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/

    Optimizing in the background while running live or backtesting

    General Code/Help
    1
    1
    18
    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.
    • P
      paisan last edited by

      I have tried a few different ways, but they have all run into a wall. Is this possible in some way?

      When running a backtest I would like to have an optimizer run when a trade ends or at a certain time, let's say every 30 minutes.

      I did not mess with the regular runstrategy() that starts the strategy. I made a new optimize_strategy() that has the optstrategy that I try to run while the regular backtesting is on, but when I start it I get this:

      AssertionError: daemonic processes are not allowed to have children
      

      I made a sleep() test to see if the problem came from the initial runstrategy()

      def optimize_strategy():
          print('Before sleep')
          time.sleep(10)
          print('After sleep')
      

      when started from notify_trade() it pauses like it should

          def notify_trade(self, trade):
              if trade.isclosed:
                  optimize_strategy()
      

      So, what I would like is the following:

      1. In backtesting, run a separate optstrategy when I choose and have the regular code pause when it runs.
      2. In live, run a separate optstrategy in the background when I choose and without interrupting the regular code.

      Is it possible?

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