### Basic yfinance-cache Usage Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Demonstrates the basic interaction with the yfinance-cache library, showing how to import, create a Ticker object, and access historical data and calendar information. This is the primary way to use the library for fetching financial data. ```python import yfinance_cache as yfc dat = yfc.Ticker("MSFT") dat.history(period="1wk") dat.calendar # etc ``` -------------------------------- ### View and Set Persistent Cache Options Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Demonstrates how to view and modify persistent caching options, such as the max age for calendar data. ```python import yfinance_cache as yfc print(yfc.options) { "max_ages": { "calendar": "7d", ... } } yfc.options.max_ages.calendar = '30d' print(yfc.options) { "max_ages": { "calendar": "30d", ... } } ``` -------------------------------- ### Price Data Adjustment in yfinance-cache Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Shows how to enable adjustments for stock splits and dividends when fetching historical price data. This ensures the cached data remains accurate by accounting for corporate actions. ```python dat.history(..., adjust_splits=True, adjust_divs=True) ``` -------------------------------- ### Verify Prices of Entire Cache Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md This function verifies prices for all cached ticker symbols, processing them alphabetically. It's recommended to use a `requests_cache` session for debugging. Options include setting tolerances, correcting data, halting on failure, and resuming from a specific ticker. ```python # Verify prices of entire cache, ticker symbols processed alphabetically. Recommend using `requests_cache` session. yfc.verify_cached_tickers_prices( session=None, # recommend you provide a requests_cache here if debugging rtol=0.0001, vol_rtol=0.005, correct=[False|'one'|'all'], halt_on_fail=True, # stop verifying on first fail resume_from_tkr=None, # in case you aborted verification, can jump ahead to this ticker symbol. Append '+1' to start AFTER the ticker debug_tkr=None, # only verify this ticker symbol debug_interval=None) ``` -------------------------------- ### Set Max Age for Price Data Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Controls when price data cache is updated based on a specified time duration. Defaults to half of the interval. ```python df = dat.history(interval="1d", max_age="1h", trigger_at_market_close=False, ...) ``` -------------------------------- ### Fix All Data Issues Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md To automatically correct all identified data issues across the entire cache, use `verify_cached_tickers_prices` with `correct='all'` and `halt_on_fail=False`. ```python yfc.verify_cached_tickers_prices(correct='all', halt_on_fail=False) ``` -------------------------------- ### Enable Offline Mode Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Disables all web fetches by setting the session to offline mode. These options reset when Python closes. ```python import yfinance_cache as yfc yfc.options.session.offline = True ... ``` -------------------------------- ### Verify Prices of a Single Ticker Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Use this function to check the cached prices for a specific ticker symbol. You can configure relative tolerances for price and volume, and choose how to handle incorrect data (none, first, or all). ```python # Verify prices of one ticker symbol dat.verify_cached_prices( rtol=0.0001, # relative tolerance for differences vol_rtol=0.005, # relative tolerance specifically for Volume correct=[False|'one'|'all'], # delete incorrect cached data? 'one' = stop after correcting first incorrect prices table ; 'all' = correct all tickers & intervals discard_old=False, # if cached data too old to check (e.g. 30m), assume incorrect and delete? quiet=True, # enable to print nothing, disable to print summary detail of why cached data wrong debug=False, # enable even more detail for debugging debug_interval=None) ``` -------------------------------- ### Scan for Data Mismatch Without Correction Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md To simply scan for the first data mismatch without attempting to correct it, call `verify_cached_tickers_prices()` with default parameters. ```python yfc.verify_cached_tickers_prices() ``` -------------------------------- ### Set Max Age for Shares Data Source: https://github.com/valueraider/yfinance-cache/blob/main/README.md Specifies the maximum age for cached shares data before it is considered stale and needs updating. ```python df = dat.shares(..., max_age='60d') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.