I am converting my algo from QuantOpian to QuantConnet. I want to convert the before_trading_start() with the hints from Alexandre Catarino in his post "Migrating from Quantopian to QuantConnect" as follow:
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen(self.spy, -45), Action(self.EveryDayBeforeMarketOpen))
And I also define another schedule funtion as follow:
self.Schedule.On(self.DateRules.EveryDay("SPY"), self.TimeRules.AfterMarketOpen(self.spy, 90),
Action(self.Balance))
But it seems these schedule-functions are not called after the defined TimeRules.
Detail see my attached algo.
What I get are as follow:
2017-01-01 00:00:00 :Launching analysis for fe7941eadeb3a161e0cbd4d1806ce18b with LEAN Engine v2.4.0.1.2105
2017-01-04 00:00:00 :EveryDayBeforeMarketOpen
2017-01-04 00:00:00 :Balance
2017-01-04 00:00:00 :SSO Close:77.03571422000
...
One can see the schedule-function 'EveryDayBeforeMarketOpen' is not called 45minutes before the market open. And the schedule-funciton is not called at 90 minutes after the market open.
Have I used the syntatic correctly?
Jared Broad
You're using daily data so the clock is running on a daily step. The "Time" property is correct which is the actual time of the algorithm; but the logging is incorrect. Change to minute resolution and it'll give you the right logs as well.
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.
Thomas Chang
Thanks. It works now.
Another question: I will try using more the Debug() than Log() since I fear if I get use to use the Log(), I could forget to take the Log() out by Live-trading later. But by using Debug() I can't get see the timestampe as by using Log(). So I wonder if QC could provide a function like
get_datetime('US/Eastern')?Thomas Chang
I figure out the time. I use self.Time.
Jared Broad
Cool -- its actually fine to log and debug in live trading. There we pay for your data licenses from the exchanges. Its the backtesting / historical data logging which is blocked by the data vendors.
One difference between debug and log -- debug will block repeated messages.
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.
Thomas Chang
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!