Commit graph

2 commits

Author SHA1 Message Date
Viktor Barzin
bcd0857729 feat(backtest): wire real Alpaca historical fetcher
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Previously the backtest API instantiated a _NoAlpaca stub that
returned an empty DataFrame for every fetch_daily_bars call, so the
mention-driven engine had no price data to mark trades against and
every backtest reported total_return=0 / trade_count=0.

Replace with _AlpacaHistoricalFetcher which:
- Uses StockHistoricalDataClient (alpaca-py) with Day timeframe
- Reads creds from TRADING_ALPACA_API_KEY/SECRET_KEY env vars (already
  injected via trading-bot-secrets ESO)
- DataFeed.IEX (free tier — same as services/market_data uses)
- Lazy-instantiates the SDK clients on first use to avoid import cost
  in the api-gateway hot path
- Returns indexed DataFrame matching KevinPriceLoader's expected shape
  ([open, high, low, close, volume], timestamp index)
- Returns empty DataFrame on Alpaca failure (loader has its own
  cache-miss fallback that no-ops gracefully)

is_asset_tradable also wired to the real Alpaca TradingClient so the
backtest doesn't trade non-tradable tickers.
2026-05-26 21:09:40 +00:00
886dbaec86 feat(api): /api/meet-kevin/backtest/* routes
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
2026-05-24 01:10:34 +00:00