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

Best practice for date range for Emini Backtest

  • I would like to get some best practice guidance on doing backtest on Emini futures. If there is a pointer to an existing thread and if you could point that would be grateful.

    Currently using historical data from IB for my backtest, hence using data0 as ES-FUT-GLOBEX-USD-201903 for the March Emini futures. Using fromdate as 2018-12-13 todate as 2019-03-13. This works fine.

    When I run this on 2018 June futures and use the following params
    --data0 ES-FUT-GLOBEX-USD-201806 --fromdate 2018-03-13 --todate 2018-06-14 I get the following error:

    File "C:\ProgramData\Anaconda3\lib\site-packages\backtrader\indicators\", line 364, in once
    dst[i] = math.fsum(src[i - period + 1:i + 1]) / period
    IndexError: array assignment index out of range

    So is this a data provider issue and if there is a best practice to do symbols which have rollover constraints.

    Thanks for your time.

  • administrators

    What you are actually executing: unknown!

    It simply seems no data is being delivered. but it is simply a guess.

  • First thanks for the beautiful platform. Appreciate you taking the time to answer almost every thread in the forum. Much respect.

    Just trying to get my feet wet in this platform and coded a simple crossover strategy. I think there is nothing wrong with the code because it runs fine for the 201903 emini historical data.

    You are absolutely right and the problem is I am not getting data for 201812 expired futures inside the backtrader framework but I am able to see the DG inside TWS so it is not a permission issue. Hence, I was wondering how people do back test for a future like emini which expires periodically. I am sure I am doing something wrong or missing a step while accessing expired future.

    I understand it is unfair to ask IB data related question here but I was trying to tap into the community. Looking for some guidance from people who have done a year long backtest on emini using IB historic data on what they supply for data0 param for rotating futures.

    Even if there is an alternate way of getting intraday historical data from somewhere else or 2 years emini data that would be helpful too.

  • Updating the thread for people facing the same problem. This is directly related to future contracts. IBPy looks for m_includedExpired to be true to dish out expire futures minutes data.

    A possible solution to circumvent this is provided by backtrader here

Log in to reply