feat(@typedtrader/exchange): pick the Alpaca data feed from the account's subscription - #1375
Merged
Merged
Conversation
…nt's subscription Market data requests pinned feed=iex, so historical bars came from a single exchange even though every account may read consolidated SIP history older than 15 minutes: AAPL on 2025-12-01 reports 46.6M shares on the default feed against 1.6M on IEX. Omitting the parameter lets Alpaca serve the best feed the subscription allows. A stream URL has to name a feed, so the entitlement is probed once and falls back to IEX.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AlpacaMarketDatapinnedfeed=iexon every stock market data request and always streamedv2/iex.Historical data was worse than the account allows
Alpaca serves the best feed the subscription allows when the
feedparameter is omitted, and SIP history older than 15 minutes is available on the free plan too. Pinning IEX therefore replaced consolidated bars with one exchange's share of them. Same day, same account:Backtests and indicators ran on those IEX-only bars. The parameter is now omitted, so each account gets what it is entitled to.
The stream has to name a feed
A stream URL is either
v2/iexorv2/sip, so there is nothing to omit. The entitlement is probed once per instance by asking a latest endpoint for SIP: it answerssubscription does not permit querying recent SIP datawithout the Algo Trader Plus plan. SIP entitlement streamsv2/sip, anything else falls back tov2/iex, which every account can stream.Checks
Against Alpaca with a real key: the bar comparison above, and the probe returning 403 with that message on a free plan, so the stream stays on IEX. Unit tests cover the omitted
feedand both probe outcomes; each fails when the old behavior is put back.