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/

    Daily return (P&L) of total broker value

    General Code/Help
    2
    3
    1209
    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.
    • J
      jf last edited by

      Dear Backtrader community,

      I replicated the quickstart example with the SMA indicator (chapter: "adding an indicator"), and it works perfectly. Backtrader is awesome, so thanks to everybody who contributed to this project and the great documentation!

      I would now like to better understand the return characteristics of the strategy, and would therefore like to access the daily returns ("PnL") of the strategy (=total broker value of active positions and cash combined). The final idea would be to plot a histogram of the daily returns of the strategy and compare it with the returns of just "buy-and-hold"-ing the asset, similar to this plot: http://www.cboe.com/publish/histogram-charts/1012-BFLY.png

      So far I could only find the absolute value of the broker (using "broker.getvalue()") but not the daily returns (= daily percentage change of the absolute value).

      Could anybody indicate where the returns are stored/how I can access them? I couldn't find that in the documentation nor the forum...

      Your help would be highly appreciated!

      Thanks,
      jf

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

        You have to plug in an analyzer.

        • Docs - Analyzers
        • Docs - Analyzer Reference

        You probably want to read this post:

        • Blog - Analyzers: Benchmarking
        1 Reply Last reply Reply Quote 0
        • J
          jf last edited by

          ok great, thanks!

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