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.