Stream and Archive Real-Time level 2 orderbook data in Python

preview_player
Показать описание
We stream level 2 orderbook data from Binance using websockets in python. We request an orderbook snapshot using the REST API, and then stream the updates to the orderbook at a frequency of up to 100 milliseconds.

We discuss how to store orderbook data on disk and why I prefer using plain text files for this purpose. As well as how to extend this system to take it into production.

⭐ Code:

Timestamps:
00:00 - Introduction
01:45 - Documentation Walkthrough
06:29 - Streaming orderbook updates via websocket
18:55 - Requesting orderbook snapshots
25:12 - Why use plain text for storing orderbook data?
30:24 - Ideas for taking this system to production
Рекомендации по теме
Комментарии
Автор

whole video series intensifies ❤ Looking forward to more! Thank you!

AI_BotBuilder
Автор

Thank you for this video. Super useful! 💪

paulnheera
Автор

Please pleas continue this Order Book series. It would be great if you add Order Book into a trading strategy

sChaikovsky
Автор

This is great! Please continue expanding this topic. One question: Once the snapshot is taken, you continue on to get the diff data, but what if the state of the LEVEL2 changes between the sanpshot and the first diff. Isn’t that going to produce wrong levels? We will be adding the diff to an outdated levels data?

cryptoeraser
Автор

Really cool stuff
I hv a question on the async performance. U a running a single async function here (also u put await on each chunk of operations), so I am wondering how does async benefit the speed here? (Coz my impression is that async benefits from running multi async functions concretely, so here where does the concurrency happen?)

wanhonglau
Автор

Hi chad it's very good, could you make this code available for download?

leonardorospendowski
Автор

Hello. I have a question for you. I hope you answer.
When using the WebSocket, if there is a sell limit order in the order book at a price of 0.1 with a volume of 10, and let's say that price matches with a buy market order at a price of 0.1 and a volume of 10, or all the sell limit orders at price 0.1 are cancelled, will the WebSocket update the ask price to 0.1 with a volume of 0? Or What can I do to know those prices are no longer in use. Thank you😊

ngocmanh
Автор

Doesn't your websocket creates lag on the receiving side? Their system quite fast and overflows the connection. How do you handle that?

bck
Автор

when I collect the stream data for a long time, I reach the rate limit of websocket API, how could you handle this?

billyluo
Автор

which version of python are you usning? this is my first time using any programming language

noumanmohsin
Автор

Hi chad, how could i put a trade on live streamd data, like data comes the algorithm check if there is any trade opend, if no then put a trade, with out using pandas or any other step that can cause a delay?
And if i put a trade and it was profitable with $10 besides the trading fee and the spread what the exchange will charge me ? What my pure profit?
Thank you very much in advance ❤

mssafy
Автор

async with connect(url) as ws:
TypeError: 'ClientConnection' object does not support the asynchronous context manager protocol

Ligthus
visit shbcf.ru