I have been working on a momentum-based breakout strategy, and naturally, it performs best when the stocks it is trading are trending upward, and less so when it is ranging. The problem is that it is somewhat fit to the general market over the past few years and will not perform out of sample during times they are in a downtrend/ranging, with highest DD on days/weeks the stock/s went negative. Essentially, my algo is very good at capturing breakouts, but on bad days, it will also capture many false positives that cannot go the distance. So rather than trying to fit my algo better to the specific stocks I have been testing on, I would rather fit my stock selection to my algorithm. In a sense, so that it doesn't matter whether google or amazon, etc is having a good day, but instead that some stocks are having a good day.
As far as I understand, coarse universe selection occurs at midnight. The problem is that any stock that is currently experiencing an uncharacteristic, overnight uptrend, will not be included in my universe. I do not want to trade XYZPharmaCompany which had a drug approved and gapped up 10% overnight, the next day. I want to trade it the morning it has gapped up.
Currently, creating a universe of stocks with fundamental data greater than 10$ with 100mil dollar volume narrows down the list massively but it is still very large (around 500). From there, however, my understanding is that it would be too data-intensive (using second data/consolidated 60 sec bars) to simply use RateOfChange or MomentumPercent as a trade criteria to ignore stocks that have not gained 5%ish percent between yesterday's close and the first few minutes of the session. Or am I wrong, (both for backtesting purposes and live trading)?
In an ideal world, I would like my universe to consist of the top 10-25 gainers 5-10 minutes after market open, greater than 10$ with an average of 100mil + dollar volume. But so far, I believe I am constrained by the Universe method.
Thankyou
Adam W
Extended market hours are generally until 8PM, and simplest way is to just add `self.UniverseSettings.ExtendedMarketHours = True`. Limitation of this is that you won't capture any pre-trading (e.g. 4AM - 9:30 AM) since the universe selection happens at midnight, so alternatively you can use a ScheduledUniverseSelection to trigger everyday 5-10 minutes after market open.
A universe of 500 equities with couple of indicators does not seem very data-intensive at all - is there a bug in the code perhaps?
Newoptionz
Hi Adam W
Just out of curiousity and due to the fact that the market moves so much after hours, is there a method to get the pre-trading data?
Thanks
Adam W
Setting `self.UniverseSettings.ExtendedMarketHours = True` will automatically take care of that for you, so pre-trading/extended hours is fed in to `OnData()` as usual. You can differentiate between extended hours vs market hours by adding a check if the market is open. See this backtest:
Logs
Edit: In previous post I meant that if you want pre-trading to be included in the universe selection, you can use a ScheduledUniverseSelectionModel on market open and manually do your filtering using History requests etc.
Newoptionz
Thanks, Adam W
Below is my first shot at this, I have not added to much to your code, just got the structure from copying from the documents to get some stocks having greater then 10million dollar volumen above their 200Day ema's. And added added an event that fires 10min after market opens. In this event we can sort these stocks by those that have increased the most since open. I'm out of time to try to figure that out.
This can be later expaned for decreasing stocks as well, and better methods used then just selecting above or below the EMA, something along the line of being a certain percentile from their ema. Baby steps, first for me. So I would like to continue to work on this any help is appreciated.
Jack Bueller
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!