Back

Real Time Event

Hi Team,

I'm wondering if there is an example of how to use Real Time Events.
Let's say there is a NFP data coming out at 2pm, and I want to trigger an algo at exactly that time.
How do I register the event, so it can be triggered by the realtimehandler?
Thank you.

Jianwei
Update Backtest








Welcome @Jianwei! RealTimeHandler isn't exposed to the algorithm yet but we'll add a git issue for it and probably get to it this week :) We might need to give this some thought though to cover all the cases people want to see. I've created an issue for it here.

If you're keen the fastest way to see this in LEAN would be to contribute the code!
0

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.


Thanks Jared,

My idea is to add the following event registering methods in QCAlgorithm.
User can AddCustomEvent in Initialize() function in Algorithm.
The custom events are stored in a list and added to the RealTimeHandler during core engine initialization process.

public void AddCustomEvent(DateTime dt, string symbol)
{
var action = new RealTimeEvent( dt, () =>
{
try
{
OnCustomEvent(dt, symbol);
}
catch (Exception err)
{

}
}));

CustomEvents_.Add(Action);
}

virtual void OnCustomEvent(DateTime triggerTime, string symbol)
{
}
0

Thanks Jianwei, please check out the Git issue. We've designed something similar to that which is a little more flexible so people can create different event styles (e.g. 3 times per month, every day at 12, every 30 minutes).
0

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.


Update Backtest





0

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.


Loading...

This discussion is closed