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:

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):