fix(data): tolerate bounded Binance source clock lead - #121
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBinance receive-clock validation now permits source timestamps to lead the local receive clock by up to 1,000 milliseconds, while retaining the maximum delay check. Depth and aggregate-trade tests cover acceptance at the boundary and rejection beyond it. ChangesBinance receive-clock validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a837056b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let received_at_ms = received_at_ns / 1_000_000; | ||
| if event_time_ms > received_at_ms { | ||
| anyhow::bail!("{kind} source and receive clocks are reversed"); | ||
| if event_time_ms.saturating_sub(received_at_ms) > MAX_SOURCE_LEAD_MS { |
There was a problem hiding this comment.
Carry the clock-lead tolerance into replay filters
For accepted Binance aggTrade/depth frames whose source timestamp is 1–1000 ms ahead of receive time, this parser now permits rows with received_at < trade_time/event_time; however, checked rust_hft/prediction-markets/crates/ploy-feed-loaders/src/database.rs and the sampled replay queries still require received_at >= trade_time (lines 90–94) and received_at >= event_time (lines 121–126). Those newly accepted rows are therefore silently excluded from historical replay/features, so the tolerant capture contract does not carry through to experiments.
Useful? React with 👍 / 👎.
Change contract
Accept Binance depth and aggregate-trade source timestamps that lead the local receive clock by at most 1,000 ms while preserving the existing 30,000 ms stale-delay ceiling and rejecting larger leads fail closed.
Out of scope
Dependency or merge order
PR #118 is already merged. This PR is otherwise independent and must merge before the Binance artifact verifier is rebased and promoted.
Focused validation
cargo test --manifest-path rust_hft/Cargo.toml -p hft-data binance_market_tape— 14 passedcargo clippy --manifest-path rust_hft/Cargo.toml -p hft-data --all-targets -- -D warnings— passedcargo fmt --manifest-path rust_hft/Cargo.toml -p hft-data -- --check— passedgit diff --check origin/main...HEAD— passedRollout / rollback impact
No runtime switch is performed by this PR. Rollout is the shared parser behavior change; rollback is a single-commit revert that restores zero positive clock lead tolerance. Existing fail-closed replay safety from #118 remains in effect.
Summary by CodeRabbit