feat: phase 1 — data downloader, backtrader runner, SMA strategy

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Yuxuan Yan
2026-06-07 09:21:16 +08:00
parent 338c912029
commit fd86190e9a
19 changed files with 456 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
"""Convert pandas DataFrames to backtrader data feeds."""
import backtrader as bt
import pandas as pd
def df_to_bt_feed(df: pd.DataFrame) -> bt.feeds.PandasData:
"""Convert a standardized OHLCV DataFrame to a backtrader PandasData feed."""
df = df.copy()
df["date"] = pd.to_datetime(df["date"])
df = df.set_index("date")
df = df[["open", "high", "low", "close", "volume"]]
return bt.feeds.PandasData(dataname=df)