KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ sym flipping back and forth when creating continues futures contacts based on volume Re: sym flipping back and forth when creating continues futures contacts based on volume

  • Laura

    Administrator
    May 19, 2022 at 12:00 am

    Full answer on SO.

    TL;DR:  find cumulative maxima; eliminate recurrences; upsert into an empty table; fill nulls

    Eliminating recurrences uses a vector idiom inherited from APL that flags duplicate items in a list. In APL its (??x)?x?x, which translates easily into q as (til count x)<>x?x.