KX Community

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

Home Forums kdb+ Range Bar in kdb Reply To: Range Bar in kdb

  • unterrainer_ale

    Member
    July 23, 2024 at 3:52 pm

    Hi rgiu70,

    not sure if this is what you are looking for, but if you have a table and just want to get the open, high, low, close by sym you can run the following query

    </p><p>q)t:([] sym:20?AAPLMSFTC; price:20?100.0)

    q)t

    sym price

    ————-

    MSFT 39.27524

    MSFT 51.70911

    C 51.59796

    AAPL 40.66642

    MSFT 17.80839

    C 30.17723

    MSFT 78.5033

    C 53.47096

    MSFT 71.11716

    AAPL 41.1597

    AAPL 49.31835

    MSFT 57.85203

    C 8.388858

    MSFT 19.59907

    C 37.5638

    AAPL 61.37452

    AAPL 52.94808

    C 69.16099

    AAPL 22.96615

    MSFT 69.19531

    q)exec ohlc!(first;max;min;last)@\:price by sym from t

    | o h l c

    —-| ———————————–

    AAPL| 40.66642 61.37452 22.96615 22.96615

    C | 51.59796 69.16099 8.388858 69.16099

    MSFT| 39.27524 78.5033 17.80839 69.19531

    q)

    `