For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Extending Commissions

  • administrators

    Use the link below to go the original post

    Click here to see the full blog post

  • How can I use it to trade a portfolio of futures? Every contract has a different multiplier and different margin. So multiplier and margin should be linked to data rather than broker. Or is there another way to do it?

  • Commissions can be added to bt with relation to data feed names:

    for index, contract in FUT_SPECS.iterrows():
        data = <add data feed with the name=contract['name']>

    FUT_SPECS pandas data frame has comm, margin, mult and name columns.

  • administrators

    As indicated by @ab_trader in his/her snippet, the key is the name that you assign to the data feed and which helps you link a given set of details for a commission scheme to that data feed.

    In the snippet, the commission scheme is added directly with setcommission, but you can also create your own instances of CommissionInfo and use addcommissioninfo. See: Docs - Broker

  • That's very helpful. Thank you @ab_trader and @backtrader

Log in to reply