Hi guys!
Searched the docs and forums trying to disable short positions on a portfolio. Closest thing I found was the PortfolioBias.Long parameter for the Portfolio constructor but it doesn't seem to change the outcome.
Any tips? Backtests attached.
Thanks in advance!
Mak K
Hi Mauricio,
For this you should modify code in the alpha model itself.
Instead of importing the alpha model, what you can do is add it into your main file.
In the Initialize you do this;
And then you simply copy/paste the alpha model code into your main.py file, like this;
This is where you find the alpha model.
Then here;
You either remove the elif condition entirely or try changing it to “InsightDirection.Flat”
You can play around with this as you wish but this “InsightDirection.Down” is what makes it go short..
You might have to read through the alpha model code for a bit and try a few things to achieve whatever is your desired outcome but this should work.
Also the “if direction == sd.PreviousDirection: continue"
might cause some problems.
If you have any further questions please let me know
Vladimir
Mauricio Hernández Durán
Try this one, it is long only
Mauricio Hernández Durán
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!