This repository has been archived on 2025-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
SightRay_Legacy/risk_manage_engine/risk_calculator_concept.txt
2025-05-06 21:23:04 +09:00

95 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 🧮 리스크 통합 계산기 (`risk_calculator.py`) 개념 정리
---
## ✅ 목적
`risk_calculator.py`는 SightRay의 리스크 관리 엔진 내에서
**VaR, SVaR, Monte Carlo, ATR 등 여러 리스크 지표를 하나의 함수로 통합 계산**하는 모듈입니다.
> 📌 각 지표는 별도의 모듈로 계산되며, 이 파일은 해당 지표들을 조합해서 일괄 계산하는 "통합 계산기" 역할을 수행합니다.
---
## 📦 포함 지표 목록
| 지표 | 설명 | 파일명 |
|------|------|--------|
| **VaR** | Value at Risk 통계 기반 손실 한계 추정 | `var.py` |
| **SVaR** | Stressed VaR 스트레스 구간 기반 VaR | `svar.py` |
| **MCS** | Monte Carlo Simulation 시뮬레이션 기반 손실 예측 | `monte_carlo.py` |
| **ATR** | Average True Range 기술적 변동성 지표 | `atr.py` |
---
## 🧠 내부 구조
```python
from var import calculate_var
from svar import calculate_svar
from monte_carlo import monte_carlo_var
from atr import calculate_atr
def calculate_all_risks(df):
return {
'var': calculate_var(df),
'svar': calculate_svar(df),
'mcs': monte_carlo_var(df),
'atr': calculate_atr(df)
}
```
---
## 🔁 작동 흐름
```plaintext
[단일 종목의 CDS 입력 (DataFrame)]
calculate_var(df)
calculate_svar(df)
monte_carlo_var(df)
calculate_atr(df)
통합된 dict 형태로 반환
```
---
## 📊 출력 예시
```python
{
'var': 0.0312,
'svar': 0.0443,
'mcs': 0.0375,
'atr': 2.91
}
```
- **각 값은 비율 또는 포인트 단위의 손실 위험을 의미**하며,
- 이후 `risk_score` 산출 모듈에서 가중치 등을 통해 통합 점수로 변환됩니다.
---
## ✅ SightRay에서의 역할
| 기능 | 설명 |
|------|------|
| 지표 통합 | 분석된 종목 하나에 대해 리스크 지표를 일괄 계산 |
| 스코어 입력 | `risk_scorer.py`에서 사용할 기초 입력 값 제공 |
| 확장성 확보 | 새로운 지표를 추가해도 이 모듈에서 간단히 조정 가능 |
---
## 🚀 다음 단계와 연계
- 다음 파일인 `risk_scorer.py`에서 `calculate_all_risks()` 결과를 받아
종합 리스크 점수(`risk_score`)를 계산하게 됩니다.
---
## ✅ 요약
- `risk_calculator.py`는 **지표 계산을 하나의 인터페이스로 통합**해주는 모듈
- 향후 리스크 엔진 전체의 모듈화와 유지보수 효율성을 높이는 **핵심 연결 지점**입니다