Hi,
I recently started to use QC and want to learn about updates of universe selection and alpha in the big picture of the algorithm framework before starting to code/test a strategy.
Please find an simplified example of what I want to achieve with algo framework models:
- Day 1 -> Let's say my universe selection + alpha triggers to buy TSLA (with a specific event in time such as earnings for instance, a discrete time signal).
- Day 2 -> TSLA went up and is no longer selected/triggered in universe selection + alpha models (no more earnings event remains this day), but the stock is still up and I want to extract money from it with a trailing stop loss or another risk management model.
- Day 3 -> TSLA still up. My universe selection + alpha now triggers to buy DDOG. I want to: rebalance TSLA according to how much value is left to extract from it (based on alpha model 2 with indicators or risk model) and rebalance to add DDOG.
- Day 4 -> TSLA goes down under my 5% trailing stop-loss threshold and I sell it. DDOG still extracting money.
My questions:
- Do my universe selection + alpha models needs to keep selecting and triggering insights on day 2 for me to keep TSLA in portfolio (is TSLA still in portefolio on day 2 if earnings trigger ended) ?
- Otherwise what would be the best updates methods, approach or model (risk, 2nd alpha model, 2nd universe, feedback loop on portfolio, etc) to use for this kind of strategy ?
Thanks ! All the best
Shile Wen
Hi Etienne,
Sorry for the late reply.
Day 1: Emit an Insight with timedelta(days=2), or any other time period
Day 2: TSLA may or may not be liquidated, it all depends on the Universe Selection model. For trailing stop-loss risk management, I would suggest this implementation by Ofir Shmulevich.
Day 3: use the method Rebalance within the Universe Selection Model
Day 4: see Day 2
The way Insights work is that when they are emitted, if the InsightDirection is Up, then the algorithm buys that stock now (or over a period of time, depending on the Execution Model), and sells it (immediately or over time, like before) after the specified timedelta, and does the reverse when the InsightDirection is Down. So if an Insight with InsightDirection Up is emitted for TSLA for 2 days, a buy order would be executed at that time or over a period of time of the Insight, and after 2 days, the TSLA stock will be sold at that time or over a period of time. That means after the 2 days are over, further Insights would need to be emitted in order to keep the same sized position in TSLA in the portfolio, or the original Insight could be set with a longer time period. More information on Insights can be found here.
For more flexibility in a trading strategy, feel free to extend a Component of the Algorithm Framework and customize it however you would like. For this particular strategy, I believe increasing the length of the Insight while adding a Trailing Stop Loss Risk Management model (see above) would work the best.
Best,
Shile Wen
Etienne RAINAUT
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!