Skip to content

Fix missing quotes when subscribing to more than 30 symbols - #41

Merged
Martin-Molinero merged 1 commit into
masterfrom
fix-level2-streams-per-connection-limit
Sep 17, 2026
Merged

Martin-Molinero merged 1 commit into
masterfrom
fix-level2-streams-per-connection-limit

Conversation

@Martin-Molinero

Copy link
Copy Markdown
Member

Description

Coinbase allows 30 level2 streams per web socket connection. Subscriptions above it are rejected with too many L2 streams requested in a single session, so those symbols streamed trades but never quotes. The rejection was only logged at debug level.

  • Data subscriptions are spread across multiple connections, 30 symbols each, using BrokerageMultiWebSocketSubscriptionManager. The main connection keeps the heartbeats and user channels
  • USD and USDC pairs share the same Coinbase stream. When they land on different connections we follow a single one, so trades and book updates are not handled twice
  • Sequence numbers are tracked per connection
  • Web socket error messages are logged as errors

Motivation and Context

Live deployments with more than 30 symbols were missing quote data for most of them.

How Has This Been Tested?

  • New StreamsQuotesForMoreSymbolsThanASingleConnectionAllows: subscribes quotes for 60 symbols and asserts they stream, passes live
  • Existing unit tests pass
  • SubscribeOnDifferentUSDTickers streams BTCUSD and BTCUSDC quotes and trades without duplicates. It can time out waiting for a BTCUSDT trade, which is illiquid. Added the received data to its assert message

🤖 Generated with Claude Code

Coinbase allows 30 level2 streams per web socket connection, the rest are
rejected with 'too many L2 streams requested in a single session', so those
symbols got trades but no quotes. The rejection was logged at debug level.

- Spread data subscriptions across multiple connections, 30 symbols each,
  using BrokerageMultiWebSocketSubscriptionManager. The main connection keeps
  the heartbeats and user channels
- USD and USDC pairs share the same stream, when they land on different
  connections follow a single one so data is not handled twice
- Track sequence numbers per connection
- Log web socket error messages as errors

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Martin-Molinero
Martin-Molinero merged commit e7fa7bb into master Sep 17, 2026
1 check failed
@Martin-Molinero
Martin-Molinero deleted the fix-level2-streams-per-connection-limit branch September 17, 2026 19:42
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