Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Long & Short Return Miss Match

Hello Everyone:
All along, I thought the total return of a long & short portfolio should be the return of the long side plus the short side. However, it does not always seem to be the case. For example, the sample program from: https://www.quantopian.com/lectures/example-long-short-equity-algorithm would produce an unanticipated miss match.
Testing between 2015/01/05 ~ 2017/12/29, with total capital of $1000000, the total return of long only of this program is about 18.6%, and the short only is 7.46%. However the total return of the combined long & short is 12.79% instead of 11.14%. If we repeat the same test over a 10-year period, the total return of long & short will be deviating much further apart from what it should be. Does anyone have any ideas as for why it happens this way? Or, is this a bug / known issue?

I switch the program into long or short only mode by commenting out the following lines accordingly.

# Filter to select securities to short.  
shorts = percent_difference.top(300)

# Filter to select securities to long.  
longs = percent_difference.bottom(100)

Thanks,

6 responses

Are you changing the constraints?

DollarNeutral() is going to make the basket of stocks dollar neutral, making the strategy completely different if all you've done is comment out longs or shorts in the pipeline.

I thought about that too. I will take a second look at it again from the constraints' perspective. Thanks for your comments...

Depending on the constraints you're using, there's no way to split them up cleanly. For example, any constraint that balances beta or risk exposure will adjust weights depending on what is on the other side. Remove the other side and the equation has changed.

You can run a tearsheet with round_trips = True on your long-short algo to see the separate returns attribution of the long and short side.

Actually I take that back. You can return the optimized weights for your long-short portfolio using calculate_optimal_portfolio, then take those weights and only order the long or short half.

Here is my way of doing it at this point. I think it's same as what you suggested here... thanks,

#long short net dollar exposure <= 10%
context.long_weight = 0.5
context.short_weight = -0.45

context.target_weights = context.short_weight or context.short_long / total number of securities

context.MAX_GROSS_EXPOSURE = 1.0

max_position_concentration = opt.PositionConcentration.with_equal_bounds(
-context.MAX_POSITION_CONCENTRATION,
context.MAX_POSITION_CONCENTRATION
)

order_optimal_portfolio(
objective=opt.TargetWeights(context.target_weights),
constraints = [ max_gross_exposure,
max_position_concentration,
]
)

I use the following settings to achieve dollar_neutral
context.long_weight = 0.5
context.short_weight = -0.5