@chrix I solved it like this

class ValuePercentSizer(bt.Sizer): params = ( ('percents', 20), ('retint', True),# return an int size or rather the float value ) def __init__(self): pass def _getsizing(self, comminfo, cash, data, isbuy): position = self.broker.getposition(data) accvalue = self.broker.getvalue() if not position: size = accvalue / data.close[0] * (self.params.percents / 100) else: size = position.size if self.p.retint: size = int(size) return size