Back

Previous day OHCL prices

Hi

Because there is no pivot point indicator in LEAN, I have to calculate myself pivot points in my strategy.  A pivot point is simply the average of the high, low and closing prices from the previous trading day.  But also with another PP calclation is to use open price from the previous day in addition.  So I need to get OHCL prices from previous day.

First, I used History method:

history = self.History(self.pair, 1, Resolution.Daily)
o = history['open']
h = history['high']
l = history['low']
c = history['close']

but I got error that 'open' key does not exist.   Does History method deliver only close prices?

I used then SetWarmUp methos:

self.SetWarmUp(timedelta(1)) # Warm up 1 day of data

This works fine.  However, when starting paper backtesting, I have to wait for one day for feeding previous day data.

Is there any other way to get previous day OHCL prices without warming up and waiting for one day to pass in paper and live backtesting?

Thanks for your help

Update Backtest








Hi CloudTrader, history price includes open price. For example "SPY"

history = self.History(["SPY"], 1, Resolution.Daily)
open = history.loc["SPY"]['open']

The history request in Python will return pandas.DataFrame. It is a multi-index dataframe where the first index is the symbol.

For strategy warming up,  you can specify a warm-up period for your algorithm utilizing self.SetWarmUp(TimeSpan) or self.SetWarmUp(barCount). It pumps data in before the start date. When you use the TimeSpan to set the warm-up period, please use longer periods than the period in indicator setting because only the trading days has the data. But since you are using the history instead of the indicator, the History() will automatically get the history price before the current day so I don't think you need to set the warm-up period for history. 

1

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.


Hi Jing, this is really helpful.   Thank you!

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