Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Hedging against factors for algos

Hey everyone,

I just ran a performance attribution tear sheet on an algo of mine and I noticed a high negative exposure to momentum. I want to improve by reducing my exposure to momentum, without introducing a significant amount of other exposures; is this possible and is it the right thing to do? I was thinking of constructing a portfolio with a high exposure to momentum, and not much other exposure, and introducing that portfolio as a hedge against my original algo. Any ideas on better ways to hedge or tips on this?

4 responses

"I want to improve by reducing my exposure to momentum, without introducing a significant amount of other exposures; is this possible and is it the right thing to do?"

If you're planning on entering the Q contest then you need to keep the abs of momentum exposure below .40. So yes, it's the right thing to do for the contest. If you're developing an algo for some other purpose than maybe it's not so important. There's some interesting discussion on this here (https://www.quantopian.com/posts/a-new-contest-is-coming-more-winners-and-a-new-scoring-system).

However, let's assume you're looking for ways to reduce momentum exposure. "Any ideas on better ways to hedge or tips on this?"

Take a look at the 'FactorExposure' constraint (https://www.quantopian.com/help#module-quantopian_optimize_constraints). Assuming you are using the 'order_optimal_portfolio' method for ordering, one could do something like this.

   # Create a pipeline factor for momentum. A good start is simply 120 day return  
    momentum = Factors.Returns(window_length = MOMENTUM_WINDOW, mask = universe)

    # Simply use that factor as an input to the FactorExposure constraint  
    momentum_constraint = opt.FactorExposure(loadings = context.output,  
                                               min_exposures = {'momentum': -MAX_ABS_EXPOSURE},  
                                               max_exposures = {'momentum': MAX_ABS_EXPOSURE}  
                                              )

    # Finally, order using this factor exposure constraint  
    order_optimal_portfolio(objective = maximize_momentum_objective,  
                                constraints = [leverage_constraint,  
                                               concentration_constraint,  
                                               momentum_constraint])

Attached is a simple algorithm which orders the highest and lowest momentum securities. There's a constant called CONSTRAIN_EXPOSURE which one can use to turn on and off the exposure constraint. Unconstrained, the algorithm has a momentum exposure of 1.77 (according to the tear sheet). Adding this constraint with an exposure limit of .20 and then running, results in an exposure of .20 (again according to the tear sheet).

If you just get hung up on a few factor 'over dependancies', this is a simple straightforward way to limit those exposures.

I'll attach the tear sheets of the 'unconstrained' version and then the 'constrained' version for comparison.

Good luck.

Here's the 'unconstrained' tear sheet showing a momentum exposure of 1.77.

Here's the 'constrained' version with the constraint set at .20. The tear sheet now shows (unsurprisingly) a momentum exposure of .20.

Hey Dan,

Thanks for the help! I'll make incorporate those functions. It's very interesting that you can specify the constraints when making orders, appears very useful.