KX Community

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

Home Forums kdb+ Question on streaming

  • Question on streaming

    Posted by mshk on September 13, 2021 at 12:00 am

    I have a question. Having a data source publishing real time quotes(bid price and ask price), I want to subscribe it and plot the mid price(0.5*bid+0.5*ask) using the streaming mode.  How to do it please? As shown in the picture, it seems only one filter can be applied to the streaming data source and no calculation can be done.

    mshk replied 9 months ago 3 Members · 9 Replies
  • 9 Replies
  • Laura

    Administrator
    September 14, 2021 at 12:00 am

    Hi MSHK, thanks for your question!

    Have you seen the documentation on streaming queries at: https://code.kx.com/dashboards/datasources/ ?

    Further down the page there is more information on Subscriptions using the streaming or auto-execute functionality.

    Hope this helps!

    Laura

  • dfallon

    Member
    September 16, 2021 at 12:00 am

    Hi MSHK,

    If you havent already, take a look at the example we have for setting up a streaming process.

    The screenshot you show for quote.bond has an input parameter exposed to Kx Dashboards, which is defined in your kdb streaming query.  More than one filter can be made available if required, but usually its a time series pull for a single asset so only one such query parameter is exposed.

    Your streaming query should have the necessary bid and ask calculations, results of which are then pushed to the Dashboards.  The query handles the calculations returned in the Results pane when you Execute it.  There is a Key by dropdown as part of the streaming options for Dashboards (drawn from the data columns in your query), one of which should be time or date.

    Dashboards only handles the filters from the query and the data key by, it doesnt do the underlying bid, ask calculation.

    Take a look at our latest 1.4. release, which you download from here.   We have an upgraded version of Document Graph to help manage your queries and view states, this makes it easier for Dashboard users to work with large numbers of queries and/or view states without having to go through the component UI.

    Thanks,

    Declan

  • mshk

    Member
    September 17, 2021 at 12:00 am

    Thanks. So should I do the calculation on bid and ask in some file like stream.q (in your demo)? And publish the result to dashboard?

  • dfallon

    Member
    September 17, 2021 at 12:00 am

    Yes, you want to run the calculation in q before pushing it to Dashboards.

  • mshk

    Member
    September 23, 2021 at 12:00 am

    Thanks, but I am not using query. I am using the streaming mode instead, so there is no place to enter query. How should I do then?

  • dfallon

    Member
    September 23, 2021 at 12:00 am

    Yes, assuming you have in your streaming kdb query {[x] … … where Product in x}.  Then x as your Dashboard input is the value from the Product, “cgb10y” etc.  Your value for “x” should then be assigned to a view state parameter in Dashboards, so it can be used as part of a dropdown.

  • mshk

    Member
    September 23, 2021 at 12:00 am

    Thanks for your answer. I have developed q scripts and published my own data, and my streaming data look like this (please see screenshot attached).

    My Product column contains cgb5y, cgb10y and etc.  How do I filter the streaming data only for cgb10y in the following screen? I just enter cgb10y in box after symbol??

  • mshk

    Member
    October 12, 2021 at 12:00 am

    Hi Dfallon,

    I would like to follow up on my question. I am not using query mode but streaming mode.

    As in the screenshot shows, there is no place to place query. How can I filter the streaming source and keeps cgb10y data only?

    Appreciate your help pls.

     

  • dfallon

    Member
    October 12, 2021 at 12:00 am

    Apologies,

    In your stream setup you need to define [x].

    The easiest guide for you is to perhaps look at the demo.q file inside the /sample/ directory which hosts the streaming examples which come with dashboards.  There are four streaming data sets which use [x]: book, book1Agg, book2Agg and stream.  If you use them as a template to your streaming example you should be able to set [x] as a filter.

    You can test these four examples in the dashboard by using an FX symbol like EUR/USD.

    Hope this helps,
    Declan

Log in to reply.