python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

How to get more depth information for bid and ask prices?

Open bmw7 opened this issue 3 years ago • 6 comments

I use Web Socket Streams to get depth information. For example:

wss://fstream.binance.com/ws/btcusdt@depth20

Here, the levels is 20, and I can get 20 bids and asks. According to API, Valid levels are 5, 10, or 20.

How to get more depth information over 20 levels?

bmw7 avatar Mar 20 '22 08:03 bmw7

It could be done by subscribe diff book depth stream. I believe binance has described this well in their official document:

partial-book-depth-streams

The How to manage a local order book correctly section is what you're looking for.

On the other hand, if you only need a snapshot of orderbook, fapi.binance.com/fapi/v1/depth http API could provide 1000 levels orderbook.

halfelf avatar Mar 21 '22 06:03 halfelf

With get_order_book(symbol="btcusdt", limit=5000)you get even 5000 levels! Keep an eye on the binance api weight! i think you can not repeat very often within one minute.

the partial book depth streams just update the first 1000 levels, so thats why you have to use a snapshot with limit=1000 in that case.

oliver-zehentleitner avatar Mar 21 '22 11:03 oliver-zehentleitner

https://binance-docs.github.io/apidocs/spot/en/#order-book

oliver-zehentleitner avatar Mar 21 '22 11:03 oliver-zehentleitner

It's interesting if you could have more than one source of data. When you get all of it from one single source your algo may be easily subjected to market manipulation, heavy volume or not.

marcuschaer avatar May 15 '22 17:05 marcuschaer

It's interesting if you could have more than one source of data. When you get all of it from one single source your algo may be easily subjected to market manipulation, heavy volume or not.

What exactly do you mean?

oliver-zehentleitner avatar May 15 '22 20:05 oliver-zehentleitner

Hello there @oliver-zehentleitner. Well, Binance's order book has their spread coming from their liquidity provider, which generates the ask and bid prices. Although the algo is directly related to Binance, it's subjected to any margin moves called by the liquidity provider itself. Also, the main problem is that the liquidity provider "sees" the hidden liquidity (which is the pending buy and sell orders) but "we"don't, since it's not been processed into the depth source until it becomes an active order.

marcuschaer avatar May 15 '22 23:05 marcuschaer