Skip to content

feat(prediction): add Binance Prediction L2 market-data adapter - #59

Merged
proerror77 merged 1 commit into
mainfrom
codex/prediction-l2-market-data
Jul 16, 2026
Merged

proerror77 merged 1 commit into
mainfrom
codex/prediction-l2-market-data

Conversation

@proerror77

Copy link
Copy Markdown
Owner

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-prediction
  • cargo check -p hft-runtime

Rollout and rollback

Quotes-only configuration remains the default. Revert this PR to remove the adapter registration.

Scope exception

None.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proerror77, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5e357e2a-6f7b-499e-af9c-c12b709a11e8

📥 Commits

Reviewing files that changed from the base of the PR and between 42ade9a and 463ab0e.

⛔ Files ignored due to path filters (1)
  • rust_hft/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • rust_hft/Cargo.toml
  • rust_hft/config/dev/binance_prediction_live.yaml.example
  • rust_hft/config/dev/binance_prediction_quotes_only.yaml.example
  • rust_hft/data-pipelines/adapters/adapter-binance-prediction/Cargo.toml
  • rust_hft/data-pipelines/adapters/adapter-binance-prediction/src/lib.rs
  • rust_hft/market-core/runtime/Cargo.toml
  • rust_hft/market-core/runtime/src/system_builder.rs
  • rust_hft/market-core/runtime/src/system_builder/config_loader.rs
  • rust_hft/market-core/runtime/src/system_builder/venue_registry.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/prediction-l2-market-data

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proerror77
proerror77 marked this pull request as ready for review July 16, 2026 07:26
@proerror77
proerror77 merged commit 354cd61 into main Jul 16, 2026
21 of 22 checks passed
@proerror77
proerror77 deleted the codex/prediction-l2-market-data branch July 16, 2026 07:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +240 to +241
ticker.tick().await;
for (symbol, outcome) in &selected {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +1510 to +1511
config.api_key = venue_cfg.api_key.clone().unwrap_or_default();
config.api_secret = venue_cfg.secret.clone().unwrap_or_default();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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