Fixed Commission Amount
is there a way to set the commission per movement to a fixed amount?
E.g. My broker charges 10€ for orders of less of 10k€ and 20€ for larger ones.
I did not manage to implement this after reading the documentation.
run-out last edited by
There's a good example here. Fixed Income Scheme
A class is created as follows:
class FixedCommisionScheme(bt.CommInfoBase): ''' This is a simple fixed commission scheme ''' params = ( ('commission', 5), ('stocklike', True), ('commtype', bt.CommInfoBase.COMM_FIXED), ) def _getcommission(self, size, price, pseudoexec): return self.p.commission
You could modify the _getcommission method to read something like:
def _getcommission(self, size, price, pseudoexec): if abs(size * price) < 10000: return 10 else: return 20
Once made, add this to cerebro:
#Set commissions comminfo = FixedCommisionScheme() cerebro.broker.addcommissioninfo(comminfo)
There is an entire article about this: https://www.backtrader.com/blog/posts/2015-11-20-commission-schemes-subclassing/commission-schemes-subclassing/
Thank you guys super helpful!