Skip to main content

Troubleshooting

MissingCredentials

If Client::from_env() or Client::builder().credentials_from_env()? returns MissingCredentials, confirm the right environment variables are present.

Market data:

  • ALPACA_DATA_API_KEY
  • ALPACA_DATA_SECRET_KEY

Trading:

  • ALPACA_TRADE_API_KEY
  • ALPACA_TRADE_SECRET_KEY

Wrong Base URL

If requests go to the wrong environment:

  • alpaca-trade reads ALPACA_TRADE_BASE_URL
  • alpaca-trade defaults to paper trading unless you switch to .live()
  • alpaca-data always targets the production market data endpoint

alpaca-mock Starts But Orders Fail

Common causes:

  • ALPACA_DATA_API_KEY / ALPACA_DATA_SECRET_KEY are not set for market-data-backed mock flows
  • auth headers are missing on trading routes
  • an HTTP fault was injected through /admin/faults/http
  • the submitted limit has not yet reached the expected mid or composite-mid fill threshold

Check:

curl http://127.0.0.1:3847/health
curl http://127.0.0.1:3847/admin/state

Notes:

  • /admin/faults/http is one-shot and clears after the next authenticated trading request
  • stock and single-option limit orders fill at mid price once that mid is reached
  • multi-leg limit orders fill at composite mid price once that composite mid is reached

Docs Site Build Issues

Rebuild with:

python3 tools/docs/generate-doc-site
npm ci --prefix website
npm run build --prefix website

Downstream cargo publish --dry-run Fails Before First Release

Before the first real crates.io publication, dependent workspace crates can fail dry-run because upstream workspace crates are not yet available on crates.io.

Expected publish order:

  1. alpaca-core
  2. alpaca-rest-http
  3. alpaca-data
  4. alpaca-trade
  5. alpaca-mock
  6. alpaca-time
  7. alpaca-option
  8. alpaca-facade

Published Crate Name Versus Source Directory

If docs or release automation mention alpaca-rest-http while the repository tree uses crates/alpaca-http, that is expected. The source directory name and the published crate name are intentionally different.

Real API Tests Skip Or Fail Outside Market Conditions

Some live tests depend on paper trading state or current market conditions. Use the documented release-confidence subset that matches the current environment, and do not replace live verification with fake data branches.