Expected Return, Volatility, Sharpe Ratio

The Expected Return, Volatility and Sharpe Ratio of a portfolio are computed with the module finquant.quants.

The module provides functions to compute quantities relevant to financial portfolios, e.g. a weighted average, which is the expected value/return, a weighted standard deviation (volatility), and the Sharpe ratio.

finquant.quants.annualised_portfolio_quantities(weights, means, cov_matrix, risk_free_rate=0.005, freq=252)

Computes and returns the expected annualised return, volatility and Sharpe Ratio of a portfolio.

Input:
weights:numpy.ndarray/pd.Series of weights
means:numpy.ndarray/pd.Series of mean/average values
cov_matrix:numpy.ndarray/pandas.DataFrame, covariance matrix
risk_free_rate:float (default= 0.005), risk free rate
freq:int (default= 252), number of trading days, default value corresponds to trading days in a year
Output:
(Expected Return, Volatility, Sharpe Ratio):
 tuple of those three quantities
finquant.quants.sharpe_ratio(exp_return, volatility, risk_free_rate=0.005)

Computes the Sharpe Ratio

Input:
exp_return:int/float, Expected Return of a portfolio
volatility:int/float, Volatility of a portfolio
risk_free_rate:int/float (default= 0.005), risk free rate
Output:
sharpe ratio:float (exp_return - risk_free_rate)/float(volatility)
finquant.quants.weighted_mean(means, weights)

Computes the weighted mean/average, or in the case of a financial portfolio, it can be used for the Expected Return of said portfolio.

Input:
means:numpy.ndarray/pd.Series of mean/average values
weights:numpy.ndarray/pd.Series of weights
Output:
weighted mu:numpy.ndarray: (np.sum(means*weights))
finquant.quants.weighted_std(cov_matrix, weights)

Computes the weighted standard deviation, or Volatility of a portfolio, which contains several stocks.

Input:
cov_matrix:numpy.ndarray/pandas.DataFrame, covariance matrix
weights:numpy.ndarray/pd.Series of weights
Output:
weighted sigma:numpy.ndarray: np.sqrt(np.dot(weights.T, np.dot(cov_matrix, weights)))