Phase 1: - Real-time signal alerts (Discord/Telegram webhook) - Trading journal with entry/exit tracking - Position sizing calculator (Fixed/Kelly/ATR) Phase 2: - Pension asset allocation (DC/IRP 70% risk limit) - Drawdown monitoring with SVG gauge - Benchmark dashboard (portfolio vs KOSPI vs deposit) Phase 3: - Tax benefit simulation (Korean pension tax rules) - Correlation matrix heatmap - Parameter optimizer with grid search + overfit detection
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
"""
|
|
Benchmark comparison schemas.
|
|
"""
|
|
import enum
|
|
from datetime import date
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class BenchmarkType(str, enum.Enum):
|
|
KOSPI = "kospi"
|
|
DEPOSIT = "deposit"
|
|
|
|
|
|
class PeriodType(str, enum.Enum):
|
|
ONE_MONTH = "1m"
|
|
THREE_MONTHS = "3m"
|
|
SIX_MONTHS = "6m"
|
|
ONE_YEAR = "1y"
|
|
ALL = "all"
|
|
|
|
|
|
class BenchmarkIndexInfo(BaseModel):
|
|
code: str
|
|
name: str
|
|
description: str
|
|
|
|
|
|
class TimeSeriesPoint(BaseModel):
|
|
date: date
|
|
portfolio_return: Optional[float] = None
|
|
benchmark_return: Optional[float] = None
|
|
deposit_return: Optional[float] = None
|
|
|
|
|
|
class PerformanceMetrics(BaseModel):
|
|
cumulative_return: float = Field(..., description="누적 수익률 (%)")
|
|
annualized_return: float = Field(..., description="연환산 수익률 (%)")
|
|
sharpe_ratio: Optional[float] = Field(None, description="샤프 비율")
|
|
max_drawdown: float = Field(..., description="최대 낙폭 (%)")
|
|
|
|
|
|
class BenchmarkCompareResponse(BaseModel):
|
|
portfolio_name: str
|
|
benchmark_type: str
|
|
period: str
|
|
start_date: date
|
|
end_date: date
|
|
time_series: List[TimeSeriesPoint]
|
|
portfolio_metrics: PerformanceMetrics
|
|
benchmark_metrics: PerformanceMetrics
|
|
deposit_metrics: PerformanceMetrics
|
|
alpha: float = Field(..., description="초과 수익률 (포트폴리오 - 벤치마크) (%)")
|
|
information_ratio: Optional[float] = Field(None, description="정보 비율")
|