Feeds still not reliable



  • Somehow the feeds are still not reliable. Can you advise if the reliability is likely to improve or would it be better to code some polling mechanish to see which feeds have stopped and resubscribe to them ?

    As you can see, some of the feeds for me with new ltp and timestamp stopped arround 14:40

    2017-07-20 14:45:45	ICICIBANK17JULFUT
    2017-07-20 14:47:08	FEDERALBNK17JULFUT
    2017-07-20 14:50:10	SBIN17JULFUT
    2017-07-20 15:29:56	KOTAKBANK17JULFUT
    2017-07-20 15:29:59	HDFCBANK17JULFUT
    

    While some did get the final few feeds, most of the feeds seem to have a mind of their own. Can you please suggest what to expect ?


  • Global Moderator

    Hi @abbanerjee ,

    All the subscribed feeds come to you in a single packet/object through socket
    For Eg, if I subscribed INFY, SBIN, ONGC the structure of the packet/object will be

    [{"timestamp":"1500609623000","exchange":"NSE_EQ","symbol":"INFY","ltp":"977.95","close":"969.45"},{"timestamp":"1500609623000","exchange":"NSE_EQ","symbol":"ONGC","ltp":"164.65","close":"165.85"},{"timestamp":"1500609624000","exchange":"NSE_EQ","symbol":"SBIN","ltp":"291.75","close":"290.95"}]

    [{"timestamp":"1500609624000","exchange":"NSE_EQ","symbol":"INFY","ltp":"977.95","close":"969.45"},{"timestamp":"1500609624000","exchange":"NSE_EQ","symbol":"ONGC","ltp":"164.65","close":"165.85"},{"timestamp":"1500609625000","exchange":"NSE_EQ","symbol":"SBIN","ltp":"291.75","close":"290.95"}]

    [{"timestamp":"1500609624000","exchange":"NSE_EQ","symbol":"INFY","ltp":"977.95","close":"969.45"},{"timestamp":"1500609624000","exchange":"NSE_EQ","symbol":"ONGC","ltp":"164.65","close":"165.85"},{"timestamp":"1500609625000","exchange":"NSE_EQ","symbol":"SBIN","ltp":"291.75","close":"290.95"}]

    As you can see it is an Array Of Objects, you either get it or you miss it. In the array, every object corresponds to one of the subscribed instruments, currently, we are sending all the instruments even if there is no change in them.

    So either you get the object or you won't get it, the subscribed feeds won't get removed from the object unless you unsubscribe them.

    I would request you to please check your code once and see if you are unsubscribing some instruments.

    Also if you are sharing your api-key and secret with someone else, any change made by that person will reflect on your account i.e if he subscribes or unsubscribes something it will reflect on your feed too.

    Thanks,
    Alok Gaira



  • So your event parameter in the event handler will actually be a list of dictionary ?

    That must be the reason why I dont see the quotes as its not yet documented that one may expect an array of objects, but thanks for letting me know.


  • Global Moderator

    Hi @abbanerjee ,

    Sorry I missed, you are using our Python SDK.

    In our Python SDK, we are requesting the feed as a CSV, not as a JSON

    So the response from server is like this:

    1500616450000,NSE_EQ,INFY,978.4,969.45;1500616454000,NSE_EQ,SBIN,291.7,290.95;1500616455000,NSE_EQ,RELIANCE,1577.35,1528.9;1500616454000,NSE_EQ,ONGC,165.5,165.85

    1500616455000,NSE_EQ,INFY,978.35,969.45;1500616455000,NSE_EQ,SBIN,291.7,290.95;1500616455000,NSE_EQ,RELIANCE,1577.35,1528.9;1500616454000,NSE_EQ,ONGC,165.5,165.85

    1500616455000,NSE_EQ,INFY,978.35,969.45;1500616456000,NSE_EQ,SBIN,291.7,290.95;1500616455000,NSE_EQ,RELIANCE,1577.9,1528.9;1500616455000,NSE_EQ,ONGC,165.5,165.85

    1500616457000,NSE_EQ,INFY,978.35,969.45;1500616457000,NSE_EQ,SBIN,291.7,290.95;1500616457000,NSE_EQ,RELIANCE,1577.85,1528.9;1500616456000,NSE_EQ,ONGC,165.55,165.85

    1500616458000,NSE_EQ,INFY,978.45,969.45;1500616458000,NSE_EQ,SBIN,291.7,290.95;1500616458000,NSE_EQ,RELIANCE,1577.35,1528.9;1500616456000,NSE_EQ,ONGC,165.55,165.85

    We are splitting it and changing it to Instruments Object and then sending it to your event handler one by one. This is all done to save your bandwidth and maintain OOPs paradigm.

    Take a deep dive on this part of the code (Python SDK) for better understanding
    https://github.com/upstox/upstox-python/blob/master/upstox_api/api.py#L186

    But the concept remains the same either you get all or none.
    Rest assured we will update our docs as per your queries.

    Thanks,
    Alok Gaira



  • @AlokGaira said in Feeds still not reliable:

    1500616450000,NSE_EQ,INFY,978.4,969.45;1500616454000,NSE_EQ,SBIN,291.7,290.95;1500616455000,NSE_EQ,RELIANCE,1577.35,1528.9;1500616454000,NSE_EQ,ONGC,165.5,165.85

    Okay, so eventually then the event handler recieves each packet with one ticker only correct ?

    In that case, it dosent explain my original question why the data for few tickers didnt move for last 1.5 hours of market closing. Can you please look into it ?


  • Global Moderator

    Hi @abbanerjee ,

    Try running this and send me the last 20 print messages after market close, change the stocks as per your will.
    This will help me debug the issue.

    def event_handler_quote_update(message):
        print(message)
    
    u.set_on_quote_update(event_handler_quote_update)
    
    u.unsubscribe(u.get_instrument_by_symbol('NSE_EQ', 'ONGC'), LiveFeedType.LTP)
    u.subscribe(u.get_instrument_by_symbol('NSE_EQ', 'ONGC'), LiveFeedType.LTP)
    
    u.unsubscribe(u.get_instrument_by_symbol('NSE_EQ', 'INFY'), LiveFeedType.LTP)
    u.subscribe(u.get_instrument_by_symbol('NSE_EQ', 'INFY'), LiveFeedType.LTP)
    
    u.unsubscribe(u.get_instrument_by_symbol('NSE_EQ', 'SBIN'), LiveFeedType.LTP)
    u.subscribe(u.get_instrument_by_symbol('NSE_EQ', 'SBIN'), LiveFeedType.LTP)
    
    u.unsubscribe(u.get_instrument_by_symbol('NSE_EQ', 'TATASTEEL'), LiveFeedType.LTP)
    u.subscribe(u.get_instrument_by_symbol('NSE_EQ', 'TATASTEEL'), LiveFeedType.LTP)
    
    u.start_websocket(False)
    

    Thanks,
    Alok Gaira



  • @AlokGaira I see that you set the event handler before you subscribe. Is that the better sequence ?


  • Global Moderator

    @abbanerjee No you can subscribe at any sequence, it doesn't matter.


Log in to reply
 

Looks like your connection to Upstox Forum was lost, please wait while we try to reconnect.