For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Backtesting 1 minute data

  • Hello - I've been able to successfully backtest 1 day and 1 hour data and for some reason when I try to backtest on 1 minute data no trades get executed when the backtest completes. I'm loading the appropriate CSV file with GenericCSVData for each test and not using the resampling feature provided by BackTrader. I'm assuming this should theoretically work for 1 min or 5 min.. The data looks like the following:

    1 hour
    2017-01-27 00:00:00+00:00,1.07246,1.06928,1.06791,1.06576,107892.0

    1 min
    2017-01-27 22:59:00+00:00,1.06954,1.06928,1.06948,1.0691,10.0

    and the dtformat is set as:
    dtformat=('%Y-%m-%d %H:%M:%S+00:00')

    Any suggestions?


  • administrators

    The platform executes trades even with isolated ticks. Unfortunately the information provided above is insufficient to say why you may not be executing.

    Long shot: you should always tell the platform which timeframe and compression the data feed has by specifying both during data feed creation.

  • Thanks, it working now on 1 min data - BackTrader is simply awesome!

  • @Z03 can you please post one example how use intraday timeframes? thx

  • administrators

    Without knowing what you may be looking for, using intraday timeframes is not different from daily timeframes. In the question above, the problem is that the creation of the data feed was not specifying the timeframe and compression parameters. As such the platform uses the defaults (timeframe=bt.TimeFrame.Days)

    See this Blog - Timers post. The intraday script uses de 5-minutes data sample available in the sources.

    An excerpt where the parameters are specified

        # Data feed kwargs
        kwargs = dict(
            sessionstart=datetime.time(9, 0),
            sessionend=datetime.time(17, 30),

Log in to reply

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.