Straight Arrow Strategy Implementation
A clean, focused AI-powered investment analysis system using the proven Straight Arrow strategy (60% VTI, 30% BNDX, 10% GSG).
- Straight Arrow Strategy: Fixed allocation (60% VTI, 30% BNDX, 10% GSG)
- Portfolio Analysis: Drift analysis and rebalancing recommendations
- Real-time Market Data: Alpha Vantage integration with fallback to mock data
- AI Analysis: Educational investment guidance with OpenAI integration
- Database Storage: Portfolio history tracking with Supabase
- Simple API: Clean, focused endpoints
FinAgent Simplified
βββ Straight Arrow Strategy (Fixed Allocation)
βββ Market Data Service (Alpha Vantage + Mock)
βββ AI Service (OpenAI + Mock)
βββ Database (Supabase PostgreSQL)
βββ FastAPI REST API
Python 3.8+
Supabase account (optional)
API Keys: OpenAI, Alpha Vantage (optional)pip install -r requirements_simple.txtexport SUPABASE_URL="your-supabase-url"
export SUPABASE_ANON_KEY="your-supabase-key"
export OPENAI_API_KEY="your-openai-key"
export ALPHA_VANTAGE_API_KEY="your-alpha-vantage-key"# Run in your Supabase SQL editor
cat database_simple.sqlpython main_simplified.py
# Server available at http://localhost:8000
# API docs at http://localhost:8000/docspython test_simple.pyGET /healthPOST /api/analyze-portfolio
{
"portfolio": {
"VTI": 25000,
"BNDX": 20000,
"GSG": 5000
},
"total_value": 50000
}POST /api/market-data
{
"symbols": ["VTI", "BNDX", "GSG"]
}POST /api/agents/data-analyst
{
"query": "What is the Straight Arrow strategy?",
"symbols": ["VTI", "BNDX", "GSG"]
}GET /api/portfolio-historyTarget Allocation:
- 60% VTI - Vanguard Total Stock Market ETF
- 30% BNDX - Vanguard Total International Bond ETF
- 10% GSG - iShares GSCI Commodity-Indexed Trust
Benefits:
- Simple 3-fund portfolio
- Broad diversification
- Low costs
- Easy to rebalance
- Suitable for beginners
# Start server
python main_simplified.py
# Run tests
python test_simple.py
# Check health
curl http://localhost:8000/health# Deploy to Render/Heroku
# Set environment variables
# Update database connectionimport requests
response = requests.post("http://localhost:8000/api/analyze-portfolio", json={
"portfolio": {"VTI": 30000, "BNDX": 15000, "GSG": 5000},
"total_value": 50000
})
analysis = response.json()["analysis"]
print(f"Strategy: {analysis['strategy']}")
print(f"Needs rebalancing: {analysis['risk_assessment']['needs_rebalancing']}")response = requests.post("http://localhost:8000/api/agents/data-analyst", json={
"query": "Should I rebalance my portfolio?",
"symbols": ["VTI", "BNDX", "GSG"]
})
ai_response = response.json()["analysis"]
print(ai_response["analysis"])- Set
ALPHA_VANTAGE_API_KEYfor real market data - Set
OPENAI_API_KEYfor AI analysis - Set
SUPABASE_URLandSUPABASE_ANON_KEYfor database
- System works with mock data
- No external dependencies
- Perfect for testing and development
main_simplified.py- Main applicationrequirements_simple.txt- Dependenciesdatabase_simple.sql- Database schematest_simple.py- Test suiteREADME.md- This file
- Connect GitHub repository
- Set environment variables
- Deploy from
main_simplified.py - Run database schema in Supabase
SUPABASE_URL=your-supabase-url
SUPABASE_ANON_KEY=your-supabase-key
OPENAI_API_KEY=your-openai-key
ALPHA_VANTAGE_API_KEY=your-alpha-vantage-key
PORT=8000
Try the live API:
- Health:
GET https://your-app.onrender.com/health - Docs:
https://your-app.onrender.com/docs
- Fork repository
- Create feature branch
- Make changes
- Test thoroughly
- Submit pull request
MIT License - see LICENSE file
FinAgent Simplified - Clean, focused investment analysis π―