Market data
Two packs read market data through read-only adapters in the host (FR-408, FR-419, FR-429). Neither trades, bets or holds funds: there is no order, wallet, position or account code anywhere in Tevrin.
| Pack | Source | Account | Settings |
|---|---|---|---|
| Market research desk | Alpaca market data (daily bars) and Alpaca’s paper API (asset lookup) | an Alpaca paper account’s API keys | MarketData:Alpaca:KeyId, MarketData:Alpaca:SecretKey, MarketData:Alpaca:Feed |
| Forecasting desk | Polymarket’s public market data API (Gamma) | none | MarketData:Polymarket:BaseUrl (has a default) |
Both adapters send only GET requests to their configured hosts, with a 10 s timeout per attempt, 2 retries on a 5xx
answer or a timeout, a 2 MB response cap and no redirects. A failure fails the stage with MARKET_DATA_NOT_FOUND or
MARKET_DATA_UNAVAILABLE, never the app.
Alpaca keys
Without keys everything else works, and market research runs fail at snapshot with MARKET_DATA_UNAVAILABLE and
“Alpaca market data isn’t configured”.
- Sign up at Alpaca and open the paper trading dashboard. A paper account is enough: Tevrin only calls the market data API and the paper API’s asset lookup, never trading.
- Generate the paper account’s API keys. Copy the key id and the secret; the secret is shown once.
- Pick the feed:
iex(free, the default) orsip(all US exchanges, needs a paid data plan). - Set the keys where the app reads them. Use different keys per environment if you like; they’re never shared.
| Where | How |
|---|---|
| Dev loop | dotnet user-secrets set MarketData:Alpaca:KeyId <id> --project src/Tevrin.Api, and the same for MarketData:Alpaca:SecretKey |
| Docker Desktop Kubernetes | MarketData__Alpaca__KeyId and MarketData__Alpaca__SecretKey in deploy/k8s/overlays/local/secrets.env (git-ignored; placeholders in secrets.env.example), then redeploy |
| Railway | … \| railway variable set MarketData__Alpaca__KeyId --stdin --service api --environment <env>, and the same for the secret. Both names are in variables.ignore in .railway/railway.ts, and listed in deploy/railway/variables.md |
Never commit a key. The keys go out only as the APCA-API-KEY-ID and APCA-API-SECRET-KEY request headers; logs
redact those headers, and the keys never reach a prompt or a stored artifact.
Settings
| Key | Default | Notes |
|---|---|---|
MarketData:Alpaca:KeyId |
unset | secret |
MarketData:Alpaca:SecretKey |
unset | secret |
MarketData:Alpaca:Feed |
iex |
iex or sip; anything else stops the API at start-up |
MarketData:Alpaca:DataBaseUrl |
https://data.alpaca.markets |
an absolute http(s) URL, checked at start-up |
MarketData:Alpaca:AssetBaseUrl |
https://paper-api.alpaca.markets |
checked at start-up; the live trading host api.alpaca.markets is refused |
Polymarket
Polymarket’s public API needs no account or key. MarketData:Polymarket:BaseUrl defaults to
https://gamma-api.polymarket.com; leave it unset. An invalid value doesn’t stop the app, and forecast runs fail at
snapshot with MARKET_DATA_UNAVAILABLE.
Troubleshooting
| Stage error | Check |
|---|---|
MARKET_DATA_UNAVAILABLE with “isn’t configured” |
both Alpaca keys are set in this environment |
MARKET_DATA_UNAVAILABLE with “refused the market data keys (401)” or “(403)” |
the keys are current, and the feed matches your data plan (sip needs a paid plan) |
MARKET_DATA_UNAVAILABLE with “didn’t answer” or “after 3 attempts” |
the provider’s status; then retry the stage |
MARKET_DATA_NOT_FOUND |
the symbol (or the Polymarket slug or link) |