Common issues and solutions for QuantumVest.
Symptom:
ModuleNotFoundError: No module named 'flask'
Solution:
# Ensure virtual environment is activated
cd code/backend
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Reinstall requirements
pip install -r requirements.txtSymptom:
OSError: [Errno 48] Address already in use
Solution:
# Find process using port
lsof -i :5000 # Mac/Linux
netstat -ano | findstr :5000 # Windows
# Kill process
kill -9 PID # Mac/Linux
taskkill /PID PID /F # Windows
# Or use different port
FLASK_PORT=8000 python app.pySymptom:
sqlalchemy.exc.OperationalError: could not connect to server
Solution:
# Check PostgreSQL is running
sudo systemctl status postgresql # Linux
brew services list | grep postgresql # Mac
# Start PostgreSQL
sudo systemctl start postgresql # Linux
brew services start postgresql # Mac
# Verify connection string
echo $DATABASE_URL
# Test connection
psql -U quantumvest -d quantumvest -h localhostSymptom:
{
"success": false,
"error": "Token has expired"
}Solution:
# Use refresh token to get new access token
response = requests.post(
'http://localhost:5000/api/v1/auth/refresh',
json={'refresh_token': refresh_token}
)
new_access_token = response.json()['access_token']Symptom:
ImportError: attempted relative import with no known parent package
Solution:
# Run from correct directory
cd code/backend
# Use module syntax
python -m data_pipeline.data_fetcher
# Or add to PYTHONPATH
export PYTHONPATH="${PYTHONPATH}:$(pwd)"Symptom:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
Solution:
# Clear npm cache
npm cache clean --force
# Use legacy peer deps
npm install --legacy-peer-deps
# Or delete node_modules and retry
rm -rf node_modules package-lock.json
npm installSymptom:
Access to XMLHttpRequest blocked by CORS policy
Solution:
In backend .env:
CORS_ORIGINS=http://localhost:3000,http://localhost:8080Or for development:
CORS_ORIGINS=*Symptom:
alembic.util.exc.CommandError: Target database is not up to date
Solution:
cd code/backend
# Check current version
flask db current
# Apply all migrations
flask db upgrade
# If conflicts persist, reset migrations
flask db downgrade base
flask db upgradeSymptom:
psycopg2.OperationalError: database is locked
Solution:
# Check for hanging connections
SELECT * FROM pg_stat_activity WHERE datname='quantumvest';
# Kill hanging connections
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='quantumvest' AND pid <> pg_backend_pid();
# Restart PostgreSQL
sudo systemctl restart postgresqlSymptom:
{
"success": false,
"error": "Rate limit exceeded"
}Solution:
- Wait for rate limit reset (check
X-RateLimit-Resetheader) - Upgrade to higher tier
- Implement exponential backoff:
import time
def api_call_with_retry(url, max_retries=3):
for attempt in range(max_retries):
response = requests.get(url)
if response.status_code == 429:
wait_time = 2 ** attempt
time.sleep(wait_time)
continue
return response
raise Exception("Max retries exceeded")Symptom:
Unable to fetch data from Alpha Vantage API
Solution:
# Verify API key is set
echo $ALPHA_VANTAGE_API_KEY
# Test API key
curl "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=AAPL&apikey=$ALPHA_VANTAGE_API_KEY"
# Check rate limits (Alpha Vantage free tier: 5 calls/minute)Symptom: API calls taking > 5 seconds
Solutions:
- Check Redis cache:
redis-cli ping
redis-cli INFO stats- Enable query logging:
# In config.py
SQLALCHEMY_ECHO = True- Add database indexes:
CREATE INDEX idx_portfolios_user_id ON portfolios(user_id);
CREATE INDEX idx_assets_symbol ON assets(symbol);- Optimize queries:
# Use eager loading
query = Portfolio.query.options(
joinedload(Portfolio.positions)
).filter_by(user_id=user_id)Symptom:
MemoryError: Unable to allocate array
Solutions:
- Process data in chunks:
# Instead of loading all data at once
chunk_size = 1000
for chunk in pd.read_csv('data.csv', chunksize=chunk_size):
process(chunk)- Increase worker memory:
# Gunicorn
gunicorn --workers 2 --worker-class gevent --timeout 120 app:app- Use connection pooling:
# In config.py
SQLALCHEMY_POOL_SIZE = 10
SQLALCHEMY_MAX_OVERFLOW = 20Backend:
FLASK_ENV=development
DEBUG=True
LOG_LEVEL=DEBUGCheck logs:
# Application logs
tail -f /var/log/quantumvest/app.log
# PostgreSQL logs
tail -f /var/log/postgresql/postgresql-14-main.log
# Redis logs
tail -f /var/log/redis/redis-server.logUse verbose curl:
curl -v http://localhost:5000/api/v1/healthUse httpie:
http -v GET localhost:5000/api/v1/portfolios "Authorization: Bearer TOKEN"If issues persist:
- Check logs in
/var/log/quantumvest/ - Search issues on GitHub
- Open new issue with:
- System information
- Error messages
- Steps to reproduce
- Log excerpts
For more information: