class FixedSize(bt.Sizer):
params = (('size', 1),)
def _getsizing(self, comminfo, cash, data, isbuy):
if isbuy:
return self.p.size
position = self.broker.getposition(data)
if not position.size:
return 0 # we don't have any shares
return position.size # we simply hold what we have