Market Data Manager#
get_available_snapshot_dates(ticker: str) -> list[str]
#
Lists all available snapshot dates for a given ticker.
Scans the market data directory for saved parquet files corresponding to the ticker and extracts the date from the filenames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ticker
|
str
|
The stock ticker to search for, e.g., 'SPY'. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
A sorted list of available dates in 'YYYY-MM-DD' format, from most recent to oldest. |
Source code in src/quantfin/data/market_data_manager.py
get_live_option_chain(ticker: str) -> pd.DataFrame | None
#
Fetches a live option chain from the configured data provider.
The data provider is determined by the live_data_provider
key in the
config.yaml
file. Supported providers are "yfinance" and "polygon".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ticker
|
str
|
The stock ticker for which to fetch the option chain, e.g., 'SPY'. |
required |
Returns:
Type | Description |
---|---|
DataFrame | None
|
A DataFrame containing the formatted option chain data, or None if the fetch fails or no data is returned. |
Source code in src/quantfin/data/market_data_manager.py
load_market_snapshot(ticker: str, snapshot_date: str) -> pd.DataFrame | None
#
Loads a previously saved market data snapshot for a specific date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ticker
|
str
|
The stock ticker of the desired snapshot, e.g., 'SPY'. |
required |
snapshot_date
|
str
|
The date of the snapshot in 'YYYY-MM-DD' format. |
required |
Returns:
Type | Description |
---|---|
DataFrame | None
|
A DataFrame containing the snapshot data, or None if the file is not found. |
Source code in src/quantfin/data/market_data_manager.py
save_market_snapshot(tickers: list[str])
#
Saves a snapshot of the current market option chain for given tickers.
For each ticker, it fetches the live option chain using
get_live_option_chain
and saves it to a parquet file named with the
ticker and the current date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tickers
|
list[str]
|
A list of stock tickers to process, e.g., ['SPY', 'AAPL']. |
required |