Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Use one of 2 factors depending on the value of the third factor

Say, I have a factor that returns True if it's better to use Factor1 and False if it's better to use Factor2.
For example in the first 15 days since report I long the stocks with highest capex and after that I short them.

For order_target_portfolio I can do it with combining Boolean factors (like the algorithm attached - I can feed 'longs' and 'shorts').
But for order_optimal_portfolio I need opt.MaximizeAlpha that requires an array of floats.
So I need an array of floats that depend on the value of another factor - days since report.

How would you implement something like this?
Factor X =
Factor1 where FactorSelect == True
Factor2 where FactorSelect == False

1 response