This repository implements a complete 5-step intelligent, modular robo-advising platform built on
LLM-powered agents orchestrated with LangGraph.
The system integrates conversational intent detection, questionnaire-based risk profiling,
portfolio optimization, fund selection, trading execution workflows, and a modern Streamlit web interface.
User
└──> Entry Agent (ChatOpenAI)
├─ natural conversation
├─ manages phase summaries and user intent
├─ routes based on intent flags:
│ ├─ Risk Agent → equity setting OR questionnaire-based guidance
│ ├─ Portfolio Agent → mean-variance optimizer
│ ├─ Investment Agent → fund selection & analysis
│ ├─ Trading Agent → executable trading requests
│ └─ Reviewer Agent → when awaiting final input
↓
├──> Risk Agent (ChatOpenAI + Tool)
│ ├─ handles direct equity setting commands
│ ├─ runs 7 risk-profiling questions (when guidance requested)
│ ├─ produces {"equity": x, "bond": 1-x}
│ └─ writes recommendation to shared state
│
├──> Portfolio Agent (ChatOpenAI + Tool)
│ ├─ reads equity/bond split from risk output
│ ├─ expands into detailed asset-class sleeves via **mean/variance optimization**
│ ├─ allows user edits to λ (risk-aversion) and cash-reserve inputs
│ ├─ outputs an **asset-class portfolio dictionary**
│ └─ routes to Investment Agent for fund selection
│
├──> Investment Agent (ChatOpenAI + Fund Analysis)
│ ├─ selects ETFs/funds for each asset class
│ ├─ provides 4 selection criteria (Balanced, Low Cost, High Performance, Low Risk)
│ ├─ analyzes funds using Yahoo Finance API
│ ├─ allows user review and editing of selections
│ └─ outputs **investment portfolio with tickers**
│
├──> Trading Agent (ChatOpenAI + Rebalancing Engine)
│ ├─ generates executable trading requests
│ ├─ uses demo scenarios for realistic testing
│ ├─ implements tax-aware rebalancing optimization
│ ├─ outputs **simple trading table** (ticker, action, price, shares)
│ └─ provides execution summary
│
└──> Reviewer Agent (ChatOpenAI)
├─ validates completion of all phases
├─ shows final summary when all complete
├─ handles "start over" and "finish" options
├─ routes back to Entry Agent for next phase
└─ manages phase transitions and state updates
| Module | File | Purpose |
|---|---|---|
| Entry | entry_agent.py | Main orchestrator, intent detection, routing |
| Risk | risk/risk_agent.py | Risk profiling questionnaire and guidance |
risk/risk_manager.py | Risk calculation tools and question management | |
| Portfolio | portfolio/portfolio_agent.py | Portfolio optimization conversation |
portfolio/portfolio_manager.py | Mean-variance optimization tools | |
| Investment | investment/investment_agent.py | Fund selection and analysis |
investment/fund_analyzer.py | Yahoo Finance API integration | |
| Trading | trading/trading_agent.py | Trading request generation |
trading/trading_utils.py | Trading utility functions | |
trading/rebalance.py | Tax-aware rebalancing optimization | |
trading/config.py | Configuration and assumptions | |
trading/trading_scenarios.py | Demo trading scenarios | |
| Reviewer | reviewer/reviewer_agent.py | Final review, recommendations, and flow orchestration |
reviewer/reviewer_utils.py | Reviewer utility functions | |
| UI | streamlit_app.py | Modern web interface with real-time visualization |
| Core | state.py | Shared TypedDict state |
app.py | Main LangGraph orchestration |
# Create conda environment conda create -n roboadvisor python=3.11 conda activate roboadvisor # Install dependencies pip install -r requirements.txt
Create a .env file in the project root:
OPENAI_API_KEY=sk-your-key
OPENAI_MODEL=gpt-4o-mini
OPENAI_TEMPERATURE=0.2
streamlit run streamlit_app.py
The app will open in your browser at http://localhost:8501
python app.py
intent_to_risk=Trueintent_to_portfolio=Trueintent_to_investment=Trueintent_to_trading=Truestate["risk"]done=True and awaiting_input=Falseportfolio/config/asset_stats.xlsx| Ticker | Action | Unit Price | Shares |
|--------|--------|------------|--------|
| VUG | BUY | $245.50 | 100 |
| VTV | SELL | $180.25 | 50 |
next_phase field to guide Entry Agent routing┌───────────────────────────────┐
│ User launches conversation │
└──────────────┬────────────────┘
▼
Entry Agent
│ Show welcome & phase summary
│ Orchestrate flow based on intent
▼
User says "proceed"
▼
Entry Agent
│ Sets intent_to_risk=True
│ Routes to Risk Agent
▼
Risk Agent
│ Presents two options:
│ 1) Set equity directly ("set equity to 0.6")
│ 2) Use guidance (7-question questionnaire)
│ User selects option
│ Computes equity/bond allocation
│ Sets done=True, routes to Reviewer
▼
Reviewer Agent
│ Validates risk completion
│ Updates next_phase="portfolio"
│ Routes to Entry Agent
▼
Entry Agent
│ Shows portfolio phase summary
│ User says "proceed"
│ Sets intent_to_portfolio=True
│ Routes to Portfolio Agent
▼
Portfolio Agent
│ Asks λ & cash reserve parameters
│ Runs mean-variance optimization
│ Outputs asset-class portfolio
│ Sets done=True, routes to Reviewer
▼
Reviewer Agent
│ Validates portfolio completion
│ Updates next_phase="investment"
│ Routes to Entry Agent
▼
Entry Agent
│ Shows investment phase summary
│ User says "proceed"
│ Sets intent_to_investment=True
│ Routes to Investment Agent
▼
Investment Agent
│ Presents fund selection criteria
│ Analyzes funds via Yahoo Finance
│ Allows review/edit of selections
│ Outputs investment portfolio
│ Sets done=True when user says "proceed"
│ Routes to Reviewer
▼
Reviewer Agent
│ Validates investment completion
│ Updates next_phase="trading"
│ Routes to Entry Agent
▼
Entry Agent
│ Shows trading phase summary
│ User says "proceed"
│ Sets intent_to_trading=True
│ Routes to Trading Agent
▼
Trading Agent
│ Shows demo scenarios
│ User selects scenario
│ Generates trading requests
│ Outputs trading table
│ Sets done=True, routes to Reviewer
▼
Reviewer Agent
│ Validates all phases complete
│ Shows final summary with options:
│ • "start over" → Reset & restart
│ • "finish" → Complete session
▼
(Ready for execution)
AI (Entry): Welcome! Let's start with risk assessment...
User: proceed
AI (Risk): Choose: 1) Set equity directly (e.g., "set equity to 0.6") or 2) Use guidance (questionnaire)
User: use guidance
AI (Risk): [Shows 7-question questionnaire]
User: [Answers questions]
AI (Risk): Your allocation: 60% equity / 40% bonds
User: proceed
(Risk Agent routes to Reviewer, then Entry shows portfolio summary)
AI (Entry): Portfolio Construction phase...
User: proceed
AI (Portfolio): Defaults λ = 1.0, cash = 0.05...
User: set lambda to 1 and cash to 0.03 run
AI (Portfolio): [Optimization results]
| Asset Class | Weight |
|---|---|
| Mid-term Treasury | 29.72% |
| TIPS | 29.72% |
| Corporate Bond | 22.56% |
| Emerging Market Equity | 11.00% |
| Cash | 3.00% |
| Large Cap Value | 1.90% |
| Small Cap Growth | 1.32% |
| Total | 100% |
User: proceed
(Entry shows investment summary, then routes to Investment Agent)
AI (Investment): Choose fund selection criteria: Balanced, Low Cost, High Performance, or Low Risk
User: balanced
(Fund analysis and selection)
| Asset Class | Weight | Ticker | Selection Reason |
|---|---|---|---|
| Mid-term Treasury | 29.72% | VGIT | Low cost index fund |
| TIPS | 29.72% | VTEB | Diversified bond exposure |
| Corporate Bond | 22.56% | VCIT | Best Sharpe ratio |
| Emerging Market Equity | 11.00% | VWO | Emerging market exposure |
| Cash | 3.00% | sweep_cash | Sweep Account |
User: proceed
(Entry shows trading summary, then routes to Trading Agent)
AI (Trading): Select a demo scenario (1-6)...
User: 1
(Trading requests generated)
| Ticker | Action | Unit Price | Shares |
|---|---|---|---|
| VGIT | BUY | $50.35 | 100 |
| VTEB | BUY | $45.20 | 150 |
| VCIT | SELL | $48.75 | 50 |
Total Trades: 3
Buy Orders: 2
Sell Orders: 1
Net Cash Flow: $15,000
User: proceed
(Reviewer validates all phases and shows final summary)
AI (Reviewer): Portfolio Planning Complete! Your plan is ready.
Options: Start over | Finish
User: finish
AI (Reviewer): Thank you for using our robo-advisor!
| Phase | Status | Description |
|---|---|---|
| ✅ Step 1 – Risk Onboarding | Complete | Risk-profiling and allocation summary finished |
| ✅ Step 2 – Portfolio Agent | Complete | Asset-class optimizer with mean-variance optimization |
| ✅ Step 3 – Investment Agent | Complete | Fund selection with Yahoo Finance analysis |
| ✅ Step 4 – Trading Agent | Complete | Tax-aware rebalancing with demo scenarios |
| ✅ Step 5 – Reviewer Agent | Complete | Central orchestrator and flow management |
| ✅ Step 6 – Streamlit UI | Complete | Modern web interface with real-time visualization |
| 🚀 Step 7 – Production Ready | Vision | Real market data, custodian integration, monitoring |
trading/config.py) with all assumptions and parametersapp.py| Category | Asset Classes |
|---|---|
| Equity | Large Cap Growth, Large Cap Value, Small Cap Growth, Small Cap Value, Emerging Market Equity, Developed Market Equity |
| Fixed Income | Mid-term Treasury, Long-term Treasury, Short-term Treasury, TIPS, Corporate Bond |
| Cash | Sweep Account (for trading reserve) |
The repository includes comprehensive testing coverage:
Test core functions independently:
# Run all unit tests python test/unittesting/test_suite.py # Run individual unit tests python test/unittesting/test_risk_manager.py python test/unittesting/test_portfolio_manager.py python test/unittesting/test_fund_analyzer.py python test/unittesting/test_rebalancer.py
Test end-to-end user flows:
# Run all user flow tests python test/userflowtesting/test_suite.py # Run individual tests python test/userflowtesting/test_comprehensive_risk_flow.py python test/userflowtesting/test_portfolio_to_investment.py python test/userflowtesting/test_simple_completion.py python test/userflowtesting/test_start_over.py python test/userflowtesting/test_trading_completion.py
Test Coverage:
This robo-advisor represents a complete end-to-end wealth management solution, from risk assessment to trade execution, built with modern AI, optimization techniques, and a beautiful web interface.