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/

    optstrategy trouble with Unix timestamps

    Indicators/Strategies/Analyzers
    2
    5
    35
    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
      adenosine last edited by

      My dataset's datetime-stamp is formatted in Unix float notation. I've divided the datetime-stamp by 1000 so it can be passed with GenericCSVData no problem in a normal addstrategy backtest with the parameter dtformat=2. However, when trying to optimize with optstrategy, I get an error: AttributeError: Can't pickle local object 'GenericCSVData.start.<locals>.<lambda>'

      I assume the dtformat=2 parameter I've set is the lambda function so I've just manually converted the Unix datetime-stamps into the %Y-%m-%d %H:%M:%S format and removed the dtformat=2 parameter. However, I then get another error that my format is still incorrect:

      ValueError: time data '20/09/01 02:00:00' does not match format '%Y-%m-%d %H:%M:%S'

      Is there something I'm missing here?

      A 1 Reply Last reply Reply Quote 0
      • A
        ab_trader @adenosine last edited by

        @adenosine
        your date-time format is more %y/%m/%d %H:%M:%S rather than %Y-%m-%d %H:%M:%S. or %d/%m/%y %H:%M:%S since it is not clear where the year is shown.

        A 1 Reply Last reply Reply Quote 2
        • A
          adenosine @ab_trader last edited by

          @ab_trader I took another stab and tried making the year more clear and get the same error.

          2032e4a2-304a-41d6-b658-342de7a946cc-image.png

          Is there a difference between %y and %Y?

          A 1 Reply Last reply Reply Quote 0
          • A
            ab_trader @adenosine last edited by

            @adenosine said in optstrategy trouble with Unix timestamps:

            Is there a difference between %y and %Y?

            Sure, there is a difference. google, what is python date time string format

            Also you separate the numbers by /, but in the format description you use -. This can affect it as well.

            A 1 Reply Last reply Reply Quote 2
            • A
              adenosine @ab_trader last edited by

              @ab_trader You were right. It was the - that was throwing it off . Thank you.

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