feat(prediction): add Binance Prediction L2 market-data adapter - #59
Conversation
(cherry picked from commit 862b605)
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (9)
✨ Finishing Touches🧪 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: 463ab0eb7d
ℹ️ 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".
| ticker.tick().await; | ||
| for (symbol, outcome) in &selected { |
There was a problem hiding this comment.
Throttle prediction book polling per outcome
When more than one outcome is configured, this loop calls Binance Query Order Book once per token on every tick; that endpoint is documented as 200 request-weight, so the default 1000 ms interval burns 24,000 weight/minute for just two tokens and exceeds the SAPI IP budget before any other Binance traffic. In that configuration the adapter will quickly hit 429/418 responses and leave the quote stream emitting errors, so add a rate limiter/minimum per-outcome interval or use the websocket feed before supporting multiple outcomes.
Useful? React with 👍 / 👎.
|
|
||
| impl BinancePredictionMarketStream { | ||
| pub fn new(config: BinancePredictionMarketDataConfig) -> HftResult<Self> { | ||
| if config.api_key.trim().is_empty() || config.api_secret.trim().is_empty() { |
There was a problem hiding this comment.
Reject unresolved credential placeholders
If a user copies the new quotes-only example without setting BINANCE_PREDICTION_API_KEY or BINANCE_PREDICTION_API_SECRET, config_loader::expand_env_vars leaves the ${...} placeholder text intact, and this check treats it as a valid non-empty credential. The runtime then starts the polling task and signs requests with literal placeholders, producing continuous authentication failures instead of failing closed during config validation.
Useful? React with 👍 / 👎.
| } | ||
| Err(error) => { | ||
| state.connected.store(false, Ordering::SeqCst); | ||
| if tx.send(Err(error)).await.is_err() { |
There was a problem hiding this comment.
Invalidate stale books on polling failures
When a REST poll fails after this adapter has published a snapshot, this only yields Err; checked AdapterBridge::spawn_ingestion_task, and stream errors are logged but not converted into MarketEvent::Disconnect, while the aggregation layer only removes canonical books on Disconnect. In a quotes-only or live runtime with a transient 429/network/auth failure, the last Binance Prediction book remains in the engine and can still be used as if it were current, so emit a venue/symbol Disconnect before or instead of the stream error.
Useful? React with 👍 / 👎.
| config.api_key = venue_cfg.api_key.clone().unwrap_or_default(); | ||
| config.api_secret = venue_cfg.secret.clone().unwrap_or_default(); |
There was a problem hiding this comment.
Preserve credentials for v2 prediction data configs
For schema_version: v2 configs that take the shared-config path, such as the existing live example with venue_type: BINANCE_PREDICTION, shared::VenueConfig does not carry api_key, secret, or rest, so even with the environment variables set these assignments see None. If a user follows the new live-example comment and adds data_config.outcomes, the new market-data stream then fails authentication with empty credentials; preserve these fields during v2 conversion or read them from the raw YAML.
Useful? React with 👍 / 👎.
Change contract
Add a quotes-only Binance Prediction order-book adapter and register it in the runtime market-data path.
Out of scope
No execution adapter, account reconciliation, risk policy, backtest semantics, or promotion changes.
Dependencies and merge order
None.
Focused validation
cargo test -p hft-data-adapter-binance-predictioncargo check -p hft-runtimeRollout and rollback
Quotes-only configuration remains the default. Revert this PR to remove the adapter registration.
Scope exception
None.