Skip to content

Capture individual Binance trades - #60

Open
tradingexpert wants to merge 4 commits into
mainfrom
feature/binance-raw-trades
Open

Capture individual Binance trades#60
tradingexpert wants to merge 4 commits into
mainfrom
feature/binance-raw-trades

Conversation

@tradingexpert

@tradingexpert tradingexpert commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • capture Binance USD-M individual @trade WebSocket messages alongside depth
  • preserve aggregate trades only as an independent reconciliation stream
  • record explicit individual trade-ID discontinuities within each connection
  • expose typed BinanceIndividualTrade records through individual_trades()
  • retain a supplemental /fapi/v1/trades recorder for isRPITrade, overlap auditing, and recovery evidence
  • preserve exact REST payloads, poll metadata, errors, deduplication, and confirmed missing-ID ranges
  • align the connector, schema, data guide, changelog, and public docs with the two-source design

Why both individual-trade sources

The real-time WebSocket @trade stream is the primary individual-trade evidence. It avoids the information loss in aggTrade and the rolling-window risk of REST-only polling. The REST endpoint contributes the additional isRPITrade field and independent reconciliation evidence. aggTrade is retained for comparison, never as a substitute for individual trades.

Live testing rejected the initial REST-only design after observed BTCUSDT/ETHUSDT bursts rolled beyond the 1,000-row response window. The implementation and documentation now state that limitation directly.

Live validation

A two-symbol live smoke run captured:

  • 721 individual WebSocket trades over about 22 seconds
  • zero trade-ID discontinuities
  • zero connection errors
  • concurrent 100 ms depth, book ticker, and aggregate-trade evidence

Verification

  • python -m ruff check .
  • python -m pytest --cov=ordersim --cov-report=term-missing
    • 237 passed
    • 98.96% total coverage
    • 100% statement and branch coverage for every Binance module
  • python -m build --outdir /tmp/ordersim-dist-cea0861
  • python -m twine check /tmp/ordersim-dist-cea0861/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant