Same OHLC data on every tick

MihirGore
MihirGore edited October 2020 in Python client
Hi, using your Python Socket API, since last month I am getting the same OHLC data throughout the day. The same was working correctly previous month. Pls help.
The following the log from today received via Python Websocket. Notice how no change is there:
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54906470, datetime.datetime(2020, 10, 5, 15, 27, 22))
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54906555, datetime.datetime(2020, 10, 5, 15, 27, 23))
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54906555, datetime.datetime(2020, 10, 5, 15, 27, 23))
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54907235, datetime.datetime(2020, 10, 5, 15, 27, 24))
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54911160, datetime.datetime(2020, 10, 5, 15, 27, 26))
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54912585, datetime.datetime(2020, 10, 5, 15, 27, 27))
('NSE:TATAMOTORS', {'open': 136.95, 'high': 137.5, 'low': 132.05, 'close': 133.5}, 54913420, datetime.datetime(2020, 10, 5, 15, 27, 28))


This happens for the entire day. What is going on?? My entire subscription duration is getting wasted please help ASAP
Tagged:
  • sujith
    If high and low doesn't change then it won't be updated. Open and close are anyways ther same throughout the day. What is the problem here?
  • MihirGore
    MihirGore edited October 2020
    But the real high low is changing.... On Zerodha dashboard I'm getting correct values but by KiteConnect Python API the same values of High Low repeat throughout the day... any suggestions?

    Only start of the day I get new High Low values. They do not change by one point throughout the day
  • sujith
    The OHLC API gives you the day's OHLC but the candle data will give you OHLC for the minute or any other specified interval. Can you let us know what are you looking for?
  • MihirGore
    Hi Sujith, my earlier comment somehow disappeared so I'm gonna repost.

    I need to get live High Low data feed throughout the day. For that purpose, I am using the following code (which worked for me last month, as in I was getting live changes in High/Low every second), taken from official Python API documentation for Websocket at https://github.com/zerodhatech/pykiteconnect/

    Kindly let me know what I might be doing wrong, thank you.
    from kiteconnect import KiteTicker

    # Initialise
    kws = KiteTicker('xxxx', 'xxxx')

    def on_ticks(ws, ticks):
    # Callback to receive ticks.
    logging.debug("Ticks: {}".format(ticks))

    def on_connect(ws, response):
    # Callback on successful connect.
    # Subscribe to a list of instrument_tokens
    ws.subscribe([738561])
    ws.set_mode(ws.MODE_FULL, [738561])

    def on_close(ws, code, reason):
    # On connection close stop the main loop
    # Reconnection will not happen after executing `ws.stop()`
    ws.stop()

    # Assign the callbacks.
    kws.on_ticks = on_ticks
    kws.on_connect = on_connect
    kws.on_close = on_close

    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()
  • rakeshr
    @MihirGore
    I am using the following code (which worked for me last month, as in I was getting live changes in High/Low every second), taken from official Python API
    This example code is working perfectly fine.
    Can you paste your complete Websocket code here?
  • MihirGore
    @rakeshr
    I have run the above code on MCX: CRUDEOIL20OCTFUT.
    As I see on Zerodha dashboard, the High and Low are changing constantly. But from the Websocket API I am getting the same OHLC values constantly.

    Output of the above code for MCX:CRUDEOIL20OCTFUT
    (Note that High Low is coming the same but volume is changing )
     

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37068, 'buy_quantity': 2439, 'sell_quantity': 2530, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 57), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 46, 57), 'depth': {'buy': [{'quantity': 78, 'price': 2899.0, 'orders': 19}, {'quantity': 64, 'price': 2898.0, 'orders': 15}, {'quantity': 150, 'price': 2897.0, 'orders': 46}, {'quantity': 58, 'price': 2896.0, 'orders': 15}, {'quantity': 26, 'price': 2895.0, 'orders': 11}], 'sell': [{'quantity': 45, 'price': 2900.0, 'orders': 9}, {'quantity': 116, 'price': 2901.0, 'orders': 55}, {'quantity': 84, 'price': 2902.0, 'orders': 27}, {'quantity': 49, 'price': 2903.0, 'orders': 11}, {'quantity': 38, 'price': 2904.0, 'orders': 8}]}}]

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37068, 'buy_quantity': 2439, 'sell_quantity': 2535, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 57), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 46, 57), 'depth': {'buy': [{'quantity': 78, 'price': 2899.0, 'orders': 19}, {'quantity': 59, 'price': 2898.0, 'orders': 14}, {'quantity': 145, 'price': 2897.0, 'orders': 45}, {'quantity': 58, 'price': 2896.0, 'orders': 15}, {'quantity': 31, 'price': 2895.0, 'orders': 12}], 'sell': [{'quantity': 55, 'price': 2900.0, 'orders': 11}, {'quantity': 122, 'price': 2901.0, 'orders': 61}, {'quantity': 78, 'price': 2902.0, 'orders': 21}, {'quantity': 49, 'price': 2903.0, 'orders': 11}, {'quantity': 38, 'price': 2904.0, 'orders': 8}]}}]

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37069, 'buy_quantity': 2437, 'sell_quantity': 2493, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 59), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 46, 59), 'depth': {'buy': [{'quantity': 84, 'price': 2899.0, 'orders': 21}, {'quantity': 152, 'price': 2898.0, 'orders': 47}, {'quantity': 69, 'price': 2897.0, 'orders': 15}, {'quantity': 43, 'price': 2896.0, 'orders': 11}, {'quantity': 26, 'price': 2895.0, 'orders': 11}], 'sell': [{'quantity': 97, 'price': 2901.0, 'orders': 35}, {'quantity': 54, 'price': 2902.0, 'orders': 40}, {'quantity': 75, 'price': 2903.0, 'orders': 16}, {'quantity': 51, 'price': 2904.0, 'orders': 9}, {'quantity': 49, 'price': 2905.0, 'orders': 26}]}}]

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37069, 'buy_quantity': 2470, 'sell_quantity': 2487, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 59), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 47), 'depth': {'buy': [{'quantity': 35, 'price': 2900.0, 'orders': 7}, {'quantity': 89, 'price': 2899.0, 'orders': 22}, {'quantity': 152, 'price': 2898.0, 'orders': 47}, {'quantity': 74, 'price': 2897.0, 'orders': 16}, {'quantity': 43, 'price': 2896.0, 'orders': 11}], 'sell': [{'quantity': 86, 'price': 2901.0, 'orders': 33}, {'quantity': 54, 'price': 2902.0, 'orders': 40}, {'quantity': 70, 'price': 2903.0, 'orders': 15}, {'quantity': 46, 'price': 2904.0, 'orders': 8}, {'quantity': 59, 'price': 2905.0, 'orders': 28}]}}]

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37069, 'buy_quantity': 2475, 'sell_quantity': 2487, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 59), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 47, 1), 'depth': {'buy': [{'quantity': 40, 'price': 2900.0, 'orders': 8}, {'quantity': 89, 'price': 2899.0, 'orders': 22}, {'quantity': 152, 'price': 2898.0, 'orders': 47}, {'quantity': 74, 'price': 2897.0, 'orders': 16}, {'quantity': 43, 'price': 2896.0, 'orders': 11}], 'sell': [{'quantity': 86, 'price': 2901.0, 'orders': 33}, {'quantity': 54, 'price': 2902.0, 'orders': 40}, {'quantity': 70, 'price': 2903.0, 'orders': 15}, {'quantity': 46, 'price': 2904.0, 'orders': 8}, {'quantity': 58, 'price': 2905.0, 'orders': 27}]}}]

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37069, 'buy_quantity': 2471, 'sell_quantity': 2487, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 59), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 47, 1), 'depth': {'buy': [{'quantity': 35, 'price': 2900.0, 'orders': 7}, {'quantity': 84, 'price': 2899.0, 'orders': 21}, {'quantity': 152, 'price': 2898.0, 'orders': 47}, {'quantity': 79, 'price': 2897.0, 'orders': 17}, {'quantity': 38, 'price': 2896.0, 'orders': 10}], 'sell': [{'quantity': 91, 'price': 2901.0, 'orders': 34}, {'quantity': 54, 'price': 2902.0, 'orders': 40}, {'quantity': 70, 'price': 2903.0, 'orders': 15}, {'quantity': 51, 'price': 2904.0, 'orders': 9}, {'quantity': 53, 'price': 2905.0, 'orders': 26}]}}]

    [{'tradable': True, 'mode': 'full', 'instrument_token': 56336903, 'last_price': 2900.0, 'last_quantity': 1, 'average_price': 2928.78, 'volume': 37069, 'buy_quantity': 2476, 'sell_quantity': 2489, 'ohlc': {'open': 2935.0, 'high': 2965.0, 'low': 2891.0, 'close': 2972.0}, 'change': -2.4226110363391657, 'last_trade_time': datetime.datetime(2020, 10, 7, 16, 46, 59), 'oi': 4053, 'oi_day_high': 4058, 'oi_day_low': 1025, 'timestamp': datetime.datetime(2020, 10, 7, 16, 47, 1), 'depth': {'buy': [{'quantity': 40, 'price': 2900.0, 'orders': 8}, {'quantity': 84, 'price': 2899.0, 'orders': 21}, {'quantity': 152, 'price': 2898.0, 'orders': 47}, {'quantity': 79, 'price': 2897.0, 'orders': 17}, {'quantity': 38, 'price': 2896.0, 'orders': 10}], 'sell': [{'quantity': 89, 'price': 2901.0, 'orders': 32}, {'quantity': 55, 'price': 2902.0, 'orders': 41}, {'quantity': 71, 'price': 2903.0, 'orders': 16}, {'quantity': 51, 'price': 2904.0, 'orders': 9}, {'quantity': 53, 'price': 2905.0, 'orders': 26}]}}]



  • rakeshr
    As I see on Zerodha dashboard, the High and Low are changing constantly.
    What values are you comparing with the kite web? Market depth, chart candle.
    Can you paste a screen-shot of specific value from the Kite web?
    (Note that High Low is coming the same but volume is changing )
    As stated by @sujith above, these High and Low values on Websocket are for the day, so it would only change when these values are changed throughout the day.
  • MihirGore
    @rakeshr
    Rakesh I am seeing the attached 1-minute updated candlestick chart on Zerodha dashboard

    Now that you mentioned depth, looking at the API logs, these candlesticks seem to be correlated with the Depth rather than High/Low of OHLC.

    Thanks for you help, I need to follow up with my senior on this
  • sujith
    @MihirGore,
    You can check out how to build candles here.
  • livekrish
    i want OHLCV for nickel live and historical data in CSV/EXCEL format?

    thanks heaps
    krish
  • sujith
    @livekrish,
    We only have data in this format. You can check out webocket documentation and historical data documentation.

    If you are looking for live market data candles then we suggest generating candles at your end using the websocket data.
Sign In or Register to comment.