Hi,
When switching to Live paper trading, I am wondering about the execution timing and order of the portfolio. In my backtest all works fine but in Live/paper the trades are not executed.
I read through the Live trading documentantion but still had two questions:
1. Is it fair to say that Universe Selection is automatically executed between 4-7AM ET each day? Are the AlphaModel, PortfolioConstruction and ExecutionModel then executed sequentially after the universe selection has been completed or is a scheduled event required to construct the portfolio?
2. In addition as of what time in the evening are the close prices available for extended market hours?
class TestAlgo(QCAlgorithm):
def Initialize(self):
# initialize all parameters
# ....
self.UniverseSettings.Resolution = Resolution.Daily
# Leverage Algo framework for execution
self.SetUniverseSelection(MyUniverseModel()) # Leverages coarse and fine of FundamentalUniverseSelectionModel
self.SetAlpha(MyAlphaModel())
self.SetPortfolioConstruction(MyPortfolioConstructionModel())
self.SetRiskManagement(MyRiskManagementModel())
def OnData(self):
# leverage algo framework instead of OnData
pass
Derek Melchin
Hi Goofball,
(1) When backtesting, universe selection is performed at midnight by default; During live trading, universe selection is done about 6 hours later. The alpha model is not called directly after the universe selection model. Rather, it's called when a new data slice is available. As for the operation of the other Framework components, refer to our documentation. No scheduled event is needed to trade with the Framework design.
(2) In live trading and backtesting the daily bars are closed at midnight. When using extended market hours and non-daily resolution data, the extended market hours close will be provided to the algorithm at 8pm NY exchange time.
For any issues with live deployments, open a support ticket. This video explains the process.
https://www.youtube.com/watch?v=MIAJU6xWM0ABest,
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.
Goofball
Derek,
Thanks for the info. I just want to further clairfy the behavior of the Framework and On Data.
If the extended market data is available at 8PM ET I assume the OnData event will be triggered and execute the OnData code followed by the alpha, portfolio construction, risk and order execution models as outlined by the Framework.
Are there other instances with daily resolution data that will trigger the OnData slice and consequently trigger the Framework compents?
My goal is to run the Framework at the end of day just once. If the OnData is triggered only once a day when new market data is available then that is great. If OnData has other potential triggers then how can I ensure to execute the Framework components once a day (e.g., through a scheduled function?)
Derek Melchin
Hi Goofball,
After setting the universe resolution to daily, it's still possible for OnData to be called intraday. For example, in the attached backtest, we susbcribe to TiingoNews data, so the OnData is called intraday when a new article is released. However, if an algorithm only subscribes to daily pricing data, the OnData method should only be called at the end of each day.
This is a bad idea. We do not recommend using daily price data with intraday signals. Its much safer to simply use minute data to get accurate intraday fills.
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.
Goofball
Thanks Derek. That makes sense.
Is there a way to determine what the trigger is for the OnData call (e.g., can I determine that it was triggered by extended market hours data availability, by Tingo News, etc.). In my case it would be great if I can determine if the event trigger is the market data availability.
Derek Melchin
Hi Goofball,
We can determine why OnData was called by examining the data slice passed to it.
if data.ContainsKey(self.symbol) and data[self.symbol] is not None: self.Log("New price data") elif self.alpha.tiingo_symbol is not None and data.ContainsKey(self.alpha.tiingo_symbol): self.Log("New Tiingo data")
See the attached backtest for reference.
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.
Goofball
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!