market depth

amit123
I am receiving some ticks where

tick['depth']['buy'][0]['price'] < tick['depth']['buy'][1]['price']
which should never happen.
and ( similarly where sell price at depth 2 is lower than sell price of depth 1 and other combinations)
such ticks are rare (less than 0.1%). But why is this happening?
This looks like a bug.
Tagged:
  • ZI4453
    please post that tick data...
  • amit123
    amit123 edited September 2019
    i was not saving the ticks, but their values in a dataframe. However i'll save these problem ticks and post it here in a day or two.
  • amit123
    here is an example of a tick with tick['depth']['sell][0]['price'] > tick['depth']['sell'][1]['price']

    {'tradable': True, 'mode': 'full', 'instrument_token': 1510401, 'last_price': 662.45, 'last_quantity': 15, 'average_price': 664.39, 'volume': 41984, 'buy_quantity': 61765, 'sell_quantity': 42870, 'ohlc': {'open': 667.0, 'high': 667.0, 'low': 667.0, 'close': 670.9}, 'change': -1.2595021612758879, 'last_trade_time': datetime.datetime(2019, 9, 17, 9, 15, 1), 'oi': 0, 'oi_day_high': 0, 'oi_day_low': 0, 'timestamp': datetime.datetime(2019, 9, 17, 9, 15, 1), 'depth': {'buy': [{'quantity': 201, 'price': 661.85, 'orders': 4}, {'quantity': 3219, 'price': 661.8, 'orders': 3}, {'quantity': 1200, 'price': 661.7, 'orders': 1}, {'quantity': 158, 'price': 661.65, 'orders': 1}, {'quantity': 391, 'price': 661.5, 'orders': 1}], 'sell': [{'quantity': 2259, 'price': 667.4, 'orders': 1}, {'quantity': 75, 'price': 662.9, 'orders': 3}, {'quantity': 299, 'price': 663.0, 'orders': 1}, {'quantity': 949, 'price': 663.5, 'orders': 2}, {'quantity': 1200, 'price': 663.55, 'orders': 1}]}}

    here is an example of tick with tick['depth']['buy'][0]['price']< tick['depth']['buy'][1]['price']

    {'tradable': True, 'mode': 'full', 'instrument_token': 11400706, 'last_price': 16690.0, 'last_quantity': 25, 'average_price': 16746.56, 'volume': 20600, 'buy_quantity': 4875, 'sell_quantity': 6200, 'ohlc': {'open': 16700.0, 'high': 16865.9, 'low': 16657.9, 'close': 16776.1}, 'change': -0.5132301309601073, 'last_trade_time': datetime.datetime(2019, 9, 17, 10, 22, 13), 'oi': 379450, 'oi_day_high': 379625, 'oi_day_low': 377875, 'timestamp': datetime.datetime(2019, 9, 17, 10, 22, 41), 'depth': {'buy': [{'quantity': 50, 'price': 16683.35, 'orders': 2}, {'quantity': 25, 'price': 16686.6, 'orders': 1}, {'quantity': 25, 'price': 16686.25, 'orders': 1}, {'quantity': 25, 'price': 16680.15, 'orders': 1}, {'quantity': 25, 'price': 16680.1, 'orders': 1}], 'sell': [{'quantity': 25, 'price': 16697.75, 'orders': 1}, {'quantity': 25, 'price': 16699.4, 'orders': 1}, {'quantity': 50, 'price': 16699.45, 'orders': 2}, {'quantity': 25, 'price': 16704.35, 'orders': 1}, {'quantity': 25, 'price': 16704.5, 'orders': 1}]}}

    Please see the attached file for 290+ examples.
  • sujith
    Hi @amit123,
    Is this something that popped up recently? Or you just tried it now.
    This shouldn't be happening. We have informed concerned team to take a look at this.
  • sujith
    Is this happening for these scrips or it can be random?
  • sujith
    Only the first price value in depth is off or it can be any of the five values?
  • ZI4453
    @amit123 , just to confirm was there any data processing done(in your end) before you read this data ?
    if possible can you please confirm (compare)this with partial mode data also ?
    if partial data emits same then its data is incorrect,
    if partial is giving correct data and full is emitting wrong data i think we need to take look at our data conversion process(our end) and if everything is correct then its issue from Broker's end.
  • amit123
    amit123 edited September 2019
    @sujith
    I first noticed it sometime around last week of august. At first I suspected I was doing something wrong so i did not report it immediately here. It does not happen for all scripts. But it does happen everyday for about 0.1% of the ticks.
  • amit123
    amit123 edited September 2019
    @ZI4453
    i readjusted my code so that i collect any wrong tick right in the first line before any processing.

    in any case it would be very easy for you to replicate the above problem since it happens every day for some ticks.
  • sujith
    @amit123,
    I will forward your inputs to the team and get back to you if anything is needed.
  • ZI4453
    @amit123, this is something critical which you have reported .. please keep this updated if it happens again . If folks are on bid_0 and Ask_0 then their strategy might have some impact due to this error.
  • amit123
    hi @ZI4453 and @sujith . any update on the issue? the problem is still not solved.
  • amit123
    amit123 edited September 2019
    hello! please let me know about the status of this issue. By when can one hope this to be resolved? thanks in advance.
  • sujith
    Hi @amit123,
    There is a new version of the adapter that is coming out, hopefully this is solved once it is deployed. This has to go through mock in order to be pushed to live as it is a very critical piece.
    I really hope this will be gone in the next release otherwise, the cycle has to be repeated. Since the cycle involves mock trading to be done, it is taking a while.
    Thank you for your patience.
  • amit123
    that is great ! thanks a lot @sujith
This discussion has been closed.