websocket connection with multithreading

HP036
I have a program that properly works, and fetches the data in real-time and save the data in csv file in every minute and websocket connection for fetching data at given time, and close the connection at a given time properly works,
but when i run the code, it connects the websocket at a given time, and at that time it fetches all nse nifty50 stocks data, and that single entry of all stocks saved into csv file, but after first minute, the data again fetched but it not fetches all the data , it only fetches 34 stocks data out of 50, and in third minute it fetches 37 stocks data and save into csv file, but not fetches for the all stocks, means after first instance it fetches randomely stocks data but not fetches all data, why? give me the solution with the example, and kindly help to solve this error using multithreading , so it fetches the all stocks data separately in every single minute
  • sujith
    Are you closing the websocket and connecting again or are you doing unsubscribe and subscribe again?
    Do check out the tick frequency in the FAQs thread to know more about the Kite Ticker behavior.
  • HP036
    No, i am not connecting again, and unsubscribe again, i run that code for Nifty500 also, same issue generated in first minute it generates the all 500 stocks data and save single entry in csv file, but at second minute it stops to fetching data after 197 or 152 stocks data generating and same at third minute it stops the fetching data after 134 or 210 stocks data, not fetches all data, is this issue regarding rate limits or tick frequency?, how i overcome with this issue?, and is it solve using multithreading and fetches all 500 stocks single data in every minute?, if yes then how, can you explain me with example?
  • rakeshr
    first minute, the data again fetched but it not fetches all the data , it only fetches 34 stocks data out of 50, and in third minute it fetches 37 stocks data
    how i overcome with this issue?, and is it solve using multithreading and fetches all 500 stocks single data in every minute?,
    WebSocket streams data when received from the exchange, so it can happen that there won't be a tick every second for those indices when you were trying to parse and dump it. Maybe you can create a map that keeps the last available tick for all keys (i.e., indices here) and dumps it to CSV at the required interval.
    Go through the websocket streaming FAQs.
  • HP036
    HP036 edited April 19
    Thanks @rakeshr , but i want to save all 50 stocks data every minute, so if any stocks is not fetched from that 50 stocks then, can i take the previous data of that non-updated stocks(is it correct data for that timing) OR any other method?
Sign In or Register to comment.