如何将backtrader csv 阅读器转换为backtrader 数据馈送?我试过了:
尝试 1:(用 GenericCSV 替换数据馈送)
all_data=bt.feeds.GenericCSVData(
#my csv params here
)
for s, df in all_data.items(): #THIS LINE READS IN CSV AND ERRORS
#do stuff
“Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst”对象没有属性“项目”
尝试 2:(将 GenericCSV 转换为 Datafeed)
all_data=bt.feeds.GenericCSVData(
#my csv params here
)
all_datafeed = bt.feeds.PandasData(dataname=all_data)
错误:“Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst”对象没有属性“列”
尝试 3:(读取 csv 并转换为数据馈送)
df=pd.read_csv('/home/abc/EUR_USD.csv',header=0,parse_dates=True)
all_datafeed = bt.feeds.PandasData(dataname=df)
for df in all_datafeed.items():
print(df)
“Lines_LineSeries_DataSeries_OHLC_OHLCDateTime_Abst”对象没有属性“项目”
来自csv的摘录:
time,oask,hask,lask,cask,obid,hbid,lbid,cbid,volume
2002-05-06 20:00:00 UTC,0.9184,0.9184,0.9181,0.9184,0.9181,0.9181,0.9181,0.9181,1
2002-05-07 20:00:00 UTC,0.9155,0.9155,0.9152,0.9155,0.9152,0.9152,0.9152,0.9152,1
2002-05-08 20:00:00 UTC,0.9045,0.9045,0.9042,0.9045,0.9042,0.9042,0.9042,0.9042,1