Something to play with.
Something to play with.
Here's a longer run (back to the earliest date possible), with a slight change in the code to:
if v_z_diff[-1] < -6.5*v_z_diff[0:-1].std():
order_target_percent(context.qqq,-2.5)
elif v_z_diff[-1] > 6.5*v_z_diff[0:-1].std():
order_target_percent(context.qqq,2.5)
else:
order_target_percent(context.qqq,0)
instead of
f v_z_diff[-1] < -6*v_z_diff[0:-1].std():
order_target_percent(context.qqq,-3)
elif v_z_diff[-1] > 6*v_z_diff[0:-1].std():
order_target_percent(context.qqq,3)
else:
order_target_percent(context.qqq,0)
@Daniel, feel free to clone the algo and play around with it. To change the leverage conveniently, something like this could be done:
context.leverage = 1
if v_z_diff[-1] < -6.5*v_z_diff[0:-1].std():
order_target_percent(context.qqq,-context.leverage)
elif v_z_diff[-1] > 6.5*v_z_diff[0:-1].std():
order_target_percent(context.qqq,context.leverage)
else:
order_target_percent(context.qqq,0)
Here's a research notebook that seems to highlight that TQQQ & SQQQ (+/- 3X QQQ ETFs, respectively) are sometimes somehow "out of whack" at market open, and then settle down. Just a murky observation at this point.