Skip to content

End-to-end BTC price prediction using ML (XGBoost, RF, Lasso), CoinGecko API, Power BI, and Windows automation. Includes daily updates, weekly retraining, and dashboards.

Notifications You must be signed in to change notification settings

Harish-34/btc_price_tracker_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 BTC Price Tracker & Forecasting

📖 Project Overview

This project implements a full-cycle Bitcoin price prediction system using machine learning, Power BI dashboards, and Windows-based automation.

We use CoinGecko's API to pull 365-day BTC data, apply time series-based model training (Linear, Ridge, Lasso, RF, XGBoost, CatBoost, etc.), evaluate metrics (MAE, RMSE, R²), and visualize the results using Power BI Desktop.

The system is designed for automated daily updates and weekly retraining to always forecast the next 7-day BTC prices.

🛠️ Tools and Libraries Used

💻 Programming & Environment

  • Python 3.10
  • Jupyter Notebook – for EDA and prototyping
  • Spyder IDE – for final pipeline scripting

📦 Core Python Libraries

  • pandas, numpy – data manipulation and feature processing
  • matplotlib, seaborn – visualizations and plots
  • os, datetime, timedelta – file and time handling
  • requests – API calls to CoinGecko

🤖 Machine Learning Libraries

  • scikit-learn – linear models, metrics, and time series split
  • xgboost, lightgbm, catboost – gradient boosting models
  • pickle – for model serialization

📊 Visualization & BI

  • Power BI Desktop – interactive dashboard

🔁 Automation

  • Windows Task Scheduler – to schedule daily and weekly scripts

🌐 External API

  • CoinGecko API – for fetching historical BTC price data

🗂️ Project Folder Structure

This project includes data/ for input/output CSVs, diagrams/ for EDA/forecast plots, models/ for the latest trained model, and src/ for all Python scripts. The dashboard/ folder contains the Power BI .pbix file, with dependencies in requirements.txt and full documentation in README.md.

btc_price_tracker_api/
├── data/
│   ├── btc_full_data.csv             # Full 365-day + daily BTC data
│   ├── btc_prediction.csv            # Next 7-day forecast (updated weekly)
│   ├── btc_processed_data.csv        # Cleaned data used for ML modeling
│   └── btc_model_scores.csv          # MAE, RMSE, R², MAPE for each model
│
├── diagrams/
│   ├── btc_price_trens.png
│   ├── btc_moving_averages.png
│   ├── btc_daily_change_pct.png
│   ├── final_forecast_plot.png
│   ├── mae_comparison.png
│   ├── rmse_comparison.png
│   ├── r2_comparison.png
│   ├── mape_comparison.png
│   └── BTC Price Forecast & Model Performance Dashboard.png
│
├── models/
│   └── Lasso_btc_best_model.pkl      # Latest trained model (auto-overwritten weekly)
│
├── src/
│   ├── fetch_btc_data.py             # One-time: fetch initial 365-day BTC data
│   ├── daily_update.py               # Daily script to append new BTC price
│   ├── clean_and_process.ipynb       # Notebook for cleaning, EDA, and exports
│   └── train_and_predict.py          # Main ML training + 7-day forecasting
│
├── dashboard/
│   └── powerbi_dashboard.pbix        # Final Power BI Dashboard file
│
├── requirements.txt                  # Python dependencies
└── README.md                         # Complete project documentation

🔄 Process Flow

The BTC Price Tracker operates in a continuous loop using a structured 4-phase pipeline:

  1. Data Collection

    • Pull 365 days of BTC price data using the CoinGecko API (fetch_btc_data.py)
    • Append new daily BTC price using daily_update.py (runs via Task Scheduler)
  2. Data Cleaning & EDA

    • Run clean_and_process.ipynb to handle missing data, generate charts, and export cleaned datasets
    • Visualizations (price trend, moving averages, etc.) are saved to /diagrams
  3. Model Training & Forecasting

    • Execute train_and_predict.py weekly to:
      • Train multiple models (Linear, Ridge, Lasso, RF, XGBoost, LightGBM, CatBoost)
      • Select the best model based on RMSE
      • Forecast BTC prices for the next 7 days
      • Save the best model in /models and scores in btc_model_scores.csv
  4. Dashboard & Automation

    • Open powerbi_dashboard.pbix to visualize latest trends, model scores, and forecasts
    • Task Scheduler automates data update and model retraining

📊 Visualizations

This project combines data visualizations created using Python (Matplotlib, Seaborn) and Power BI to offer deep insights into Bitcoin price trends, forecasting accuracy, and model performance.

These visuals are critical in transforming raw data into understandable patterns that help answer key business questions such as:

  • 📉 How is BTC price behaving over time?
  • 📈 What is the forecasted price for the next 7 days?
  • 🧠 Which ML model is currently performing best?
  • 🎯 How accurate are our predictions in real terms (MAE, RMSE, R²)?
  • 🔍 Are we underfitting or overfitting any model based on error metrics?

Together, these help financial analysts, investors, or data teams track market behavior, evaluate prediction reliability, and plan investment or trading strategies based on data-driven insights.


🧮 Python Visuals

Diagram File Description
btc_price_trens.png BTC price trend over the last 365 days
btc_moving_averages.png 7-day and 14-day moving averages to detect signals
btc_daily_change_pct.png Daily % change — helps identify market volatility
final_forecast_plot.png Forecasted BTC prices for next 7 days
mae_comparison.png MAE: absolute error comparison across models
rmse_comparison.png RMSE: penalizes large prediction errors
r2_comparison.png R²: how well model explains variance in price
mape_comparison.png MAPE: shows % error — useful for business clarity
---

📊 Power BI Dashboard

Diagram File Description
BTC Price Forecast & Model Performance Dashboard.png Combined view of trend, forecast, and scores

🔸 Power BI File:

🔸 The dashboard is designed for **executive-level reporting** and allows easy interpretation of price trends, future projections, and model comparisons with filters and visuals.

⚙️ Installation

To run this project on your local machine:

# Clone the repository
git clone https://github.com/Harish-34/btc_price_tracker_api.git

# Navigate into the project folder
cd btc_price_tracker_api

# Install required dependencies
pip install -r requirements.txt

✅ Conclusion

This end-to-end BTC price prediction system demonstrates how machine learning, automated pipelines, and dashboarding tools can be combined to drive financial forecasting solutions.

From data collection and modeling to daily price updates and insightful dashboards, the project is built for real-time tracking and business-oriented decision making.

It can be extended to other cryptocurrencies or asset classes by updating the source API and modeling logic.


📬 Contact

If you liked this project or want to collaborate:

Feel free to connect for ideas, feedback, or contributions!