Is there a way to get the update resolution within an AlphaModel?
Also, is there a way to schedule the update of the AlphaModel to run at certain times (eg. 10 minutes before trading close) in addition to it's normal resolution?
QUANTCONNECT COMMUNITY
Is there a way to get the update resolution within an AlphaModel?
Also, is there a way to schedule the update of the AlphaModel to run at certain times (eg. 10 minutes before trading close) in addition to it's normal resolution?
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.
Derek Melchin
Hi Fabien,
We can not a higher resolution in the alpha model than the universe resolution, but we can consolidate data into a lower resolution. I recommend reviewing our documentation to see how this can be done.
We can schedule an event to occur 10 minutes before the close by using `Schedule.On` inside the alpha model constructor.
def __init__(self, algorithm): algorithm.Schedule.On(algorithm.DateRules.EveryDay("SPY"), \ algorithm.TimeRules.BeforeMarketClose("SPY", 10), \ self.flag_close) self.algo = algorithm self.closing_soon = False def flag_close(self): self.closing_soon = True
Then we just need to check the `closing_soon` flag inside `Update`.
def Update(self, algorithm, data): insights = [] if self.closing_soon: self.closing_soon = False self.algo.Log("10 minutes before close!") return insights
See the attached backtest for a full example of this. Keep in mind that this should only be done when the algorithm has subscribed to a data resolution at the minute level or greater.
Best,
Derek Melchin
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.
Fabien
My universe is set to a resolution of 1 hour. It is a shame I can not schedule events in between those intervals on the equities from within my alpha model but I can do it using the classic style (non-algorithm framework). The classic style allows events to be scheduled any time regardless of the update resolution for the equity.
Jared Broad
Hi Fabien the Scheduled event technology is identical for both framework and classic algorithms. For both types of algorithms, you should be using a data resolution less than the scheduled event resolution to ensure it actually triggers at that time in backtesting. In backtesting, the data feed sets the clock.
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.
Fabien
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!