Skip to content

Improve zero size trade logging for Binance Futures #2588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions nautilus_trader/adapters/binance/futures/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ def _handle_trade(self, raw: bytes) -> None:
# NOTE @trade is an undocumented endpoint for Futures exchanges
msg = self._decoder_futures_trade_msg.decode(raw)
instrument_id: InstrumentId = self._get_cached_instrument_id(msg.data.s)
trade_tick: TradeTick = msg.data.parse_to_trade_tick(
instrument_id=instrument_id,
ts_init=self._clock.timestamp_ns(),
)
self._handle_data(trade_tick)
try:
trade_tick: TradeTick = msg.data.parse_to_trade_tick(
instrument_id=instrument_id,
ts_init=self._clock.timestamp_ns(),
)
except ValueError as e:
self._log.debug(f"Error handling trade tick message {raw!r}, {e}")
else:
self._handle_data(trade_tick)

def _handle_mark_price(self, raw: bytes) -> None:
msg = self._decoder_futures_mark_price_msg.decode(raw)
Expand Down
13 changes: 13 additions & 0 deletions nautilus_trader/adapters/binance/futures/schemas/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ def parse_to_trade_tick(
instrument_id: InstrumentId,
ts_init: int,
) -> TradeTick:
"""
Parameters
----------
instrument_id : InstrumentId
The trade instrument ID.
ts_init : uint64_t
UNIX timestamp (nanoseconds) when the data object was initialized.

Raises
------
ValueError
If trade tick data are incorrect
"""
return TradeTick(
instrument_id=instrument_id,
price=Price.from_str(self.p),
Expand Down
Loading