Risk
Classes
RiskInputs
Bases: BaseModel
Input object for risk calculations.
Returns:
Type | Description |
---|---|
RiskInputs
|
Risk inputs parameters |
Raises:
Type | Description |
---|---|
ValueError
|
If any of the input parameters are invalid |
VaRAnalyzer
Class to perform a backtest for Value at Risk (VaR) calculations with non-overlapping windows
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs
|
RiskInputs
|
Object containing the following option parameters: - confidence_level : float The confidence level for the VaR calculation. - lookback_period : int The number of historical days for risk estimation. - num_simulations : int The number of Monte Carlo simulations. - portfolio_returns : pd.DataFrame Historical returns of portfolio assets or single stock. - is_single_stock : bool Flag to indicate single stock calculation. - portfolio_weights : list of float, optional Weights of assets in the portfolio (None for single stock). |
required |
window_volatility
|
int
|
The window size for the rolling volatility calculation, by default 21 |
21
|
window_forward
|
int
|
The window size for the rolling forward calculation, by default 10 |
10
|
Attributes:
Name | Type | Description |
---|---|---|
run |
str
|
The run attribute contains the results of the VaR backtest. |
VaRMetrics
Class to calculate various Value at Risk (VaR) metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs
|
RiskInputs
|
Object containing the following option parameters: - confidence_level : float The confidence level for the VaR calculation. - lookback_period : int The number of historical days for risk estimation. - num_simulations : int The number of Monte Carlo simulations. - portfolio_returns : pd.DataFrame Historical returns of portfolio assets or single stock. - is_single_stock : bool Flag to indicate single stock calculation. - portfolio_weights : list of float, optional Weights of assets in the portfolio (None for single stock). |
required |
Attributes:
Name | Type | Description |
---|---|---|
parametric_var |
float
|
The parametric VaR value. |
historical_var |
float
|
The historical VaR value. |
monte_carlo_var |
float
|
The Monte Carlo VaR value. |
expected_shortfall |
float
|
The expected shortfall value. |