Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    General Discussion
    2
    3
    2096
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      harifsingh last edited by

      Re: Backtesting 1 minute data

      from datetime import datetime
      import backtrader as bt

      class 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 ?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
        
        1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators last edited by

          The implemented feed does only download days or larger timeframes.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors