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

    Indicators/Strategies/Analyzers
    2
    2
    211
    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.
    • tianjixuetu
      tianjixuetu last edited by

      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))
      
      1 Reply Last reply Reply Quote 1
      • Matheus Pires
        Matheus Pires last edited by

        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!

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }