Skip to content

Respect priceQuality in streamed quotes - #5007

Merged
fleupold merged 4 commits into
mainfrom
fix/streamed-quotes-price-quality
Oct 2, 2026
Merged

fleupold merged 4 commits into
mainfrom
fix/streamed-quotes-price-quality

Conversation

@fleupold

Copy link
Copy Markdown
Contributor

Description

Up until now streamed quotes would ignore the price quality tag that is passed in and always return verified quote semantics. This PR makes it so that optimal are handled according to their proper semantics, while fast quotes get rejected (streams are faster than fast quotes)

Changes

  • Configure the price estimator with streamed quoters per price quality
  • Introduce new error type for when a fast quote is requested via streaming
  • Update API docs

How to test

Adjusted existing e2e test

@fleupold
fleupold requested a review from a team as a code owner September 30, 2026 13:36
@github-actions

Copy link
Copy Markdown

Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:

  • You explicitly pointed out breaking changes.
  • You communicate the changes to affected teams (at least Frontend team and SAFE team).
  • You provide proper versioning and migration mechanisms.

Caused by:

@claude

claude Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @fleupold's task in 2m 12s —— View job


PR Review: Respect priceQuality in streamed quotes

  • Read PR diff and understand the change
  • Verify quoter wiring (run.rs, quoter.rs)
  • Verify error handling + HTTP mapping
  • Verify docs and e2e test
  • Check type compatibility / compilation soundness

I reviewed the full diff. This is a well-scoped, correct change and I found no blocking issues.

What I verified

  • Estimator wiring matches non-streaming semantics. optimal streaming now uses unverified_price_estimator (no verification, ranked by promised price) and verified uses the verified price_estimator — the same estimators the one-shot POST /api/v1/quote uses for those qualities. create_quoter(...).with_streaming_estimator(...) only sets an optional field, so it doesn't alter the non-streaming path (crates/orderbook/src/run.rs:376).
  • Type soundness. Both price_estimator and unverified_price_estimator return the same Arc<CompetitionEstimator<Arc<dyn PriceEstimating>>>, which already implements StreamingPriceEstimating (it's passed to with_streaming_estimator for the verified quoter), so the new optimal wiring compiles.
  • Fail-fast rejection. StreamingQuoters::get returns None only for Fast and the match is exhaustive, so a new PriceQuality variant would force a compile error. UnsupportedPriceQuality is resolved before build_quote_params, so a rejected fast request never emits a dangling quoteRequested event.
  • HTTP mapping. post_quote_stream.rs returns err.into_response() for the pre-stream error, and OrderQuoteError::UnsupportedPriceQuality maps to 400 BAD_REQUEST with the UnsupportedPriceQuality error body — matching the new e2e assertion and the unit test.
  • Docs. openapi.yml accurately describes the new per-quality semantics, and UnsupportedPriceQuality is inserted in the correct alphabetical position in both the prose list and the enum.
  • Tests. The e2e test now covers all three qualities (fast rejected, optimal unverified, verified persisted + reused). Default PriceQuality is Verified, so the final unchanged-request leg genuinely exercises the verified path.

Nice, focused PR. 👍
• branch fix/streamed-quotes-price-quality

@MartinquaXD MartinquaXD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if forbidding fast streamed quotes is unnecessarily restrictive but I'm fine with not supporting it as it would be strictly better for the caller to use optimal instead.

Comment on lines +1087 to +1088
optimal_quotes.iter().all(|quote| !quote.verified),
"expected optimal streaming quotes to be unverified, got {optimal_quotes:?}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we also have such an assertion on the verified request? It's not required that there is a verified quote in the responses but in practice all quotes in e2e tests should be verified so we could tighten the test slightly by asserting that at least 1 quote is verified.

@fleupold
fleupold enabled auto-merge October 2, 2026 09:26
@fleupold
fleupold added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit eeea14d Oct 2, 2026
24 checks passed
@fleupold
fleupold deleted the fix/streamed-quotes-price-quality branch October 2, 2026 09:51
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants