AI-powered cryptocurrency analysis and trading advisor with intelligent data management, technical indicators, and machine learning predictions.
- Smart Data Refresh: Intelligent incremental updates that fetch only new data, preventing duplicates
- Real-time Tracking: Monitor top 5 cryptocurrencies (BTC, ETH, BNB, XRP, ADA)
- Technical Analysis: Calculate moving averages, RSI, MACD, Bollinger Bands
- ML Predictions: Random Forest model for BUY/SELL/HOLD signals
- Interactive Dashboard: Beautiful Streamlit interface with 4 pages
- Portfolio Simulator: Test investment strategies and allocation
- Automated Gap Filling: Automatically identifies and fills missing data
- Comprehensive Logging: Track all operations for debugging
- Python 3.8+
- pip
- Clone the repository
git clone https://github.com/djfrancesco/crypto-advisor-tool.git
cd crypto-advisor-tool- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Configure environment (optional)
cp .env.example .env
# Edit .env with your settings- Initialize database and load historical data
# Initialize database
python -c "from database.db_manager import initialize_database; initialize_database()"
# Load hourly data from Binance (RECOMMENDED - ~2 min for 90 days)
python load_hourly_data.py 90
# Alternative: Daily data from CSV (faster but less granular)
python -m data_collector.bulk_loader --load-all --days 365 --interval d- Run the dashboard
streamlit run app.pyThe dashboard will open at http://localhost:8501
crypto-advisor-tool/
βββ database/
β βββ __init__.py
β βββ schemas.sql # Database schema
β βββ db_manager.py # Database operations
βββ data_collector/
β βββ __init__.py
β βββ api_client.py # CoinGecko API wrapper
β βββ data_refresher.py # Smart refresh logic β
βββ analysis/
β βββ __init__.py
β βββ technical_indicators.py # Technical analysis
β βββ ml_predictor.py # Machine learning
βββ utils/
β βββ __init__.py
β βββ helpers.py # Utility functions
βββ tests/
β βββ __init__.py
β βββ test_database.py # Test suite
βββ models/ # ML models (generated)
βββ app.py # Streamlit dashboard
βββ config.py # Configuration
βββ requirements.txt
βββ .env.example
βββ .gitignore
βββ README.md
- Real-time prices for all tracked cryptocurrencies
- 24-hour price changes
- ML trading signals with confidence scores
- Mini sparkline charts
- Quick refresh button
- Interactive price charts with technical indicators
- Moving averages (7-day and 30-day)
- Bollinger Bands
- RSI (Relative Strength Index)
- MACD (Moving Average Convergence Divergence)
- Trading volume charts
- Historical ML predictions
- Input investment amount
- Allocate percentages to each cryptocurrency
- View predicted returns based on ML signals
- Visualize allocation with pie chart
- Calculate risk metrics
- Manual data refresh for all cryptocurrencies
- Retrain ML models
- View database statistics
- Export data to CSV
- Clear caches
The tool supports multiple data sources for maximum flexibility:
# Load 90 days of hourly data (~2 minutes for 10,800 records)
python load_hourly_data.py 90
# Customize days
python load_hourly_data.py 30 # Last 30 days- Granularity: Hourly (24 records per day)
- Source: Binance exchange API
- Speed: ~2 minutes for 90 days Γ 5 coins
- Rate Limit: 1200 req/min
- Best for: Detailed analysis and ML predictions
# Load 1 year of daily data in ~20 seconds
python -m data_collector.bulk_loader --load-all --days 365 --interval d
# Load specific coin
python -m data_collector.bulk_loader --coin bitcoin --days 90 --interval d- Granularity: Daily (1 record per day)
- Source: CryptoDataDownload.com
- Speed: Instant bulk downloads (no rate limits)
- Best for: Quick setup, long-term trends
- Rate Limit: 1200 requests/minute (48x better than CoinGecko)
- Data: Direct from Binance exchange
- Best for: Ongoing incremental updates
- Configured via
DATA_SOURCE="binance"in config.py (default)
- Rate Limit: 25-30 requests/minute (free tier)
- Data: Aggregated from multiple sources
- Best for: Backup/fallback option
- Configure via
DATA_SOURCE="coingecko"in config.py
Set DATA_SOURCE="auto" to try Binance first, fallback to CoinGecko on failure.
# Initialize database
from database.db_manager import initialize_database
initialize_database()
# Bulk load historical data (fast!)
from data_collector.bulk_loader import BulkDataLoader
loader = BulkDataLoader()
loader.load_all(limit_days=365)
# Refresh data for all cryptocurrencies (uses configured source)
from data_collector.data_refresher import get_refresher
refresher = get_refresher()
results = refresher.refresh_all()
# Calculate technical indicators
from analysis.technical_indicators import get_analyzer
analyzer = get_analyzer()
analyzer.batch_calculate_all()
# Generate ML predictions
from analysis.ml_predictor import get_predictor
predictor = get_predictor()
predictions = predictor.batch_predict_all()The Smart Refresh is the heart of this system. It ensures data integrity while minimizing API calls:
- First Run: Fetches 365 days of historical data
- Subsequent Runs: Fetches ONLY new data since last update
- Gap Detection: Automatically identifies missing data periods
- Gap Filling: Fetches data to fill any gaps
- Duplicate Prevention: Database constraints prevent duplicate entries
- Operation Logging: All operations logged for debugging
- β Never fetches data that already exists
- β Automatically fills gaps from connection losses
- β Respects API rate limits
- β Handles timezone conversions properly
- β Validates all incoming data
- β Provides detailed logging
- Moving Averages: Short-term (7-day) and long-term (30-day)
- RSI: Relative Strength Index (14-day period)
- MACD: Moving Average Convergence Divergence
- Bollinger Bands: Volatility bands
- Support/Resistance: Price levels identification
Each indicator generates signals:
- BULLISH: Suggests buying opportunity
- BEARISH: Suggests selling opportunity
- NEUTRAL: No strong signal
- Algorithm: Random Forest Classifier
- Features: Price changes, technical indicators, volume patterns
- Labels: BUY (0), HOLD (1), SELL (2)
- Training: 80% train, 20% test split
- Validation: 5-fold cross-validation
- Feature Engineering: Extract 15+ features from price data
- Model Training: Train Random Forest on historical data
- Prediction: Generate signal for next 3 days
- Confidence: Probability score for the prediction
- Storage: Save prediction to database
- Target accuracy: >60%
- Includes precision, recall, and F1 scores
- Cross-validation for robustness
- Retrainable with latest data
Edit config.py or use environment variables:
# API Configuration
COINGECKO_API_KEY = "" # Optional for free tier
# Data Refresh
REFRESH_INTERVAL_MINUTES = 15
INITIAL_HISTORY_DAYS = 365
# Technical Indicators
TECHNICAL_INDICATORS = {
"moving_averages": {"short_period": 7, "long_period": 30},
"rsi": {"period": 14},
"macd": {"fast_period": 12, "slow_period": 26, "signal_period": 9},
}
# Machine Learning
ML_CONFIG = {
"prediction_days": 3,
"training_window_days": 90,
"n_estimators": 100,
"max_depth": 10,
}Run the test suite:
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=html
# Run specific test
pytest tests/test_database.py- cryptocurrencies: Metadata for tracked coins
- price_history: Historical price data (with duplicate prevention)
- technical_indicators: Calculated indicators
- predictions: ML predictions and signals
- refresh_log: Operation tracking
- data_quality_metrics: Data health monitoring
UNIQUE(crypto_id, timestamp)on price_history prevents duplicates- Foreign key relationships ensure data integrity
- Indexes on timestamp columns for fast queries
- Check database initialization:
ls *.duckdb - Run manual refresh in Data Management page
- Check logs for API errors
- Free tier: 10-30 calls/minute
- System includes rate limiting and retry logic
- Upgrade to paid tier for higher limits
- Ensure sufficient historical data (90+ days)
- Retrain models from Data Management page
- Check logs for specific errors
- Should never happen due to database constraints
- If occurs, check
refresh_logtable - Report as bug with logs
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
- CoinGecko for cryptocurrency data API
- Streamlit for the dashboard framework
- scikit-learn for machine learning tools
- DuckDB for fast analytics database
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Add more cryptocurrencies
- Implement alerting system
- Add backtesting framework
- Support multiple fiat currencies
- Add sentiment analysis
- Create mobile app
- Add real-time WebSocket updates
- Implement paper trading
This tool is for educational and research purposes only. Cryptocurrency trading involves significant risk. Always do your own research and consult with financial advisors before making investment decisions. Past performance does not guarantee future results.
Built with β€οΈ for the crypto community