File size: 3,478 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from fastapi import APIRouter, Depends, HTTPException
from app.services.ai_swarm import AISwarmService
from app.models.ai_models import (
    AIAnalysisRequest, AIAnalysisResponse,
    AnalysisFocus, MarketView, InvestmentHorizon
)

router = APIRouter()

@router.post("/analyze", response_model=AIAnalysisResponse)
async def get_ai_recommendations(request: AIAnalysisRequest):
    """

    Get AI-powered investment recommendations based on client profile, portfolio, and goals

    """
    try:
        ai_service = AISwarmService()
        result = ai_service.get_enhanced_analysis(request)
        return result
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Error generating AI recommendations: {str(e)}")

@router.post("/fund-selection")
async def get_fund_selection_recommendations(

    client_profile: dict,

    goals_data: dict,

    market_conditions: MarketView = MarketView.NEUTRAL,

    investment_horizon: InvestmentHorizon = InvestmentHorizon.MEDIUM_TERM

):
    """

    Get AI-powered fund selection recommendations

    """
    try:
        ai_service = AISwarmService()
        
        request = AIAnalysisRequest(
            client_profile=client_profile,
            portfolio_data={},
            goals_data=goals_data,
            analysis_focus=[AnalysisFocus.FUND_SELECTION],
            market_conditions=market_conditions,
            investment_horizon=investment_horizon
        )
        
        result = ai_service.get_enhanced_analysis(request)
        return result
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Error generating fund selection recommendations: {str(e)}")

@router.post("/risk-assessment")
async def get_risk_assessment(

    client_profile: dict,

    portfolio_data: dict,

    market_conditions: MarketView = MarketView.NEUTRAL

):
    """

    Get AI-powered risk assessment for a portfolio

    """
    try:
        ai_service = AISwarmService()
        
        request = AIAnalysisRequest(
            client_profile=client_profile,
            portfolio_data=portfolio_data,
            goals_data={},
            analysis_focus=[AnalysisFocus.RISK_ASSESSMENT],
            market_conditions=market_conditions,
            investment_horizon=InvestmentHorizon.MEDIUM_TERM
        )
        
        result = ai_service.get_enhanced_analysis(request)
        return result
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Error generating risk assessment: {str(e)}")

@router.post("/goal-planning")
async def get_goal_planning_recommendations(

    client_profile: dict,

    goals_data: dict,

    investment_horizon: InvestmentHorizon = InvestmentHorizon.MEDIUM_TERM

):
    """

    Get AI-powered goal planning recommendations

    """
    try:
        ai_service = AISwarmService()
        
        request = AIAnalysisRequest(
            client_profile=client_profile,
            portfolio_data={},
            goals_data=goals_data,
            analysis_focus=[AnalysisFocus.GOAL_ALIGNMENT],
            market_conditions=MarketView.NEUTRAL,
            investment_horizon=investment_horizon
        )
        
        result = ai_service.get_enhanced_analysis(request)
        return result
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Error generating goal planning recommendations: {str(e)}")