Hi,
I want to run a code that has even position sizing up to a maximum of 1.5%.
The code I tried running was
def my_weights(context):
num_secs = (len(short_secs) + len(long_secs))
if 1/num_secs < 0.015:
weight = (1/num_secs)
else:
weight = 0.015
long_weight = 0.015
short_weight = -0.015
and then calling it using:
order_target_percent(security, context.long_weight)
But I keep getting an error. How do I get this to work?
Thanks,
Chris