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 set commission with condition by order?

    General Code/Help
    3
    4
    342
    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.
    • G
      G_will last edited by

      In some futures exchange, If you close a position that you open it today, the commission is higher than normal.

      So in this situation how to set commission ?

      and I have read https://www.backtrader.com/docu/user-defined-commissions/commission-schemes-subclassing.html

      but the def _getcommission(self, size, price, pseudoexec): method do not have order or trade argument pass in, can not determine the commission's order is open or is close, and close for which order.

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

        I wouldn't even bother and set max commission for all trades.
        If the system fails, then it is not stable enough for real trading.

        • 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
        • G
          G_will last edited by

          but the trade fee of close a today position is quite high. it is the open position fee's 2000%.

          If I set the max commission for all trades. It's too far from the real trading.

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

            Create a commission derived scheme which takes the corresponding data feed as an extra parameter. Use the data feed when called to get a timestamp.

            tstamp = self.data.datetime.datetime()
            
            1 Reply Last reply Reply Quote 1
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors