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 to get the current value for the fund, not just in notify fcn?

    Indicators/Strategies/Analyzers
    2
    5
    1361
    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
      Bingchen Liu last edited by

      In my backtesting program, I wanted to change cash when trading. Thus I added some code in notify_fund() to change cash. The problem is that I want to define a get_value() function which can get the current value of the fund (which is the value variable in the notify_fund() function). However, I don't know where I can find or get the value. Please give me some suggestions and thanks a lot.

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

        See: Docs - Broker -> get_fundvalue

        1 Reply Last reply Reply Quote 0
        • B
          Bingchen Liu last edited by

          Thank you for your quick reply. cerebro.broker.get_fundvalue() can give me the value. But the problem is that I want to get the value in the next() for Strategy class. Thus get_fundvalue is not available.

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

            The broker is available in the strategy. See Docs - Strategy - Member Attributes

            1 Reply Last reply Reply Quote 0
            • B
              Bingchen Liu last edited by

              Got it, thank you !

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