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

Error when Reading in Custom CSV Data



  • data = btfeeds.GenericCSVData(dataname='Data/ES_15min.csv',
    time=1,
    open=2,
    high=3,
    low=4,
    close=5,
    volume=-1,
    openinterest=-1,
    dtformat='%m-%d-%Y %H%M')

    This code gives me the following error: "re.error: redefinition of group name 'H' as group 6; was group 4 at position 133"
    I cannot figure this out. Anyone else seen this?



  • Full Error code:
    d9916230-fa95-45f6-a502-ebcc9b890283-image.png



  • Here is my data: 9ee10cf2-e77a-4dc6-96ca-dde5650b7305-image.png
    Loading in data:

        data = btfeeds.GenericCSVData(dataname='Data/ES_15min.csv',
                                      name='ES',
                                      fromdate=dt(2019, 1, 1),
                                      todate=dt(2019, 12, 31),
                                      time=1,
                                      open=2, 
                                      high=3,
                                      low=4,
                                      close=5,
                                      volume=-1,
                                      openinterest=-1,
                                      dtformat=('%m-%d-%Y %H:%M'),
                                      tmformat=('%H:%M'))
    


  • Hello.

    I think you should specify the datetime param:

    data = btfeeds.GenericCSVData(dataname='Data/ES_15min.csv',
                                  name='ES',
                                  fromdate=dt(2019, 1, 1),
                                  todate=dt(2019, 12, 31),
                                  datetime=0,
                                  time=1,
                                  open=2, 
                                  high=3,
                                  low=4,
                                  close=5,
                                  volume=-1,
                                  openinterest=-1,
                                  dtformat=('%m-%d-%Y %H:%M'),
                                  tmformat=('%H:%M'))
    

    Read more here:

    • dataname (None)

    • name ()

    • compression (1)

    • timeframe (5)

    • fromdate (None)

    • todate (None)

    • sessionstart (None)

    • sessionend (None)

    • filters ([])

    • tz (None)

    • tzinput (None)

    • qcheck (0.0)

    • calendar (None)

    • headers (True)

    • separator (,)

    • nullvalue (nan)

    • dtformat (%Y-%m-%d %H:%M:%S)

    • tmformat (%H:%M:%S)

    • datetime (0)

    • time (-1)

    • open (1)

    • high (2)

    • low (3)

    • close (4)

    • volume (5)

    • openinterest (6)

    and here: https://www.backtrader.com/docu/dataautoref/



  • @Parth-Patel said in Error when Reading in Custom CSV Data:

    data = btfeeds.GenericCSVData(dataname='Data/ES_15min.csv',
    name='ES',
    fromdate=dt(2019, 1, 1),
    todate=dt(2019, 12, 31),
    time=1,
    open=2,
    high=3,
    low=4,
    close=5,
    volume=-1,
    openinterest=-1,
    dtformat=('%m-%d-%Y %H:%M'),
    tmformat=('%H:%M'))

    The problem is that you've specified the time format for both date and time columns

    According to your data format, the date and time columns are separate, so the format of the date column should be '%m-%d-%Y' and the format of the time column should be '%H:%M'

    (No need to specify datetime=0 - it is a default )

    So the code may look like:

    data = btfeeds.GenericCSVData(dataname='Data/ES_15min.csv',
                                      name='ES',
                                      fromdate=dt(2019, 1, 1),
                                      todate=dt(2019, 12, 31),
                                      time=1,
                                      open=2, 
                                      high=3,
                                      low=4,
                                      close=5,
                                      volume=-1,
                                      openinterest=-1,
                                      dtformat='%m-%d-%Y',
                                      tmformat='%H:%M')
    


  • @vladisld I tried that already but then get the following error.
    3a6f881a-1235-4b4a-99f4-4c509fed1e7b-image.png



  • @Yaroslav-Horyslavets I tried that as well but no luck



  • please try:

    dtformat='%m/%d/%Y'
    


  • @vladisld -_- wow I'm an idiot thank you


Log in to reply
 

});