Back to Community
help understanding current 'open', 'high', 'low', and 'close'

According to the API documentation:

'open', 'high', 'low', and 'close' return the relevant information for the current trade bar. If there is no current trade bar, NaN is returned. These fields are never forward-filled.

Does this mean that for '1d' data, I can't rely on the current open, high, low, or close? As an example, I have taken some Quantopian code from "recording and plotting variables" and just replaced the securities with IHT. Sometimes the high/low is clearly returned as NaN, but it's not consistent. If I replace IHT with AAPL, for instance, there are no NaNs. It would seem that one should never use data.current(asset, 'high') as the value is unreliable. Is my understanding correct?

Clone Algorithm
3
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5734eb769dd7c4124e949c23
There was a runtime error.
3 responses

I'm not sure about never and unreliable--you can use it, how you handle the data after that is up to you. it seems that at least this part of Q is working as stated in docs.

I wouldn't call it unreliable but don't expect stocks to always be traded. I would write some code to either forward fill or wait until the next bar for trading activity.

The places where data.current for 'high' and 'low' returns NaN are indeed where the volume is 0, as seen in the attached backtest. This behavior seems reasonable, since a particular high or low price cannot be assigned if no shares changed hands on that day.

Dave, is there some reason you need this data to be non-NaN?

Clone Algorithm
3
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5745f0bcbb31b00f8f584d7d
There was a runtime error.
Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.