The following is my attempt to make a custom position sizer based on ATR and the multiplier for the given future. I'm sure this is relatively easy but I seem to have hit a wall.
I seem to have a position size of 0 for every trade.
What am I getting wrong?
class comm_sizer(bt.Sizer): def __init__(self, atr): #self.atr_parameter= atr_parameter atr= self.atr risk_per_trade=5000 atr_risk_per_trade=5 sizing = math.floor((risk_per_trade/(mult*atr_risk_per_trade*atr))) # position = self.broker.getposition(data) def _getsizing(self,comminfo,cash,data,isbuy): return sizing