Last active
April 28, 2021 23:02
-
-
Save kuznetsov-m/4c3f58964d947aa3fa9513030e294490 to your computer and use it in GitHub Desktop.
backtrader test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: test_candels.csv | |
# | |
# 274.67 274.67 274.67 274.67 123460 2021-01-04 | |
# 274.67 274.67 274.67 274.67 123460 2021-01-05 | |
# file: requirements.txt | |
# | |
# backtrader==1.9.76.123 | |
# backtrader-plotting==1.1.0 | |
import backtrader | |
from datetime import datetime | |
import matplotlib | |
import my_strategy | |
cerebro = backtrader.Cerebro() | |
cerebro.broker.set_cash(1000) | |
data = backtrader.feeds.GenericCSVData( | |
dataname='test_candels.csv', | |
separator='\t', | |
open=0, | |
close=1, | |
hight=2, | |
low=3, | |
volume=4, | |
openinterest=-1, | |
datetime=5 | |
) | |
cerebro.adddata(data) | |
print('Starting Portfolio Value: {}'.format(cerebro.broker.getvalue())) | |
cerebro.run() | |
print('Final Portfolio Value: {}'.format(cerebro.broker.getvalue())) | |
cerebro.plot() # error | |
# Exception has occurred: AttributeError | |
# 'Plot_OldSync' object has no attribute 'mpyplot' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment