trader.marketdata.yfinance_provider module¶
yfinance implementation of MarketDataProvider.
Both methods go through Ticker.history(): fast_info’s keys have changed across yfinance releases, whereas the history frame’s columns have been stable. pandas objects are converted to domain Bar/Quote here and never leave this module.
- class trader.marketdata.yfinance_provider.YFinanceProvider(ticker_factory=None)[source]¶
Bases:
objectMarket data backed by yfinance.
- Parameters:
ticker_factory (Callable[[str], object] | None) – Builds the per-symbol data object. Overridden in tests so no network call is made.
- get_quote(symbol)[source]¶
Return the latest price, derived from the most recent 1-minute bar.
- Parameters:
symbol (str)
- Return type:
- get_history(symbol, start, end, interval='1d')[source]¶
Return OHLCV bars between start and end, both inclusive.
yfinance’s `end` is exclusive; this Protocol’s is not. The translation happens here, at the adapter boundary, because that is the only place that knows about yfinance’s convention — pushing it onto callers would mean every one of them adding a day for reasons that belong to a library they are not supposed to know about.
Passing end straight through cost the final day of every fetch. Over a year that is nearly invisible: a 2024 backtest cached 251 bars, the number went into the project’s acceptance evidence, and nobody noticed that 2024 had 252 trading days. Over a one-day window it returns nothing at all, so the provider raised — which is what made every strategy record an error decision on the daemon’s first real run, with 400 days of perfectly good bars already in the cache.
- Parameters:
symbol (str)
start (date)
end (date)
interval (str)
- Return type:
list[Bar]