awt_quant.data_fetch package¶
Submodules¶
awt_quant.data_fetch.macro module¶
FRED Macroeconomic Data Fetching and Visualization
This module provides functions to fetch macroeconomic time series data from the Federal Reserve Economic Data (FRED) API and visualize the results using Plotly. It supports retrieving both historical data and metadata for various economic indicators.
- Functions:
get_fred_series(series_id, shorten=False): Fetches time series data from FRED.
get_fred_series_info(series_id, as_dict=True): Retrieves metadata for a FRED series.
get_macro(series_id, data=True, info=True, shorten=False): Fetches both time series and metadata for a FRED series.
get_bulk_macro(series_dict): Bulk fetches macroeconomic data for predefined indicators.
plot_macro_series(data, meta_data, dropna=False, y_axis_format=None): Plots macroeconomic time series data.
plot_macro_series_forecast(forecast_data, actual_data, meta_data, dropna=False, y_axis_format=None): Plots actual and forecasted macroeconomic data with confidence intervals.
fetch_and_plot(series_id, with_data=False): Fetches and plots a macroeconomic time series.
- Usage:
df, meta = get_macro(“GDP”) fig = plot_macro_series(df, meta) fig.show()
- awt_quant.data_fetch.macro.get_fred_series(series_id, shorten=False)[source]¶
Fetches time series data from FRED.
- awt_quant.data_fetch.macro.get_fred_series_info(series_id, as_dict=True)[source]¶
Retrieves metadata for a FRED series.
- awt_quant.data_fetch.macro.get_macro(series_id, data=True, info=True, shorten=False)[source]¶
Fetches both time series data and metadata for a given FRED series.
- Parameters:
- Returns:
(pd.DataFrame, dict) or single return depending on arguments.
- Return type:
- awt_quant.data_fetch.macro.get_bulk_macro(series_dict={'Consumer Price Index (CPI)': 'CPIAUCSL', 'Federal Funds Rate': 'FEDFUNDS', 'Gross Domestic Product (GDP)': 'GDP', 'Retail Sales': 'RSXFS', 'Unemployment Rate': 'UNRATE'})[source]¶
Bulk fetch of major macroeconomic series data.
awt_quant.data_fetch.yf_fetch module¶
Yahoo Finance Data Fetching
This module provides a function to fetch historical stock price data from Yahoo Finance. It preprocesses the data for use in stochastic differential equation models.
- Functions:
download_data(ticker, start_date, end_date, train_test_split): Fetches and splits stock price data.
- Usage:
train_data, test_data, meta_data = download_data(“AAPL”, “2022-01-01”, “2023-01-01”, train_test_split=0.8)
- awt_quant.data_fetch.yf_fetch.download_data(ticker, start_date, end_date, train_test_split)[source]¶
Downloads stock price data from Yahoo Finance and processes it for training/testing.
- Parameters:
- Returns:
- (train_data, test_data, meta_data)
train_data (pd.DataFrame): Training set containing stock close prices.
test_data (pd.DataFrame): Testing set containing stock close prices.
meta_data (dict): Dictionary with additional information (dates, S0, T, N).
- Return type:
Module contents¶
Data Fetching Module
This module provides functions for retrieving financial and macroeconomic data from external sources such as Yahoo Finance.
Available Functions: - fetch_macro_data: Retrieves macroeconomic indicators. - fetch_yfinance_data: Fetches historical stock price data from Yahoo Finance.
- awt_quant.data_fetch.get_macro(series_id, data=True, info=True, shorten=False)[source]¶
Fetches both time series data and metadata for a given FRED series.
- Parameters:
- Returns:
(pd.DataFrame, dict) or single return depending on arguments.
- Return type:
- awt_quant.data_fetch.plot_macro_series(data, meta_data, dropna=False, y_axis_format=None)[source]¶
Plots macroeconomic time series data.
- Parameters:
- Returns:
A Plotly figure object.
- Return type:
plotly.graph_objects.Figure
- awt_quant.data_fetch.get_bulk_macro(series_dict={'Consumer Price Index (CPI)': 'CPIAUCSL', 'Federal Funds Rate': 'FEDFUNDS', 'Gross Domestic Product (GDP)': 'GDP', 'Retail Sales': 'RSXFS', 'Unemployment Rate': 'UNRATE'})[source]¶
Bulk fetch of major macroeconomic series data.
- awt_quant.data_fetch.get_fred_series_info(series_id, as_dict=True)[source]¶
Retrieves metadata for a FRED series.
- awt_quant.data_fetch.get_fred_series(series_id, shorten=False)[source]¶
Fetches time series data from FRED.
- awt_quant.data_fetch.download_data(ticker, start_date, end_date, train_test_split)[source]¶
Downloads stock price data from Yahoo Finance and processes it for training/testing.
- Parameters:
- Returns:
- (train_data, test_data, meta_data)
train_data (pd.DataFrame): Training set containing stock close prices.
test_data (pd.DataFrame): Testing set containing stock close prices.
meta_data (dict): Dictionary with additional information (dates, S0, T, N).
- Return type: