Skip to content

Add Alpaca multi-symbol stock requests, weekly and monthly bars, and asof - #155

Merged
stefan-jansen merged 9 commits into
ml4t:mainfrom
0x0f0f0f:feat/alpaca-batch-asof
Nov 24, 2026
Merged

stefan-jansen merged 9 commits into
ml4t:mainfrom
0x0f0f0f:feat/alpaca-batch-asof

Conversation

@0x0f0f0f

@0x0f0f0f 0x0f0f0f commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #152. Depends on #153; that contributor history and its corrective follow-up are included without rewriting attribution. Merge #153 first, then refresh this branch against main and qualify the resulting head.

AlpacaDataProvider.fetch_batch_ohlcv fetches stocks in bounded symbol chunks and follows every shared pagination token. Weekly/1w and monthly/1mo aliases map to Alpaca's supported timeframes. Optional asof="YYYY-MM-DD" or "-" is sent on stock requests; omitted asof preserves existing behavior. Missing symbols are absent from the canonical long frame, including the all-missing empty result.

Independent review added validation for malformed per-symbol responses, unexpected returned symbols and invalid chunk-size types. A clipped Basic-plan window ending before its start returns an empty frame without HTTP. Repeated pagination tokens fail instead of silently returning incomplete data. Per-symbol OHLC validation is preserved.

Verification at 9a2e25e8ab93370a81639e752547ded58efddc70:

  • The added batch contract tests failed 3 cases before the corrective repair and passed 4: the invalid clipped request, malformed mapping and unexpected symbol were reproduced through the public batch workflow.
  • Final focused provider, SIP, batching, registry and consistency checks: 184 passed with ResourceWarning treated as an error.
  • Tests exercise true multi-page/chunk transport, exact symbol/time/timeframe/asof parameters, canonical timestamps and numeric values, independent pagination tokens, missing symbols, malformed responses and cyclic cursors.
  • Ruff lint/format, ty and commit hooks passed.
  • Final-head hosted complete-environment and documentation checks are running. The existing lockfile audit dependency is owned by fix(ci): restore documentation and dependency audit gates #147. No final qualification or merge is claimed yet.

The provider guide documents batch behavior and ticker mapping. Its historical live-data table is contributor-supplied, not an independently reproduced live-provider benchmark. The maintainer used official API documentation and deterministic HTTP responses; no credentialed provider requests were made. The original submission disclosed Claude Code assistance; its author and commits remain preserved. Maintainer tests and repairs also used an AI coding agent.

0x0f0f0f and others added 8 commits November 21, 2026 15:12
update-all asks up to today, which a free plan answers with HTTP 403 for
the SIP feed, reported as an invalid API key. A SIP stock request now ends
sip_delay_minutes (default 15) before now; 0 disables the cut. 401/403
errors carry Alpaca's own message.
fetch_batch_ohlcv sends up to chunk_size stock tickers per request to
/v2/stocks/bars and returns one long frame in the canonical schema, each
ticker validated alone. Tickers without bars are absent, which makes
monthly bars a probe for which tickers traded, delisted ones included.
Pagination moves into _paginate, shared with the single-symbol path.
Alpaca maps a ticker to the company holding it on asof, today by default:
a renamed company's history appears under both tickers and the
multi-symbol endpoint drops the old one. asof='-' returns the bars traded
under each ticker, which keeps a store free of duplicate and missing
histories; an InstrumentRegistry then joins renames.
@stefan-jansen
stefan-jansen marked this pull request as ready for review November 24, 2026 20:16
@stefan-jansen
stefan-jansen merged commit f020629 into ml4t:main Nov 24, 2026
33 checks passed
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.

[Feature]: Alpaca multi-symbol stock requests, weekly and monthly bars, and asof

2 participants