Backtrader Community

    • 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 use two CommissionInfo inside a strategy?

    Indicators/Strategies/Analyzers
    3
    4
    426
    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.
    • S
      soulmachine last edited by

      Some exchanges have different maker fee and taker fee, for example, BitMEX BTC taker fee is 0.075% and maker fee is -0.025%, I can add two CommissionInfo with the following code:

      cerebro.broker.addcommissioninfo(CommissionInfoFractional(commission=0.0075), name='taker')
      cerebro.broker.addcommissioninfo(CommissionInfoFractional(commission=-0.0025), name='maker')
      

      And in my strategy class I can retrieve them back:

      taker_comm = self.broker.comminfo['taker']
      maker_comm = self.broker.comminfo['maker']
      
      print(taker_comm.params.commission)
      print(maker_comm.params.commission)
      

      How can I use the two ComissionInfo instances in self.buy() and self.sell()? Thanks!

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

        I believe using name in this way means the name of the dataline. You should look at creating a custom commission scheme.

        RunBacktest.com

        1 Reply Last reply Reply Quote 0
        • S
          soulmachine last edited by

          @run-out You're right, the strategy retrieves the CommissionInfo instance at this line https://github.com/mementum/backtrader/blob/master/backtrader/strategy.py#L1315 :

          comminfo = self.broker.getcommissioninfo(data)
          

          So it uses the data name.

          Since data has only one name, so it's not possible to apply multiple commission fees?

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

            @soulmachine said in How to use two CommissionInfo inside a strategy?:

            Since data has only one name, so it's not possible to apply multiple commission fees?

            You're probably right. AFAIK a single commission could be specified per data name or default. As @run-out correctly mentioned - you may develop your custom commission scheme.

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