Comparing position-sizing algorithms
Let's take an example to further illustrate the principle. Let's use the exact same signals and starting capital. Then, let's use various position-sizing algorithms. Let's compute the equity curve for each position-sizing algorithm. The objective is to see how much position sizing impacts returns.
For demonstration purposes, we will recycle our go-to Softbank in absolute with Turtle for dummies, along with our regime_breakout()
function from Chapter 5, Regime Definition. Once again, please do not do this at home, as it is too simplistic to be deployed in a professional investment product:
def regime_breakout(df,_h,_l,window):
hl = np.where(df[_h] == df[_h].rolling(window).max(),1,
np.where(df[_l] == df[_l].rolling(window).min(), -1,np.nan))
roll_hl = pd.Series(index= df.index, data= hl).fillna(method= 'ffill')
return roll_hl
def turtle_trader(df, _h, _l, slow...