Skip to content

Commit

Permalink
Protect against KeyError on balanceUpdate
Browse files Browse the repository at this point in the history
Got a report for KeyError on del balances with 'LDDOGE' as key, apparently this key doesn't correspond to any known spot asset and it should be safe to ignore such asset updates

(cherry picked from commit c96b553)
  • Loading branch information
idkravitz authored and edeng23 committed Jun 8, 2021
1 parent 7d393a0 commit d76e4da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion binance_trade_bot/binance_stream_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def _process_stream_data(self, stream_data):
elif event_type == "balanceUpdate": # !userData
self.logger.debug(f"Balance update: {stream_data}")
with self.cache.open_balances() as balances:
del balances[stream_data["asset"]]
asset = stream_data["asset"]
if asset in balances:
del balances[stream_data["asset"]]
elif event_type in ("outboundAccountPosition", "outboundAccountInfo"): # !userData
self.logger.debug(f"{event_type}: {stream_data}")
with self.cache.open_balances() as balances:
Expand Down

0 comments on commit d76e4da

Please sign in to comment.