For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
back testing 1 minute data from yahoo finance
-
from datetime import datetime
import backtrader as btclass SmaCross(bt.SignalStrategy):
def init(self):
sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
crossover = bt.ind.CrossOver(sma1, sma2)
self.signal_add(bt.SIGNAL_LONG, crossover)cerebro = bt.Cerebro()
cerebro.addstrategy(SmaCross)data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),
todate=datetime(2012, 12, 31))
cerebro.adddata(data0)cerebro.run()
cerebro.plot()Question : It works but i want to be able to change the time frame to 1 min, 5 min, 15 min and 1 hour etc. how can i do it ?
-
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
-
The implemented feed does only download days or larger timeframes.