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/

    How do I access the observer lines after the engine has been run?

    General Code/Help
    3
    4
    280
    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.
    • Allen Mauer
      Allen Mauer last edited by

      It seems like the data must be stored in the engine. It can produce a plot after the engine has been run. Otherwise, the value line is only calculated and stored in memory for the plot. Can anyone help me find the broker value over time by extracting it from the engine object?

      1 Reply Last reply Reply Quote 1
      • vladisld
        vladisld last edited by

        Similar question was answered here: https://community.backtrader.com/topic/2458/getting-a-calculated-value-from-strateg

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

          You can access the analyzers as dictionaries from the strategy object returned by Cerebro. So for example, if you have:

          # Add an analyzer to cerebro.
          cerebro.addanalyzer(bt.analyzers.DrawDown, _name="drawdown")
          
          # Then run cerebro
          strat = cerebro.run()
          
          # Retrieve a dictionary as follows: 
          my_drawdown = results[0].analyzers.getbyname("drawdown").get_analysis()
          
          

          You can apply this technique to any analyzer you implement.

          RunBacktest.com

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

            Sorry, typo.... strat should be results...

            # Add an analyzer to cerebro.
            cerebro.addanalyzer(bt.analyzers.DrawDown, _name="drawdown")
            
            # Then run cerebro
            results = cerebro.run()
            
            # Retrieve a dictionary as follows: 
            my_drawdown = results[0].analyzers.getbyname("drawdown").get_analysis()
            

            RunBacktest.com

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