https://github.com/datudar/equity-risk-model
:chart: A fundamental equity risk model that decomposes the risk of a portfolio by factors and individual securities
https://github.com/datudar/equity-risk-model
equities risk-analysis risk-management risk-modelling
Last synced: 6 months ago
JSON representation
:chart: A fundamental equity risk model that decomposes the risk of a portfolio by factors and individual securities
- Host: GitHub
- URL: https://github.com/datudar/equity-risk-model
- Owner: datudar
- License: mit
- Created: 2017-11-11T03:36:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T13:59:54.000Z (about 7 years ago)
- Last Synced: 2024-08-13T07:08:44.005Z (10 months ago)
- Topics: equities, risk-analysis, risk-management, risk-modelling
- Language: Python
- Homepage:
- Size: 50.8 KB
- Stars: 31
- Watchers: 2
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - datudar/equity-risk-model - :chart: A fundamental equity risk model that decomposes the risk of a portfolio by factors and individual securities (Python)
README
## Equity Risk Model
This is a fundamentally-based [equity risk model](/equity_risk_model.py) that performs factor risk decomposition and single stock risk attribution. The model assumes that only three risk factors—Size, Value, Momentum—are relevant and that only ten securities—AAPL, BA, CAT, DIS, EBAY, F, GOOGL, HOG, IBM, JPM—are in our universe.
*Note: This model is a drastic oversimplification of equity risk and is intended purely for instructional purposes only. For the United States market, a more realistic model would typically include several more risk factors and thousands of securities.*
The three factors in this model are:
1. **Size**, which is defined as the natural log of the market capitalization
2. **Value**, which is defined as the trailing 12-month earnings yield
3. **Momentum**, which is defined as price change from 12 months ago to 1 month ago### How It Works
1. Enter the weights of the portfolio and benchmark in their respective CSV files
2. Run the [equity risk model](/equity_risk_model.py)
3. Assign the **portfolio**, **benchmark**, and **active** portfolios as RiskModel objects, **p**, **b**, and **a**, respectively:
```
p = RiskModel(portfolio)
```
```
b = RiskModel(benchmark)
```
```
a = RiskModel(active)
```
4. Calculate a risk measure by executing its method. For example, to calculate the total factor risk of the active portfolio, **a**, execute the following line:```
a.factor_risk_total()
```### Risk Analysis
For the portfolio, benchmark, and active portfolios, the total risk is defined as the square root of the sum of the squared factor risk and squared specific risk. Risk is further decomposed at both the stock-level and factor-level. And, for each level, we calculate the following three risk measures:
- Marginal contribution to risk
- Contribution to risk
- Percent contribution to riskThese measures are available as the following methods:
**Portfolio-level**
| # | Method | Level | Definition |
| :---: | :--- | :--- | :--- |
|1| factor_risk_total | Portfolio | Total factor risk |
|2| specific_risk_total | Portfolio | Total specific risk |
|3| total_risk_total | Portfolio | Total risk |**Stock-level**
| # | Method | Level | Definition |
| :---: | :--- | :--- | :--- |
|1| factor_risk_marginal | Stock | Marginal contribution to factor risk |
|2| specific_risk_marginal | Stock | Marginal contribution to specific risk |
|3| total_risk_marginal | Stock | Marginal contribution to total risk |
|4| factor_risk_contrib | Stock | Contribution to factor risk |
|5| specific_risk_contrib | Stock | Contribution to specific risk |
|6| total_risk_contrib | Stock | Contribution to total risk |
|7| factor_risk_pct_contrib | Stock | Percent contribution to factor risk |
|8| specific_risk_pct_contrib | Stock | Percent contribution to specific risk |
|9| total_risk_pct_contrib | Stock | Percent contribution to total risk |**Factor-level**
| # | Method | Level | Definition |
| :---: | :--- | :--- | :--- |
|1| factor_decomp_marginal | Factor | Marginal contribution to risk |
|2| factor_decomp_contrib | Factor | Contribution to risk |
|3| factor_decomp_pct_contrib | Factor | Percent contribution to risk |### License
This project is licensed under the [MIT License](/LICENSE).