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/

    Importing orders #219

    General Code/Help
    1
    2
    784
    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.
    • B
      backtrader administrators last edited by

      From #219


      Hello,
      Is there a way to import orders from an array? I have them in an array that looks like [0,0,1,0,0,-1,-1...], length of this array is the same as the length of the data(one signal for each timeframe).

      This is for backtesting only, the calculations are done outside of the testing script.

      Or simpler, signals are saved in a csv with lines like this

      2016-01-09;100200;-1
      2016-01-09;110200;1
      

      etc

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        As explained above order importing is not a feature of the the platform.

        If you have the data in that format:

        ....
        2016-01-09;100200;-1
        2016-01-10;110200;1
        ...
        

        there are several approaches:

        • Make a custom data feed with it containing only 2 fields

          • datetime
          • trigger (or any other name you wish)

          In this case you would add the data feed to the system and could at each moment in time and synchronized with the data read if an order has to be executed or not

        • Read that input with something like a pandas.read_csv module and during each call to next in the strategy, look for the corresponding datetime index in the dataframe to see if an order has to be executed or not.

        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(); }); }