System Requirements
Before installing OptionStrat AI, ensure your system meets these requirements:Backend Requirements
- Python: Version 3.8 or higher
- pip: Python package manager
- Operating System: Windows, macOS, or Linux
- RAM: Minimum 4GB (8GB recommended for large option chains)
- Storage: ~500MB for dependencies
Frontend Requirements
- Node.js: Version 16 or higher
- npm: Version 7 or higher (comes with Node.js)
- Modern Browser: Chrome, Firefox, Safari, or Edge (latest version)
API Requirements
- OpenAI API Key: Required for AI Insights feature (optional for other features)
- Internet Connection: Required for fetching real-time market data from Yahoo Finance
You can verify your Python and Node.js versions:
Backend Installation
Create Virtual Environment
Creating a virtual environment isolates your Python dependencies:You’ll see
(venv) in your terminal prompt when activated.Install Python Dependencies
With the virtual environment activated, install all required packages:This installs all dependencies including:
- FastAPI - Async web framework
- Uvicorn - ASGI server
- Pydantic - Data validation
- NumPy & Pandas - Numerical computing
- SciPy - Black-Scholes calculations
- yfinance & yahooquery - Market data
- LiteLLM - LLM router (OpenAI/OpenRouter)
- VaderSentiment - News sentiment analysis
- BeautifulSoup4 - Web scraping
The installation may take 2-5 minutes depending on your internet speed.
Configure Environment Variables
Create a Edit the
.env file in the backend directory:.env file with your preferred text editor and configure your API keys:.env
Getting an OpenAI API Key
- Visit OpenAI Platform
- Sign up or log in to your account
- Navigate to API Keys section
- Click Create new secret key
- Copy the key and paste it in your
.envfile
Frontend Installation
Navigate to Frontend Directory
Open a new terminal window (keep the backend running) and navigate to the frontend folder:
Install Node Dependencies
Install all required npm packages:This installs:
- React 19 - UI framework
- Vite - Fast build tool and dev server
- Zustand - State management
- Axios - HTTP client for API calls
- Recharts - Data visualization
- Lucide React - Icon library
The installation typically takes 1-3 minutes. You’ll see a
node_modules/ folder created with all dependencies.Configure API Endpoint (Optional)
The frontend is pre-configured to connect to
http://127.0.0.1:8000/api. If you need to change this, edit src/api/client.js:src/api/client.js
Start Development Server
Launch the Vite development server:You should see:Open your browser to the URL shown (typically
http://localhost:5173/).Complete Setup Verification
With both backend and frontend running, verify the complete integration:Load a Ticker
- In your browser at
http://localhost:5173/ - Type
AAPLin the search box - Press Enter
- The current AAPL spot price appear in the header
- Available expiration dates load in the dropdown
- The option chain table populates with calls and puts
Test AI Insights
If you configured your OpenAI API key:
- Build a simple strategy (e.g., buy a call)
- Click “Analizar con IA” in the AI Insights panel
- You should see the AI analysis appear with risk score and recommendations
If the AI Insights don’t work, verify your
OPENAI_API_KEY is correctly set in the .env file and the backend has been restarted.Environment Variables Reference
Here’s a complete reference of all available environment variables:| Variable | Required | Default | Description |
|---|---|---|---|
AI_PROVIDER | No | openai | AI provider to use (openai or openrouter) |
OPENAI_API_KEY | Yes* | - | Your OpenAI API key for AI insights |
OPENAI_DEFAULT_CHAT_MODEL | No | gpt-4o | OpenAI model to use for analysis |
OPENROUTER_API_KEY | Yes** | - | Your OpenRouter API key (if using OpenRouter) |
DEFAULT_CHAT_MODEL | No | openrouter/free | OpenRouter model selection |
AI_PROVIDER=openai**Required only if
AI_PROVIDER=openrouter
Troubleshooting
Backend Issues
ModuleNotFoundError: No module named 'fastapi'
ModuleNotFoundError: No module named 'fastapi'
Problem: Dependencies not installed or wrong Python environmentSolution:
Port 8000 is already in use
Port 8000 is already in use
Problem: Another application is using port 8000Solution:Update the frontend
src/api/client.js baseURL to match the new port.OpenAI API Error: Invalid API Key
OpenAI API Error: Invalid API Key
Problem: API key is incorrect or not properly setSolution:
- Verify your
.envfile exists in thebackend/directory - Check the API key format (starts with
sk-) - Ensure no extra spaces or quotes around the key
- Restart the backend server after editing
.env
Yahoo Finance data not loading
Yahoo Finance data not loading
Problem: Network issues or Yahoo Finance rate limitingSolution:
- Check your internet connection
- Try a different ticker symbol
- Wait a few minutes if rate-limited
- Verify yfinance is installed:
pip show yfinance
'venv' is not recognized (Windows)
'venv' is not recognized (Windows)
Problem: Virtual environment not created properlySolution:
Frontend Issues
npm ERR! code ENOENT
npm ERR! code ENOENT
Problem: npm not installed or not in PATHSolution:
- Install Node.js from nodejs.org
- Restart your terminal
- Verify installation:
node --version && npm --version
Port 5173 is already in use
Port 5173 is already in use
Problem: Another Vite dev server is runningSolution:
Cannot connect to backend / Network Error
Cannot connect to backend / Network Error
Problem: Backend not running or CORS issueSolution:
- Verify backend is running:
curl http://127.0.0.1:8000/ - Check the frontend is using correct API URL in
src/api/client.js - Verify no firewall is blocking connections
- Check browser console (F12) for detailed error messages
npm install fails with EACCES
npm install fails with EACCES
Problem: Permission issues on macOS/LinuxSolution:
React components not rendering
React components not rendering
Problem: Build or dependency issueSolution:
Data and API Issues
Option chain returns empty data
Option chain returns empty data
Problem: No options available for selected ticker/expirationSolution:
- Try a more liquid ticker (AAPL, SPY, TSLA)
- Select a different expiration date
- Some stocks don’t have listed options
- Check if market is open (data updates during trading hours)
Greeks calculation errors
Greeks calculation errors
Problem: Invalid inputs for Black-Scholes modelSolution:
The system handles this automatically, but if you see issues:
- Check that implied volatility > 0
- Verify expiration date is in the future
- Ensure strike prices are valid numbers
AI Insights not appearing
AI Insights not appearing
Problem: OpenAI API key not configured or quota exceededSolution:
- Verify
.envfile has validOPENAI_API_KEY - Check OpenAI account has available credits
- View backend logs for detailed error messages
- Try using
gpt-3.5-turbomodel for lower costs
Production Deployment
For deploying OptionStrat AI to production:Backend Production
Frontend Production
For production deployment, consider using Docker, AWS, Heroku, or Vercel for easy scaling and management.
Performance Optimization
Backend Performance
- Caching: Implement Redis for caching option chains and market data
- Database: Add PostgreSQL for storing historical strategies and user data
- Rate Limiting: Add rate limiting to prevent API abuse
- Async Processing: Use Celery for long-running calculations
Frontend Performance
- Code Splitting: Vite handles this automatically
- Lazy Loading: Components load on demand
- Debouncing: Already implemented in Zustand store for API calls
- CDN: Serve static assets from a CDN in production
Next Steps
Quickstart Guide
Build your first strategy in 5 minutes
API Reference
Explore all available endpoints
Architecture
Understand the system design
Core Features
Explore the platform’s powerful features
Additional Resources
- FastAPI Docs: fastapi.tiangolo.com
- React Docs: react.dev
- Vite Docs: vitejs.dev
- Options Trading Basics: Understanding Greeks, spreads, and risk management