0
$\begingroup$

I'm comparing daily and hourly values extracted from YFinance in Python. I'm expecting the open value of the first hour of the market to be equal to the daily open value of the corresponding day, and the close value of the last hour of the market to be equal to the daily close value. Also, the min and the max daily values should be contained in at least one of the hourly values.

I enabled back adjustments in both the cases and enabled the pre & post market hours for the hourly data trying to find a corresponding daily value.

None of my assumptions holds: hourly and daily values are different (open, high, low and close).
E.g: the highest daily value is 32.746275 and the highest hourly value is 33.919899 (at 11:30).

What am I doing wrong?

import yfinance as yf

ticker = 'AY'
net = yf.Ticker(ticker)

start_date, end_date = '2020-11-06', '2020-11-07'
daily_signals_df = net.history(start=start_date, end=end_date, interval='1d', back_adjust=True, auto_adjust=True, prepost=False)
hourly_signals_df = net.history(start=start_date, end=end_date, interval='1h', back_adjust=True, auto_adjust=True, prepost=True)
>>> daily_signals_df

enter image description here

>>> hourly_signals_df

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ I think this is the same $\endgroup$
    – AKdemy
    Jul 15, 2021 at 10:36
  • $\begingroup$ Thank you @AKdemy. The difference between the two open values is more than 3.5%. Is it really due to noise in data? The values are incoherent for almost all the dates. $\endgroup$ Jul 15, 2021 at 10:48
  • 2
    $\begingroup$ Yahoo Finance data quality seems to be a FAQ. :) $\endgroup$ Jul 15, 2021 at 13:10

1 Answer 1

8
$\begingroup$

When you sample stock market data, you really need to understand what source(s) and rules are being used, and any adjustments applied to the data. Different rules might also exist for different periodicities sampled too.

There are may different/methodologies applied to Consolidated tape price versus listed exchange price versus a specific exchange price.

For example, the opening price of a NYSE-listed stock might be quite different to the first traded price of that stock across all exchanges. Some data might also be limited to a particular exchange to reduce realtime royalties (e.g. IEX or Cboe trades only). The timing of the open is often different too - NYSE stocks can actually take a few minutes to "open" versus other venues.

Secondly, when examining historical data, you need to determine what price adjustment methods are used to back-adjusted prior prices for corporate actions, such as splits/reverse splits, stock dividends (same stock), stock dividends (different stock)/spinoffs, special cash dividends/distributions, long-term/short-term capital gains, returns of capital, ordinary cash dividends/distributions etc.

In your example of AY, the daily source appears to be adjusted for cash dividends.

The hourly data is NOT adjusted for cash dividends and is probably raw data (I haven't checked the exact values).

The hourly data also suffers from single precision floating point inaccuarcies. AY actually opened at $32.01 on 20201106 (not 32.009998).

Best advice: Ask your data vendor exactly which venue trades/trade types are incorporated into their data and which price adjustment mechanisms are used. Even better if you can select various parameters yourself. Consider rounding as required to overcome floating point issues.

I'll give an interesting example on an S&P 500 NYSE:GE (General Electric) trade date 20210623 with data points representing values as at 20210714. GE had a $0.01 dividend with exdate 20210625.

  • Consolidate tape open: $13.02

  • NYSE open: $13.00

  • IEX open: $13.015

  • Total return adjusted consolidated tape open: $13.01009885931559

For volume:

  • Final Consolidated tape volume: 43,677,544

  • Final NYSE-only trade volume: 8,188,906

  • Final IEX-only volume: 855,297

  • Final diviend-adjusted tape volume: 43,710,784.140

As you can see, the prices and volumes change based upon the methodology/venues used.

Full disclosure: Norgate Data is a data vendor of daily periodicity stock data. I am a co-owner of the company.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.