Daily and Historical Returns
Returns are implemented in finquant.returns
.
The module provides functions to compute different kinds of returns of stocks.
- finquant.returns.cumulative_returns(data, dividend=0)
Returns DataFrame with cumulative returns
\(\displaystyle R = \dfrac{\text{price}_{t_i} - \text{price}_{t_0} + \text{dividend}} {\text{price}_{t_0}}\)
- Parameters:
data (
DataFrame
) – A dataframe of daily stock pricesdividend (
NUMERIC
, default: 0) – Paid dividend
- Return type:
DataFrame
- Returns:
A dataframe of cumulative returns of given stock prices.
- finquant.returns.daily_log_returns(data)
Returns DataFrame with daily log returns
\(R_{\log} = \log\left(1 + \dfrac{\text{price}_{t_i} - \text{price}_{t_{i-1}}} {\text{price}_{t_{i-1}}}\right)\)
- Parameters:
data (
DataFrame
) – A dataframe of daily stock prices- Return type:
DataFrame
- Returns:
A dataframe of daily log returns
- finquant.returns.daily_returns(data)
Returns DataFrame with daily returns (percentage change)
\(\displaystyle R = \dfrac{\text{price}_{t_i} - \text{price}_{t_{i-1}}}{\text{price}_{t_{i-1}}}\)
- Parameters:
data (
DataFrame
) – A dataframe of daily stock prices- Return type:
DataFrame
- Returns:
A dataframe of daily percentage change of returns of given stock prices.
- finquant.returns.historical_mean_return(data, freq=252)
Returns the mean return based on historical stock price data.
- Parameters:
data (
SERIES_OR_DATAFRAME
) – A dataframe of daily stock pricesfreq (
INT
, default: 252) – Number of trading days in a year
- Return type:
Series
- Returns:
A series of historical mean returns
- finquant.returns.weighted_mean_daily_returns(data, weights)
Returns DataFrame with the daily weighted mean returns
- Parameters:
data (
DataFrame
) – A dataframe of daily stock pricesweights (
ARRAY_OR_SERIES
) – An array representing weights
- Return type:
ndarray
[Union
[floating
,float
],Any
]- Returns:
An array of weighted mean daily percentage change of Returns