Back

Using RollingWindow to retrieving OHLC data

I'm trying to access the OHLC data from the first one minute bar of the regular trading day i.e. 09:30 - 09:31 ET using a rolling window (currBar1 = self.minute_rw[0]) and the final one minute bar of the prior trading day i.e. 15:59 - 16:00 using pastBar1 = self.minute_rw[1].

I've attached a simply Python script which correctly fires at 9:31 ET.  And although I'm waiting for the first 1m bar to finish using the following line (if not (self.minute_rw.IsReady): return), the script appears to be out by two 1 minute bars.  For example:

    currBar1 = self.minute_rw[0] which should be pulling the first 1 min bar ending 09:31, is pulling the data from the 1 min bar ending 15:59 (of the previous day)
    
    pastBar1 = self.minute_rw[1] which should be pulling the bar ending 16:00 (of the prior day), is pulling the data from the 1 min bar ending 15:58.

Any suggestions on how I can modify the code to pull the data from the first 1 min bar ending 09:31 and the previous 1 min bar (i.e. the final 1 min bar ending 16:00 of the previous day)? 

Here is a snipit of the log from the attached script:
    
2018-05-06 00:00:00 :    Launching analysis for eda7ae0a002b87a8fc9ecf9a47a28548 with LEAN Engine v2.4.0.0.3751
2018-05-08 09:31:00 :    Script fired at (s/b 09:31) : 2018-05-08 09:31:00
2018-05-08 09:31:00 :    Past Bar Time on 1 min s/b FINAL 1 min of prior day
2018-05-08 09:31:00 :    Past Bar Price: Time: 2018-05-07 15:58:00 Open: 266.81 High: 266.92 Low: 266.81 Close: 266.90
2018-05-08 09:31:00 :    Current Bar Time on 1 min s/b FIRST 1 min of current day
2018-05-08 09:31:00 :    Current Bar Price: Time: 2018-05-07 15:59:00 Open: 266.895 High: 266.99 Low: 266.81 Close: 266.91
 

Update Backtest








check the examples provided by QC using history

0

Thank you Michael for your reply.  Are you suggesting that I look at history examples because  RollingWindows should not be used to retrieve OHLC data?  I've looked at the history examples and prefer to use RollingWindows, if it's possible.

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