I'm not sure how to add this, but how can you make it so it picks only stocks within a certain price range? like below 20 dollars in price.
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
How to limit stock selection to under $20 price range in random universe selection?
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
Random Universe Selection
Zedrick Gilo | August 2016
I'm not sure how to add this, but how can you make it so it picks only stocks within a certain price range? like below 20 dollars in price.
QuantConnectâ„¢ 2025. All Rights Reserved
Alexandre Catarino
Hi Hector, please checkout the docs section Universes.
Here is code snippet from the Coarse Universe Selection section that teaches you how to pick stocks based on price:
// Take the top 50 by dollar volume using coarse AddUniverse(coarse => { return (from c in coarse where c.Price > 10 orderby c.DollarVolume descending select c.Symbol).Take(50); });
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.
Zedrick Gilo
Ah, Yeah I'm reading it now. Thank you.
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.
Zedrick Gilo
Okay, So I added the code under the setcash like this
public override void Initialize() { UniverseSettings.Resolution = Resolution.Daily; SetStartDate(2016, 01, 01); SetCash(100000); // Take the top 50 by dollar volume using coarse AddUniverse(coarse => { return (from c in coarse where c.Price > 10 orderby c.DollarVolume descending select c.Symbol).Take(10); });
I get no errors but, It doesn't seem to be working correctly... Do it not belong there?
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.
Guadiana
Hi Hector. You are adding universe twice.
First you're adding Universe with the explicit selection function as parameter on line 44.
Later on line 55, you're calling again AddUniverse, using CoarseSelectionFunction, FineSelectionFunction as parameters.
i moved your code inside the CoarseSelectionFunction
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.
Guadiana
By the way, the code Alex Catarino posted is based on LINQ syntax. The one i did is is slightly different, as it uses Lambda expressions . Both do the same.
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.
Zedrick Gilo
Thank you guys, but why is it that when I look at the trades in the backtesting it still doesn't do trades within the price range?
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.
Alexandre Catarino
Hi Hector,
The price is not adjusted when you select the security.
After you selected it, it will be adjusted by default.
I changed Marco's algorithm to buy securities with price below $20 like you asked above. On February 4th, 2016, DUST was priced at $8.66, so it was selected to be bought. Since DUST has two reverse splits (1:15), it was bought with the adjusted price of $464.5.
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!