Rate limits and caching¶
Yahoo Finance throttles clients by IP address. Too many requests in a short time return HTTP 429, and a persistent block can last hours. The server is built to avoid that.
How requests are paced¶
- One session. Every tool shares one Yahoo session (one cookie and crumb) for the life of the process, instead of a new handshake per call.
- A process-wide rate limit. Every HTTP request, including the cookie and crumb requests, passes through one token bucket: by default bursts of 5, then 2 per second. Calls wait their turn rather than fail.
- A pause after HTTP 429. When Yahoo answers 429, every request stops for 30 seconds.
Another 429 right after doubles the pause, up to 5 minutes; a successful request resets
it. During a pause, tools answer at once with
rate_limitedand the seconds to wait. - Multi-symbol calls stop early. After a rate limit,
get_quotes,get_price_history,get_newsandget_eventsreport the remaining symbols inerrorsasrate_limitedinstead of requesting them.
Tune the pace with YFINANCE_AGENT_MCP_RATE_LIMIT and YFINANCE_AGENT_MCP_RATE_BURST
(configuration).
How answers are cached¶
Each answer is cached by tool and arguments for a time that suits the data: 15 seconds for
quotes, 2 minutes for news, 6 hours for fundamentals (full table).
A cached answer keeps the as_of of its original fetch, so the agent can always see its age.
Failures are never cached.
yfinance itself caches some responses for the life of the process with no expiry; the server clears that cache before each request so its own expiry times decide freshness.
What an agent should do¶
- Batch. One
get_quotescall with 20 symbols is far cheaper than 20 calls. - Prefer summaries.
get_price_historyin summary mode gives indicators without requesting more bars. - On
rate_limited, wait the number of seconds in the message, then retry once. - Don't poll in a tight loop. Asking for the same quote every second only returns the
cached answer; use
get_live_quotesfor continuous prices.
Request costs¶
The tool reference lists approximate Yahoo requests per call. The first call in a process also fetches a cookie and crumb, and the first request for a symbol may look up its timezone, which is then cached on disk.