API Key Configuration¶
TradeTally integrates with several external APIs to provide enhanced features. This guide will help you configure these APIs.
Overview¶
| API | Purpose | Free Tier | Self-Hosted |
|---|---|---|---|
| Finnhub | Real-time quotes, CUSIP resolution, sector analysis | Limited (60 calls/min) | Basic plan required for full features |
| Alpha Vantage | Chart visualization (fallback) | 25 calls/day | Optional |
| OpenFIGI | CUSIP resolution | 25,000/month | Recommended |
| Various AI Providers | AI recommendations | Varies | Optional |
Finnhub API (Required for Full Features)¶
Finnhub provides real-time market data, CUSIP resolution, and sector analysis.
Self-Hosted Requirement
For self-hosted deployments to access all Pro features (real-time quotes, advanced charts, sector analysis), a Finnhub Basic plan is required. The free tier has significant limitations.
Setup¶
- Visit Finnhub.io
- Sign up for an account
- Recommended: Upgrade to Basic plan ($0-20/month depending on needs)
- Generate an API key from your dashboard
- Add to your
.envfile:
Features Enabled¶
- Real-time Stock Quotes: Live market data for open position tracking
- Advanced Chart Data: High-resolution candlestick charts (Basic plan+)
- CUSIP to Ticker Resolution: Symbol search and identification
- Sector Analysis: Industry-based performance breakdown
- Rate Limiting: Built-in rate limiting (varies by plan)
- Free Tier: 60 API calls/minute (limited features)
- Basic Plan: Enhanced limits and features for full TradeTally functionality
Priority in System¶
- Real-time quotes (primary source)
- CUSIP resolution (primary after cache)
- Sector data for analytics
Alpha Vantage API (Optional)¶
Alpha Vantage provides chart visualization for free tier users.
Setup¶
- Visit Alpha Vantage
- Sign up for a free account
- Generate an API key
- Add to your
.envfile:
Features Enabled¶
- Interactive Candlestick Charts: Visual trade analysis
- Historical Market Data: Intraday and daily stock prices
- Trade Performance Overlay: Entry/exit indicators with P&L
- Free Tier: 25 API calls/day, 5 calls/minute
- Smart Caching: Reduces API usage
Note
Pro users get exclusive Finnhub access for charts with no Alpha Vantage fallback
OpenFIGI API (Recommended)¶
OpenFIGI provides reliable CUSIP-to-ticker mapping using Bloomberg's database.
Setup¶
- Visit OpenFIGI
- Sign up for a free account (optional but recommended)
- Generate an API key from your account dashboard
- Add to your
.envfile:
Features Enabled¶
- Reliable CUSIP Resolution: Bloomberg's official mapping service
- High Accuracy: Industry-standard financial data
- Free Tier: 25,000 requests/month without key, unlimited with free account
- Real Financial Data: Actual securities database
- Multiple Asset Types: Stocks, bonds, options, and other securities
Why OpenFIGI?¶
OpenFIGI is the recommended CUSIP resolution method because:
- No AI hallucinations or guessing
- Real-time access to Bloomberg's securities database
- High accuracy for all security types
- Free and reliable
AI Provider Configuration¶
AI features are configured through the web interface (Settings page).
Supported Providers¶
- Anthropic Claude: High-quality analysis and recommendations
- OpenAI: GPT-3.5/GPT-4 for trade analysis
- Google Gemini: Advanced AI with good financial knowledge
- Ollama: Self-hosted local AI models
- Custom API: Bring your own AI provider
Setup¶
- Navigate to Settings in TradeTally
- Go to AI Provider Settings
- Select your preferred provider
- Enter your API key
- Test the connection
Features Enabled¶
- AI-Powered Trading Recommendations: Personalized analysis
- Sector Performance Analysis: Industry-specific insights
- Trading Pattern Analysis: Identify strengths and weaknesses
- Multiple Provider Support: Choose the best AI for your needs
AI CUSIP Resolution
AI CUSIP resolution is disabled by default due to reliability concerns. See the warning section below.
AI CUSIP Resolution (Advanced Users Only)¶
Reliability Warning
AI CUSIP resolution is disabled by default and should only be enabled by advanced users who understand the limitations.
Limitations¶
- Unreliable Results: AI models frequently return incorrect ticker mappings
- Self-Hosted Issues: Local models cannot access real financial databases
- Static LLM Limitations: Training data cutoffs cause issues with recent changes
- Hallucination Risk: AI may guess popular symbols for unknown CUSIPs
- Data Integrity: Incorrect mappings can corrupt your trade data
When AI CUSIP Might Work¶
- Perplexity AI Recommended: Actively searches web for current mappings
- Cloud-based AI only: OpenAI, Anthropic Claude, Google Gemini, Perplexity
- Manual Verification: You verify every AI-resolved CUSIP
- Test Environment: You can afford incorrect data
To Enable AI CUSIP Resolution¶
Recommended Alternative¶
Instead of AI CUSIP resolution, use:
- OpenFIGI API (reliable, free, industry standard) ✓
- Manual mapping through the import interface
- Broker-specific formats that include ticker symbols
CUSIP Resolution Priority¶
The system uses the following priority for CUSIP resolution:
- Cache: Previously resolved mappings (fastest)
- Finnhub: Symbol search API (primary)
- OpenFIGI: Bloomberg's CUSIP-to-ticker API (reliable fallback)
- AI Fallback: Optional, disabled by default
- Manual Entry: User mapping through import interface
Market Data Priority¶
Real-time Quotes¶
- Finnhub API: Primary source for live market data
- Cache: Previously fetched quotes (1-minute cache)
- Fallback: Display without real-time data if unavailable
Chart Data¶
- Pro Users: Finnhub Stock Candles API (150 calls/min, 1-minute precision)
- Free Users: Alpha Vantage API (25 calls/day, limited precision)
- Cache: Previously fetched chart data with intelligent caching
Testing Your Configuration¶
Test Finnhub Connection¶
Test Alpha Vantage Connection¶
curl "https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=AAPL&interval=5min&apikey=YOUR_API_KEY"
Test OpenFIGI Connection¶
curl -X POST "https://api.openfigi.com/v3/mapping" \
-H "Content-Type: application/json" \
-d '[{"idType":"ID_CUSIP","idValue":"037833100"}]'
Rate Limiting¶
All APIs implement rate limiting to prevent quota exhaustion:
- Finnhub: 30 calls/second (built-in)
- Alpha Vantage: 5 calls/minute (enforced)
- OpenFIGI: Reasonable limits (enforced)
- AI Providers: Varies by provider
Troubleshooting¶
API Key Not Working¶
- Verify key is correctly copied (no extra spaces)
- Check API key is in backend
.envfile, not frontend - Restart backend server after adding keys
- Check API provider dashboard for usage limits
CUSIP Resolution Failing¶
- Ensure
FINNHUB_API_KEYandOPENFIGI_API_KEYare set - Check internet connectivity
- Try manual mapping as fallback
- Review console logs for error messages
Real-time Quotes Not Updating¶
- Verify
FINNHUB_API_KEYis set in backend.env - Check backend server is running on port 3000
- Verify frontend is proxying to correct backend
- Confirm ticker symbols are valid (not CUSIPs)
Cost Considerations¶
Free Tier Limits¶
- Finnhub: 60 calls/minute (sufficient for most users)
- Alpha Vantage: 25 calls/day (limited but free)
- OpenFIGI: 25,000/month (very generous)
- AI Providers: Varies (check provider pricing)
Self-Hosted vs SaaS¶
Self-Hosted: - All Pro features included for free - You provide your own API keys - No subscription fees
SaaS (tradetally.io): - API keys provided by platform - Higher rate limits - No setup required - $19.99/month for Pro
Next Steps¶
- Quick Start Guide - Start using TradeTally
- Docker Deployment - Deploy with Docker
- Features Guide - Explore features