How do I customize my own Sizer and calculate the size for the long or short position ?
I backtest my own strategy, and customize my own sizer like following:
class MySizer(bt.Sizer): def _getsizing(self, comminfo, cash, data, isbuy): size = cash*0.96/data.close return size
the above is for the long position, but how do I customize the short position ? maybe for the using the leverage . Thanks .
the above is for the long position, but how do I customize the short position ?
By checking the parameter
isbuywhich tells you if the sizing operation is for a
buyorder. Else it will be a