@davidavr
head "12 Apr 2021 _Raw.csv" <- this doesnt work.
so I just use texteditor to open my csv , so it goes like below
Date should be second column thus i am using "1" and i've also set the dtformat to match but it prompted the below
@davidavr
head "12 Apr 2021 _Raw.csv" <- this doesnt work.
so I just use texteditor to open my csv , so it goes like below
Date should be second column thus i am using "1" and i've also set the dtformat to match but it prompted the below
if i updated back to "%Y-%m-%d" it gives me the same error couldnt covert string to float.
@davidavr
So i printed my DF , my date column format is "%Y-%m-%d"
I also tried changing the Dtformat to "%m/%d/%Y" but it gives me the same error
As the title suggests, I am having problems loading raw csv into my code. It is giving ValueError, but I don't know why. I tried to turn my date column in numbers and it still gives me the same error
Here is my code:
if name == 'main':
cerebro = bt.Cerebro()
cerebro.addstrategy(TestStrategy)
cerebro.broker.setcommission(commission=0.001)
# Create a Data Feed
data = bt.feeds.GenericCSVData(
dataname='12 Apr 2021 _Raw.csv',
fromdate=datetime.datetime(2021, 1, 1),
todate=datetime.datetime(2021, 4, 5),
nullvalue = 0.0,
dtformat=('%Y-%m-%d'),
datetime = 1,
)
print(data)
cerebro.adddata(data)
cerebro.broker.setcash(100000.0)
print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
cerebro.run()
print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
cerebro.plot()
Any help is appreciated. Thank you so much!