Data freshness¶
A price is only useful if you know how old it is. Yahoo Finance data comes with different delays per exchange, and the server adds its own short cache. These fields tell an agent exactly how current an answer is.
The fields¶
| Field | Where | Meaning |
|---|---|---|
as_of |
every answer | When the server fetched the data from Yahoo. A cached answer keeps its original as_of. |
market_time |
get_quotes |
Time of the last regular-session price. |
market_state |
get_quotes, get_market_overview |
PRE, REGULAR, POST or CLOSED (Yahoo also uses PREPRE and POSTPOST). |
delay_min |
get_quotes with include_details, get_market_overview |
Minutes the exchange delays its data. 0 is real time. |
quote_source |
same as delay_min |
Yahoo's source, e.g. Nasdaq Real Time Price or Delayed Quote. |
exchange_time, age_seconds |
get_live_quotes |
When the exchange printed the tick, and how long ago the server received it. |
last_bar_time |
get_price_history |
Start of the most recent bar. |
What to expect¶
- US stocks often show
Nasdaq Real Time Price, yet Yahoo may still reportdelay_min: 15for the exchange; trustmarket_timefor the actual age. - European exchanges (for example
SAP.DE) are typically delayed by 15 minutes. - Futures and indices in
get_market_overvieware often delayed by 10 to 20 minutes. - Crypto (
BTC-USD) trades around the clock with no delay. - Outside regular hours
priceis the last regular-session price; pre- and post-market prices are indetails(pre_market_price,post_market_price) withinclude_details.
Rules for agents¶
- Before acting on a price, read
market_timeandmarket_state; if the market is closed, say the price is the last close. - If
delay_minis above 0, say the quote is delayed, and by how much. - For decisions that need the current price, use
get_live_quotes, which reports each tick's age. - When comparing data from several calls, compare their
as_oftimes; cached answers can be a few seconds to hours old depending on the cache category.
Not for live trading¶
Yahoo Finance data is unofficial, can be delayed, incomplete or wrong, and is meant for personal use. Verify prices with your broker before any order. See the disclaimer.