altangent / ccxws

WebSocket client for 38 cryptocurrency exchanges
MIT License
617 stars 186 forks source link

'size' is 0 for Level 2 on Binance, which is incorrect #213

Closed jazoom closed 4 years ago

jazoom commented 4 years ago

Exchange Binance

Subscription type Level2 orderbook updates

Describe the bug BTC/USDT Level 2 updates produce objects that look like this:

Level2Point {
  price: '10258.93000000',
  size: '0.00000000',
  count: undefined,
  meta: undefined
}

I confirmed by watching the feed alongside Binance's order book feed here: https://www.binance.com/en/orderbook/BTC_USDT The size is definitely not 0. From what I can tell, this library reports size: '0.00000000' for any value below 1 BTC.

Expected behavior Report the actual values.

bmancini55 commented 4 years ago

Thanks for submitting an issue! I confirmed that the Binance L2 update stream is reporting values as taken directly from the feed. You can see a sampling below.

Binance and many other exchanges report 0 size to indicate it is safe to delete the price point from your order book. You can refer to this section in their API documentation on how to maintain a local view.

If this isn't the issue you're having I can reopen this issue. Thanks!


Level2Update {
  exchange: 'Binance',
  base: 'BTC',
  quote: 'USDT',
  sequenceId: 5723950387,
  lastSequenceId: 5723950398,
  asks: [
    Level2Point {
      price: '10449.86000000',
      size: '6.84253200',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10449.95000000',
      size: '2.00009000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10449.96000000',
      size: '0.08657500',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10449.97000000',
      size: '0.00000000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10451.53000000',
      size: '0.00000000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10452.03000000',
      size: '0.00882000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10457.94000000',
      size: '0.00000000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    }
  ],
  bids: [
    Level2Point {
      price: '10449.34000000',
      size: '0.00750200',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10448.82000000',
      size: '0.00000000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    },
    Level2Point {
      price: '10438.98000000',
      size: '0.00000000',
      count: undefined,
      meta: undefined,
      timestamp: undefined
    }
  ]
} { id: 'BTCUSDT', base: 'BTC', quote: 'USDT' }
``
jazoom commented 4 years ago

Maybe that was it. Since the feeds move so fast it's hard to compare every single item in both lists. I didn't realise that's what was happening. Thank you for the explanation and sorry for taking up your time.