Advanced Bitcoin DCA analysis with machine learning predictions and strategy optimization
Project description
Bitcoin DCA Analysis Terminal
๐ Advanced Bitcoin DCA Analysis and Price Prediction Tool
A comprehensive terminal application for Bitcoin analysis featuring:
- ๐ฎ Advanced price prediction using deep learning and Bitcoin-specific patterns
- ๐ DCA optimization based on historical performance analysis
- ๐งช Comprehensive backtesting of DCA strategies
- ๐ Beautiful terminal interface with Rich library
Features
๐ฎ Price Prediction
- Advanced 3-Model Ensemble: LSTM, Random Forest, and XGBoost ensemble predictions
- Bitcoin-Specific Features: Halving cycles, market maturity, supply analysis
- Technical Analysis: 20+ technical indicators (RSI, MACD, Bollinger Bands, etc.)
- Pattern Recognition: Time-based patterns and market cycle analysis
- Performance-Based Weighting: Best-performing models get higher influence in final prediction
๐ DCA Recommendations
- Optimal Day Analysis: Find the best day of month for DCA investments
- Weekly Patterns: Analyze day-of-week performance
- Combined Strategies: Optimal combinations of timing factors
- Success Rate Analysis: Historical win rates for different strategies
- ๐ Custom Date Ranges: Analyze specific time periods (bull/bear markets, recent years)
- โ ๏ธ Data Validation: Ensures sufficient data for reliable analysis (minimum 90 days)
๐งช DCA Backtesting
- Monthly DCA Strategies: Fixed day of month or optimal weekday combinations
- Performance Metrics: Returns, Sharpe ratio, volatility, max drawdown
- Transaction Analysis: Detailed trade-by-trade breakdown
- ๐ Custom Date Ranges: Backtest specific time periods
- ๐ฏ Strategy Options:
- day_of_month: Invest on specific day each month (e.g., 15th)
- optimal: Invest on chosen weekday closest to chosen day of month
๐ Market Overview
- Real-time Metrics: Current price, trends, volatility
- Historical Context: All-time highs/lows, long-term performance
- Market Cycles: Halving cycle analysis and positioning
Installation
๐ PyPI Installation (Recommended)
Install from PyPI with a single command:
pip install bitcoin-dca
Then run:
btc-dca
Requirements: Python 3.8+, pip
Supported platforms: macOS, Linux, Windows
๐ฆ Development Installation
For development or to get the latest features:
-
Clone the repository:
git clone https://github.com/obokaman-com/bitcoin-dca.git cd bitcoin-dca
-
Install in development mode:
pip install -e .
๐๏ธ Uninstalling
To remove the application:
pip uninstall bitcoin-dca
๐ Upgrading
To upgrade to the latest version:
pip install --upgrade bitcoin-dca
Testing
Run the comprehensive test suite to ensure everything works correctly:
python tests/test_btc_analyzer.py
The test suite includes:
- โ Valid data processing - Normal Bitcoin price data handling
- โ Invalid data handling - Corrupted files, missing columns, negative prices
- ๐งช Edge cases - Empty datasets, extreme values, wrong data types
- ๐ Error recovery - Fallback mechanisms and graceful degradation
- ๐ All components - Data loading, prediction, DCA analysis, backtesting
Test Results: 30 tests covering all major functionality, new UI features, and error conditions.
Usage
Quick Start
After PyPI installation:
btc-dca
For development:
# Run as module
python -m bitcoin_dca.main
# Or if installed as package
btc-dca
Startup time: ~1-2 seconds with optimized on-demand feature loading
Note: On first run, if no Bitcoin data file is found, the application will automatically download the latest data from stooq.com.
โก Performance Features
The application is optimized for fast startup and efficient resource usage:
Key optimizations:
- ๐ Lazy loading - Heavy libraries load only when needed
- ๐พ Smart caching - Features cached to disk for instant reuse
- ๐ฏ On-demand computation - Only compute features for selected analysis
- โก Minimal startup - Load basic data first, enhance progressively
- ๐ Memory efficient - Optimized memory usage (15-25 MB at startup)
Performance analysis tools:
python scripts/startup_info.py # View detailed startup analysis
With Custom Data File
btc-dca --csv your_bitcoin_data.csv
Automatic Data Download
- ๐ Auto-download: Downloads latest Bitcoin price data if CSV doesn't exist
- ๐ Data validation: Verifies downloaded data integrity
- ๐ Retry mechanism: Re-downloads if data loading fails
- ๐พ Local caching: Saves data locally for future use
Data Format
The application expects a CSV file with the following structure:
Date,Open,High,Low,Close
2010-07-19,0.08584,0.09307,0.07723,0.0808
2010-07-20,0.0808,0.08181,0.07426,0.07474
...
Application Flow
Main Menu Options
-
๐ฎ Price Prediction
- Enter target date (YYYY-MM-DD)
- Get AI-powered price prediction with confidence score
- Includes market analysis and technical context
-
๐ DCA Recommendations
- Analyze optimal investment timing
- View best days of month and week
- Get personalized strategy recommendations
-
๐งช DCA Backtesting
- Test different DCA strategies
- Choose from predefined or custom strategies
- Get detailed performance analysis
-
๐ Market Overview
- Current market snapshot
- Historical performance metrics
- Volatility and trend analysis
-
๐ฅ Update Dataset
- Download fresh Bitcoin price data from stooq.com
- Automatically clears cache and reloads data
- Shows before/after data range comparison
- Keep analysis current with latest market movements
-
๐งน Clear Cache
- Remove all cached features and computed data
- Free up disk space (.cache directory)
- Force recomputation of all features
- Useful after manual data updates or troubleshooting
Advanced Features
Prediction Models
- 3-Model Ensemble: Combines LSTM, Random Forest, and XGBoost predictions
- Performance-Based Weighting: Models weighted by validation accuracy (lower MAE = higher weight)
- Feature Engineering: 40+ engineered features including:
- Technical indicators (SMA, EMA, RSI, MACD, Bollinger Bands)
- Bitcoin halving cycle analysis
- Market maturity metrics
- Seasonal and cyclical patterns
DCA Analysis
- Historical Optimization: Analyzes 10+ years of data
- Multiple Time Frames: 30, 90, 180, and 365-day return analysis
- Statistical Significance: Success rates and confidence intervals
Backtesting Engine
- Realistic Simulation: Includes transaction fees and market gaps
- Comprehensive Metrics:
- Total and annualized returns
- Sharpe ratio and volatility
- Maximum drawdown
- Win rate analysis
Technical Implementation
Architecture
bitcoin_dca/
โโโ main.py # Main application and UI
โโโ data_loader.py # Data preprocessing and feature engineering
โโโ predictor.py # ML models for price prediction
โโโ dca_analyzer.py # DCA optimization algorithms
โโโ backtester.py # Strategy backtesting engine
Key Technologies
- pandas/numpy: Data manipulation and analysis
- scikit-learn: Random Forest machine learning
- XGBoost: Gradient boosting algorithms
- TensorFlow: Deep learning (LSTM) models
- Rich: Beautiful terminal interface
- TA-Lib: Technical analysis indicators
Data Processing Pipeline
- Raw Data Loading: CSV parsing and validation
- Feature Engineering: Technical indicators and Bitcoin-specific features
- Model Training: Real-time model training on historical data
- Analysis Execution: Strategy analysis and backtesting
- Results Visualization: Rich terminal output with charts and tables
Performance Considerations
- Efficient Processing: Vectorized operations for large datasets
- Memory Management: Optimized for datasets with 10+ years of daily data
- Model Caching: Smart caching to avoid retraining
- Parallel Processing: Multi-threaded backtesting for strategy comparison
Example Output
Price Prediction
๐ฎ Price Prediction for 2025-01-15
โโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ Predicted Price โ $67,234.50 โ
โ Confidence โ 78.5% โ
โ Model โ Ensemble โ
โ Features Used โ 42 โ
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
DCA Recommendations
๐
Best Days of Month for DCA
โโโโโโโโฌโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โ Rank โ Day โ Avg Return โ Success Rateโ
โโโโโโโโผโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโค
โ 1 โ 21 โ 8.24% โ 73.2% โ
โ 2 โ 15 โ 7.89% โ 71.8% โ
โ 3 โ 28 โ 7.45% โ 69.4% โ
โโโโโโโโดโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโ
Disclaimer
This tool is for educational and research purposes only. Cryptocurrency investments are highly volatile and risky. Past performance does not guarantee future results. Always do your own research and consider consulting with financial advisors before making investment decisions.
Troubleshooting
Installation Issues
Python version errors:
# Check your Python version (requires 3.8+)
python3 --version
# Update Python (macOS)
brew install python3
# Update Python (Ubuntu/Debian)
sudo apt install python3.8 python3.8-pip
Installation failures:
# Try with pip3 explicitly
pip3 install bitcoin-dca
# Or with user install
pip install --user bitcoin-dca
# Force reinstall if corrupted
pip install --force-reinstall bitcoin-dca
TensorFlow installation issues on Apple Silicon:
# If TensorFlow fails, install manually first
pip install tensorflow-macos
pip install bitcoin-dca
Missing system dependencies (for compilation):
# macOS
xcode-select --install
# Ubuntu/Debian
sudo apt install build-essential python3-dev
# CentOS/RHEL
sudo yum groupinstall "Development Tools"
Runtime Issues
Command not found after installation:
# Check if pip installed correctly
pip show bitcoin-dca
# Try running directly
python -m bitcoin_dca.main
# Reinstall if needed
pip install --force-reinstall bitcoin-dca
Dependency conflicts:
# Update all dependencies
pip install --upgrade bitcoin-dca
# Clean reinstall
pip uninstall bitcoin-dca
pip install bitcoin-dca
Contributing
Feel free to submit issues, feature requests, or pull requests to improve the application.
License
This project is open source and available under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitcoin_dca-1.3.0.tar.gz.
File metadata
- Download URL: bitcoin_dca-1.3.0.tar.gz
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
809cf1efb44c250d032852f013f8d5e78cce115d0b7a9fd8de05f0e095997fdc
|
|
| MD5 |
44a9d9a351e3930ab12eb01fe997a577
|
|
| BLAKE2b-256 |
76991bd0cc80228cb6d8a1bbd1a00bf24b901c6aa087624db0d72fde53ba7843
|
File details
Details for the file bitcoin_dca-1.3.0-py3-none-any.whl.
File metadata
- Download URL: bitcoin_dca-1.3.0-py3-none-any.whl
- Upload date:
- Size: 38.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5b64bfdfa8fdb53610ffcca918df5c40ec80d30ed99a3d6e7b5978fede6b0f6
|
|
| MD5 |
742fd1161bdcc03f9d2774969b2b1bed
|
|
| BLAKE2b-256 |
a0e746eb4cf5b5b31aad20b3bff4554c60843e18315ed0e3b0470d4499dea685
|