Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
556 views
in Technique[技术] by (71.8m points)

backtrader - Unconverted data remains in python

date                         open   high    low     close    volume
2020-10-01 09:15:00+05:30   2510    2524    2507    2513.15 231516
2020-10-01 09:20:00+05:30   2514.85 2517.95 2495.9  2502.6  122766
2020-10-01 09:25:00+05:30   2502.1  2504.85 2497    2503.95 132321
2020-10-01 09:30:00+05:30   2502.9  2504    2496    2499.05 45690
2020-10-01 09:35:00+05:30   2498.4  2503    2495.7  2500.05 53982
2020-10-01 09:40:00+05:30   2500.9  2509.8  2497.3  2507.5  61781
2020-10-01 09:45:00+05:30   2507.5  2511.95 2503.7  2504.95 60255
2020-10-01 09:50:00+05:30   2504.95 2507.2  2500    2502.4  39571

I have data like above, i managed to parse hours, minutes and seconds information. but i couldn't remove the time zone. This information i feed to Cerebro csv feed.

data_ = bt.feeds.GenericCSVData(
dataname='tcs2.csv',
fromdate=datetime.datetime(2020, 10, 1),
todate=datetime.datetime(2021, 1, 5),
nullvalue=0.0,
dtformat=('%Y-%m-%d %H:%M:%S'),
datetime=0,
open = 1,
high = 2,
low = 3,
close = 4,
volume =5, 
openinterest=-1,
reverse=False)



cerebro = bt.Cerebro()
cerebro.broker.set_cash(100000)
cerebro.broker.setcommission(commission=0.001)

cerebro.adddata(data_)
cerebro.addstrategy(macdStrategy)


print('Starting Portfolio Value : %0.2f' % cerebro.broker.getvalue())
cerebro.run()
cerebro.plot()

print('Final Portfolio Value : %0.2f' % cerebro.broker.getvalue())

But after running this code i am getting below error, can any suggest how to remove this timezone issue.

ValueError: unconverted data remains: +05:30
question from:https://stackoverflow.com/questions/65838018/unconverted-data-remains-in-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...