Back to Community
Does BarData.current(assets, fields) returns the adjusted price ?

Does the following method: quantopian.algorithm.interface.BarData.current(assets, fields), returns the split/dividend adjusted price ?

4 responses

The data.current method returns data ("open", "high", "low", "close", "volume", or "price") which is adjusted as of the current simulation date. What does this mean? For all fields except "price" the data will always be the actual traded values one would have seen at the current simulation minute. If no trades took place in that minute, "open", "high", "low", and "close" will return nan and "volume" will return 0. It is effectively the 'actual' data.

However, "price" returns the last known close price for the asset. It is forward-filled from an earlier minute if there were no trades during the current minute. If there is no last known value (either because the asset has never traded, or because it has been delisted) nan is returned. If the value is found from a previous day, and it crossed an adjustment boundary (split, dividend, etc), then the value is adjusted to the current simulation time before being returned.

Data in an algorithm, no matter how it is fetched, will never be adjusted for any future splits. This is to prevent any look-ahead bias.

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.

@Dan,
I am interested in getting the Adjusted_Close_Price each day.

When looking at
https://www.quantopian.com/posts/comparing-data-sets

df2 = get_pricing(  
    symbols('XOM'),  
    frequency='daily',  
    start_date='2008-09-01',  
    end_date='2019-10-10'  
)
diff_df=df2['close_price']-df2['price']

diff_df.sum()

Out[16]: 0.0  

shows no diff in close_price versus price, which I guess makes sense as price at the end of the day.
So the question is:

Is close_price the adjusted close price that adds in dividends and splits when they happen?

Thanks!
alan

The price field is the same as close_price but is forward filled when there is no data (ie no trades during that period). Heavily traded securities such as XOM will generally have trades every period so price will generally be the same as close_price. For analysis, one would typically use price especially for minute data. The close_price field often has a lot of nans which may complicate one's analysis. It does depend upon the application though.

So, the question "Is close_price the adjusted close price that adds in dividends and splits when they happen?". Yes, in a research notebook when using the get_pricing method (and other similar methods) the prices are all adjusted as of the end date. All splits and dividends up through the end date, set as a parameter in the method, are accounted for. To get current adjusted prices and volumes similar to those found on Yahoo and other sites simply set the end date to the current date.

One can see the impact of an adjustment by varying the end date. AAPL had a 7:1 split effective 2014-06-09. Copy, paste , and run the code below in a notebook. The adjusted prices before the split are all around $630 while, when adjusted after the split, are all 1/7 of that around $90.


day_before_aapl_split = '2014-06-08'  
day_of_aapl_split = '2014-06-09'

aapl_before_split = get_pricing(  
    symbols('AAPL'),  
    frequency='daily',  
    start_date='2014-06-01',  
    end_date=day_before_aapl_split  
)

aapl_after_split = get_pricing(  
    symbols('AAPL'),  
    frequency='daily',  
    start_date='2014-06-01',  
    end_date=day_of_aapl_split  
)

display(aapl_before_split, aapl_after_split)

Make sense?

@Dan,
Thanks!
Yes...makes sense.
alan