fix(backtest): squeeze yfinance Close series to avoid DataFrame iteration error
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
727ad7cd6d
commit
fb86443987
@ -35,8 +35,12 @@ def _fetch_prices(ticker: str, start: datetime, end: datetime) -> dict[str, floa
|
||||
if data.empty:
|
||||
return cached
|
||||
|
||||
close_series = data["Close"]
|
||||
if hasattr(close_series, "squeeze"):
|
||||
close_series = close_series.squeeze()
|
||||
|
||||
fetched: dict[str, float] = {}
|
||||
for ts, close_val in data["Close"].items():
|
||||
for ts, close_val in close_series.items():
|
||||
date_key = ts.to_pydatetime().replace(tzinfo=None).strftime("%Y-%m-%d")
|
||||
fetched[date_key] = float(close_val)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user