Skip to content

Commit

Permalink
add python-binance bug handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoon committed Nov 19, 2023
1 parent 2443f84 commit 445d149
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Binary file added assets/refresh_interval.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions datacollector/services/collector_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ async def get_data(self):
limit=5000,
refresh_interval=0,
ws_interval=100)
# library has a bug
self.dcm._refresh_interval = None
async with self.dcm as dcm_socket:
while True:
data = await dcm_socket.recv()
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,10 @@ The ``DepthCacheManager`` interface exposes three configuration parameters:
* ``limit`` - optional number of orders to get from orderbook (default 100, max 5000)
* ``refresh_interval`` - Optional number of seconds between cache refresh, 0 or none disables refresh completely.
* ``ws_interval`` - Optional interval for updates on websocket, default None. If not set, updates happen every second. Must be 0, None (1s) or 100 (100ms).

The first argument I want to talk about is ``refresh_interval``. Current ([1.0.19](https://pypi.org/project/python-binance/1.0.19/)) version
of the _python-binance_ library has a bug that prevents disabling it and sets to default (30 minutes) instead.
This is clearly visible when we plot the total number of bids/asks for any asset:
![](assets/refresh_interval.png)
For very liquid assets like BTC, order book can contain many more bids and asks then initial 5000 allowed by _Binance_.
So actually we don't want to refresh our order book cache at all unless there is an exception.

0 comments on commit 445d149

Please sign in to comment.