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/

    which one is the final return?

    General Code/Help
    2
    6
    210
    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
      jeff lee last edited by jeff lee

      I have writed a test strategy , use the AllInSizer, and print the return with :

      def stop(self):
            self.log('Ending Value %.2f, CASH  %.2f' %
                     (self.broker.getvalue(), self.broker.getcash()))
      

      I got,

      2019-08-15, Ending Value 99468.98, CASH  199832.09
      

      so , which one is the true return? 99468.98 or 199832.09?
      I use AllInSizer. I guess they should be the same.

      thanks

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by ab_trader

        Both numbers are not returns. cash is amount of money on the broker's account, value is cash available plus cost of all open positions.

        Return is equal to value minus starting capital.

        I guess they should be the same.

        If all positions are closed than, yes, value and cash should be the same. In your case it looks like you have short position still open.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        J 1 Reply Last reply Reply Quote 0
        • J
          jeff lee @ab_trader last edited by

          @ab_trader

          so how to get the final value?
          get the dataframe length ,close all at the -1 day?

          A 1 Reply Last reply Reply Quote 0
          • A
            ab_trader @jeff lee last edited by ab_trader

            @jeff-lee

            Not sure what do you want to get. Final value of the broker account is already calculated above; if you need the return, than subtract starting capital.

            If you want to close positions, than close them on the last day, I don't see how this will affect your value.

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 0
            • J
              jeff lee last edited by

              @ab_trader said in which one is the final return?:

              value is cash available plus cost of all open positions.

              "value is cash available plus cost of all open positions."

              so , the final value is = cash + long pisiton value - short position value ?
              and the return is: the final value - init cash?

              A 1 Reply Last reply Reply Quote 0
              • A
                ab_trader @jeff lee last edited by

                @jeff-lee that's what I wrote.

                • If my answer helped, hit reputation up arrow at lower right corner of the post.
                • Python Debugging With Pdb
                • New to python and bt - check this out
                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors