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

Insisting "IndexError within GenericCSVData-loading



  • Hello backtrader-experts,

    half the day I spended in trying-searching-troubleshooting all docu-forum-google-entries...no change at all:
    "IndexError" within dataloading is solid as a rock, does not change a bit...any advice?

    CSV (GBPUSD, M5) has 100000 rows, for troubleshooting I have reduced to only 10
    Original with dtformat = ('%Y.%m.%d %H:%M:%S'),
    f2aca011-e45d-4b13-83ac-991e4c2e026d-grafik.png

    I have also changed to default-dtformat = ('%Y-%m-%d %H:%M:%S') with no difference
    e84cb8b6-119f-4212-9ebb-dda3160771f2-grafik.png

    GenericCSVData is loading data with following parameters

    import backtrader.feeds as btfeed
       dataLoad = btfeed.GenericCSVData(
            dataname = CSV_PATH + CSV_FILE,
            #separator = ",",
            #fromdate = datetime.datetime(2019, 1, 21),
            #fromdate = datetime.datetime(2020, 8, 8),
            #dtformat = ('%Y.%m.%d %H:%M:%S'),
            dtformat = ('%Y-%m-%d %H:%M:%S'),
            #dtformat = ('%YYYY.%mm.%dd %HH:%MM:%SS'),
            #tmformat=('%H:%M:%S'),
            datetime = 2,
            time = -1,
            timeframe = 5,
            compression = 1,
            open = 3,
            high = 4,
            low = 5,
            close = 6,
            volume = -1,
            openinterest = -1,
            nullvalue = 0.0,
            header = True)
    

    Later

    cerebro.adddata(dataLoad)
    

    What ever I try/change/add/remove, it allways keeps: "IndexError: list index out of range".
    a42df999-10c7-43b8-9008-dbef83edb10a-grafik.png

    • with 10 rows only, you can see: CSV cannot be corrupt
    • "CSV_PATH + CSV_FILE" gives correct path to file, otherwise "No such file or director" would rise
    • I have tried both dtformats..therefore

    ...I am completely helpless, what can be the error.
    Any advice?

    Doku
    https://www.backtrader.com/docu/dataautoref/#genericcsvdata
    https://www.backtrader.com/docu/datafeed/#genericcsvdata



  • Your data is backwards. Change the sort order so that oldest data points are first and newest are last.



  • Thats why! Thx so much!


Log in to reply
 

});