Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How do I take the opposite position?

how good are
(1) => opt.MaximizeAlpha
(2) => opt.experimental.RiskModelExposure
(3) =>algo.order_optimal_portfolio

While I understand the practical need for 2 and 3, can 1 actually work against your strategy?

To state the question more clearly, how do I ask my algorithm to take the exact opposite trade that the opt.MaximizeAlpha calculates?
My backtest is consistently losing money so if I take the opposite side it will consistently make money

7 responses

If one finds a strategy that is consistently downward, celebrate and just add a minus sign. :)
Placing a minus sign in front of the input multiplies all of the values by -1, flipping long & short.

It can also be an interesting test to do for anyone.

    objective = opt.MaximizeAlpha( -context.output.alpha ),

On the first question, there are some key things in the difference between MaximizeAlpha and TargetWeights to understand and they can probably be picked up best fairly quickly at some of these pages:

https://www.google.com/search?q=MaximizeAlpha+site:quantopian.com

It unfortunately doesn't seem to work that way :(

Probably partial fills then. Compare 1/10th the starting capital.

It'll be commission/slippage as well

even if I did not specify those?

it assigns default values

def initialize(context):  
    set_slippage(slippage.FixedSlippage(spread=0))  # no partial fills  
    #set_commission(commission.PerTrade(cost=0))  

With slippage off and thus no partial fills you'll find the returns will be closer to a mirror image of each other in comparing with and without the minus sign input to MaximizeAlpha.