File size: 1,728 Bytes
eb606e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from pydantic import BaseModel, Field
from typing import List, Dict, Optional, Any
from datetime import datetime
from enum import Enum

class InvestmentType(str, Enum):
    LUMP_SUM = "Lump Sum"
    SIP_MONTHLY = "SIP (Monthly)"
    STP = "STP"

class PortfolioHolding(BaseModel):
    scheme_code: str
    category: str
    fund_house: str
    invested_amount: float = Field(gt=0)
    current_value: float = Field(gt=0)
    units: float = Field(gt=0)
    current_nav: float = Field(gt=0)
    investment_type: InvestmentType
    nav_data: List[Any] = []

class Portfolio(BaseModel):
    holdings: Dict[str, PortfolioHolding] = {}

class PortfolioMetrics(BaseModel):
    total_value: float
    total_invested: float
    total_gains: float
    category_allocation: Dict[str, float]

class PortfolioTemplate(str, Enum):
    CONSERVATIVE = "Conservative"
    BALANCED = "Balanced"
    AGGRESSIVE = "Aggressive"
    CUSTOM_SAMPLE = "Custom Sample"

class RebalanceAction(BaseModel):
    category: str
    current_pct: float
    target_pct: float
    difference: float
    amount_change: float
    action: str  # "INCREASE" or "DECREASE"

class RebalanceAnalysis(BaseModel):
    actions: List[RebalanceAction]
    recommended_strategy: str
    target_allocation: Dict[str, float]

class PerformanceReport(BaseModel):
    total_invested: float
    total_value: float
    total_gains: float
    overall_return_pct: float
    fund_performance: List[Dict[str, Any]]
    best_performer: Optional[str] = None
    worst_performer: Optional[str] = None
    max_return: float
    min_return: float
    volatility: float
    sharpe_ratio: float
    portfolio_metrics: PortfolioMetrics