Backtrader Community

    • 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/

    run Backtest script from other script with os.system('Backtest.py') doesn't work

    General Discussion
    1
    1
    117
    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.
    • C
      chhrissi2909 last edited by

      Hello,

      I wrote a Backtest.py script. In this script I start to initialize some variables, than there are 7 classes and in the end I run the cerebro when:

      if __name__ == '__main__':
          cerebro = bt.Cerebro()
          ...
          ...
      

      If I run the script manually, the backtest works perfectly and I get exactly the results I want.
      But if I want to run this script from another Script like this:

      import os
      import Backtest
      os.system('Backtest.py')
      

      for this I put all the scripts in one folder and imported each script in the Runner Script. Each script works perfectly, only the Backtest.py script gives the error message

      sh: Backtest.py: command not found
      

      I also have to mention that the other scripts (which work and can also be executed by the runner script via os.system ) all contain no classes and no "if name == 'main':".

      Does anybody know why this backtest.py script is not found and how I can solve this problem?

      best regards
      Christian

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors