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
109 lines
2.5 KiB
Python
109 lines
2.5 KiB
Python
"""
|
|
Pension account Pydantic schemas.
|
|
"""
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import Optional, List
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.schemas.portfolio import FloatDecimal
|
|
|
|
|
|
class AccountType(str, Enum):
|
|
DC = "dc"
|
|
IRP = "irp"
|
|
PERSONAL = "personal"
|
|
|
|
|
|
class AssetRiskType(str, Enum):
|
|
SAFE = "safe"
|
|
RISKY = "risky"
|
|
|
|
|
|
# --- Account schemas ---
|
|
|
|
class PensionAccountCreate(BaseModel):
|
|
account_type: AccountType
|
|
account_name: str = Field(..., min_length=1, max_length=100)
|
|
total_amount: FloatDecimal = Field(..., ge=0)
|
|
birth_year: int = Field(..., ge=1940, le=2010)
|
|
target_retirement_age: int = Field(60, ge=50, le=70)
|
|
|
|
|
|
class PensionAccountUpdate(BaseModel):
|
|
account_name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
total_amount: Optional[FloatDecimal] = Field(None, ge=0)
|
|
target_retirement_age: Optional[int] = Field(None, ge=50, le=70)
|
|
|
|
|
|
class PensionHoldingResponse(BaseModel):
|
|
id: int
|
|
account_id: int
|
|
asset_name: str
|
|
asset_type: str
|
|
amount: FloatDecimal
|
|
ratio: FloatDecimal
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class PensionAccountResponse(BaseModel):
|
|
id: int
|
|
user_id: int
|
|
account_type: str
|
|
account_name: str
|
|
total_amount: FloatDecimal
|
|
birth_year: int
|
|
target_retirement_age: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
holdings: List[PensionHoldingResponse] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# --- Allocation schemas ---
|
|
|
|
class AllocationItem(BaseModel):
|
|
asset_name: str
|
|
asset_type: str # safe / risky
|
|
amount: FloatDecimal
|
|
ratio: FloatDecimal
|
|
|
|
|
|
class AllocationResult(BaseModel):
|
|
account_id: int
|
|
account_type: str
|
|
total_amount: FloatDecimal
|
|
risky_limit_pct: FloatDecimal
|
|
safe_min_pct: FloatDecimal
|
|
glide_path_equity_pct: FloatDecimal
|
|
glide_path_bond_pct: FloatDecimal
|
|
current_age: int
|
|
years_to_retirement: int
|
|
allocations: List[AllocationItem]
|
|
|
|
|
|
# --- Recommendation schemas ---
|
|
|
|
class RecommendationItem(BaseModel):
|
|
asset_name: str
|
|
asset_type: str
|
|
category: str # tdf, bond_etf, equity_etf, deposit
|
|
ratio: FloatDecimal
|
|
reason: str
|
|
|
|
|
|
class RecommendationResult(BaseModel):
|
|
account_id: int
|
|
birth_year: int
|
|
current_age: int
|
|
target_retirement_age: int
|
|
years_to_retirement: int
|
|
glide_path_equity_pct: FloatDecimal
|
|
glide_path_bond_pct: FloatDecimal
|
|
recommendations: List[RecommendationItem]
|