fmp_py.fmp_historical_data
Classes
Module Contents
- class fmp_py.fmp_historical_data.FmpHistoricalData(api_key: str = os.getenv('FMP_API_KEY'))
Bases:
fmp_py.fmp_base.FmpBase- daily_history(symbol: str, from_date: str, to_date: str) pandas.DataFrame
Retrieves daily historical data for a given symbol within a specified date range.
- Parameters:
symbol (str) – The symbol of the stock or asset.
from_date (str) – The starting date of the historical data in the format ‘YYYY-MM-DD’.
to_date (str) – The ending date of the historical data in the format ‘YYYY-MM-DD’.
- Returns:
A DataFrame containing the daily historical data for the specified symbol.
- Return type:
pd.DataFrame
- intraday_history(symbol: str, interval: str, from_date: str, to_date: str) pandas.DataFrame
Retrieves intraday historical data for a given symbol within a specified time interval.
- Parameters:
symbol (str) – The stock or asset symbol.
interval (str) – The time interval for the data. Must be one of: [‘1min’, ‘5min’, ‘15min’, ‘30min’, ‘1hour’, ‘4hour’].
from_date (str) – The starting date for the data in the format ‘YYYY-MM-DD’.
to_date (str) – The ending date for the data in the format ‘YYYY-MM-DD’.
- Returns:
A DataFrame containing the intraday historical data for the specified symbol and time interval.
- Return type:
pd.DataFrame
- _prepare_data(data_df: pandas.DataFrame) pandas.DataFrame
Prepare data by calculating VWAP and converting data types.
- Parameters:
data_df (pd.DataFrame) – Raw data.
- Returns:
Prepared data.
- Return type:
pd.DataFrame
- _round_prices(data_df: pandas.DataFrame) pandas.DataFrame
Round prices to 2 decimal places.
- Parameters:
data_df (pd.DataFrame) – DataFrame with price data.
- Returns:
DataFrame with rounded price data.
- Return type:
pd.DataFrame
- _calc_vwap(data_df: pandas.DataFrame) pandas.Series
Calculate the Volume Weighted Average Price (VWAP).
- Parameters:
data_df (pd.DataFrame) – DataFrame with price and volume data.
- Returns:
VWAP values.
- Return type:
pd.Series