Back

Question: History vs Current

Hi, I tried to see how 'History' function works and found that QC's 'History' function does not include current data. It's OK with it. However, I found something else. Please see my code as below:

# My security list
self.security_list = ["AAPL", "AMZN", "UPS"]

# History (2 min.)
history_min = self.History(self.security_list, 2, Resolution.Minute)
curr_price_history = history_min['close'].unstack(level=0)

# Current Prices of the security list
aapl_price = self.Securities["AAPL"].Price
amzn_price = self.Securities["AMZN"].Price
ups_price = self.Securities["UPS"].Price

# Logs
self.Log('\n' + str(curr_price_history) + '\n')
self.Log('AAPL Price : ' + str(aapl_price))
self.Log('AMZN Price : ' + str(amzn_price))
self.Log('UPS Price : ' + str(ups_price))

At 10:30am, the 'History' function (for the past 2 minutes) showed:

2017-07-03 10:30:00
symbol AAPL AMZN UPS
time
2017-07-03 10:28:00 143.655999 968.07 110.150708
2017-07-03 10:29:00 143.576312 967.88 110.190413

 At 10:30am, current 'Price' of each stock showed:

2017-07-03 10:30:00 AAPL Price : 143.57631170200
2017-07-03 10:30:00 AMZN Price : 967.88000000000
2017-07-03 10:30:00 UPS Price : 110.19041317000

As you can see in the logs above, the current prices of each security are same as the ones of 1 min. ago. What is happening here? Can anyone explain about this? I want current prices! Thanks :)

Update Backtest








In backtesting, when we make a Historical Data Request with the same resolution of the data subscription, the last bar of the request will match current price. This match also depends on the moment the historical data request is made. For instance, if we ask for daily of hourly-resolution data while subcribing to minute-resolution data and make a request at, say, 10:30, prices will be different.

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.


@Alexandre Catarino, Thanks a lot :)

0

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