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 commission info in a strategy,for example,mult,margin,leverage



  • Re: get_leverage() calls

    you can use this code:

    info=self.broker.getcommissioninfo(data)
    self.log(f"data._name:{data._name}")
    self.log('info: {},mult:{},margin:{},commission:{}'.format(
                            info,info.p.mult,info.p.margin,info.p.commission))
    


  • Dude, I tried to solve this problem by creating a function that receives the parameters you want, feed them to the strategy sub class, then the function returns the instance created. Example:

    def AssignStrategy(mult, margin,commission):
    
          Class MyStrategy(bt.Strategy):
    
                ## Some Code
    
          return MyStrategy
    
    

    Hope it works for you!


Log in to reply
 

});