Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. anas laamrani 0
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 1
    • Groups 0

    anas laamrani 0

    @anas laamrani 0

    1
    Reputation
    7
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    anas laamrani 0 Unfollow Follow

    Best posts made by anas laamrani 0

    • RE: Different commissions for each order type

      @balibou thank you for your reply, I think exectype == 'Close' refers to the "close price" rather than close operation.
      I've made a simple solution:

      commissions = []
      
      class CommInfo_My(bt.CommInfoBase):
          global commissions
      
          def _getcommission(self, size, price, pseudoexec):
              if commissions:
                  comm = commissions[0] * size * price
      
              if not pseudoexec:
                  commissions.pop(0)
      
              return comm
      
      def next(self):
          if condition1:
              commissions.append(0.0045)
              self.buy()
          elif condition2:
              commissions.append(0.009)
              self.close()
      
      cerebro.broker.addcommissioninfo(strategyDraft.CommInfo_My())
      
      posted in Indicators/Strategies/Analyzers
      A
      anas laamrani 0

    Latest posts made by anas laamrani 0

    • RE: Different commissions for each order type

      @balibou thank you for your reply, I think exectype == 'Close' refers to the "close price" rather than close operation.
      I've made a simple solution:

      commissions = []
      
      class CommInfo_My(bt.CommInfoBase):
          global commissions
      
          def _getcommission(self, size, price, pseudoexec):
              if commissions:
                  comm = commissions[0] * size * price
      
              if not pseudoexec:
                  commissions.pop(0)
      
              return comm
      
      def next(self):
          if condition1:
              commissions.append(0.0045)
              self.buy()
          elif condition2:
              commissions.append(0.009)
              self.close()
      
      cerebro.broker.addcommissioninfo(strategyDraft.CommInfo_My())
      
      posted in Indicators/Strategies/Analyzers
      A
      anas laamrani 0
    • Different commissions for each order type

      I would like to set different commissions depending on the order type, if it is buy/sell operations, it should charges a percentage comm = X, and if it is a close operation, it should charge double: 2X.

      def next(self):
          if condition1:
              self.broker.setcommission(0.0045)
              self.buy()
          elif condition2:
              self.broker.setcommission(0.009)
              self.close()
      

      Is there any way through commission scheme or other method to do this?
      Thank you in advance.

      posted in Indicators/Strategies/Analyzers
      A
      anas laamrani 0