Hey all,
Hope someone can help me with this. From my understanding, order_target_percent adjust a position to a target percent of the current portfolio value. If such position does not exists, we enter the position instead. Easy!
So what is the different between the followings:
def handle_data(context, data):
if ( context.n == 0 ):
context.n = 1
order_target_percent( context.asset, 1.0 )
and:
def handle_data(context, data):
order_target_percent( context.asset, 1.0 )
Both yield slightly different result during backtest, like return of -78.7% for the first one vs -78.29%. I would have thought that both version should do the same thing.
What get worst is comparing the short version :
def handle_data(context, data):
if ( context.n == 0 ):
context.n = 1
order_target_percent( context.asset, -1.0 )
to this:
def handle_data(context, data):
order_target_percent( context.asset, -1.0 )
From backtest, the first one yield a return of 78.02% but the second one yield as much as 215.85%!! See backtest!