Back

How to get the current date in Backtest?

Hi,

When I was trying to design the algorithm, I got one question: how could I get the dynamic current date(time) of the backtest? Suppose the backtest comes to the date 2017,1,1, how could I get the fundamental data of one stock around that date? And keep getting the date when the date goes by? Is there a global variable tracking the date and time of the backtest?

Thanks a lot!

Best,

Eric

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.


I think it should be self.time which returns a DateTime object?

0

Yes - either self.Time or self.UtcTime will return what you're looking for. It tracks the internal time of the algorithm - it would reflect the real datetime of a system running a live version of your backtest.

1

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