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/

    what happen if 400csv files optstrat in one code?

    General Discussion
    3
    3
    33
    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.
    • A
      Adam-Kim last edited by

      (My english is poor. Sorry.)

      My code below:

      for datapath in file_list:
          ....
          strats = cerebro.optstrategy(FatherStrategy, output_log_path = None, \
               buytime_log_path = LOG_PATH + 'buytime{}.log'.format(prefix), \
               min5_multiplier=[3.5], min299_multiplier=4.5, ....)
      
          dataframe = pd.read_csv(datapath, parse_dates=True, index_col=0, ...)
          dataframe["Datetime"] = pd.to_datetime(dataframe["Datetime"])   
          data = bt.feeds.PandasData(dataname=dataframe, timeframe=bt.TimeFrame.Ticks)
          
          cerebro.adddata(data)
          cerebro.run()
      

      When I excute my code, after 300csv files, error occured.

      Error code below:

      pandas... C memory error.
      

      What would be problem here?
      I think something related to optstrategy but I don't get it.

      Appreciate your help.

      A 1 Reply Last reply Reply Quote 0
      • A
        ab_trader @Adam-Kim last edited by

        @adam-kim

        it looks like pandas error raised while reading csv files, not bt issue. Google it.

        Next time postvtge whole error message, which typically shows what line of the script causes the error.

        1 Reply Last reply Reply Quote 1
        • run-out
          run-out last edited by

          I just noticed you are using tick data. Tick data can be huge and you might just be running out of memory. Try running in smaller batches, shorter dates (filter in pandas before loading to backtrader), or resample to a higher timeframe.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }