Skip to main content

Overview

CryptoView Pro uses state-of-the-art machine learning models to predict cryptocurrency prices across multiple time horizons, from 1 hour to 1 year. The system employs three distinct models optimized for different prediction scenarios:
  • XGBoost: Optimized for short-term predictions (1h - 72h)
  • Prophet: Designed for medium to long-term predictions (1 week - 1 year)
  • Hybrid Model: Intelligently combines both models for optimal accuracy

Multi-Horizon Forecasting

Time Horizons

The platform supports four distinct prediction horizons:

Short Term

6h, 12h, 24h, 48h, 72hBest for intraday and swing trading

Medium Term

1 week (168h), 2 weeks (336h), 3 weeks (504h), 1 month (720h)Best for position trading

Long Term

2-3 months, 6 months, 1 yearHigher uncertainty, strategic planning

Custom

Define your own horizonFlexible time units (hours, days, weeks, months)

Model Recommendations

The system automatically recommends the best model based on your prediction horizon:
if forecast_hours <= 72:
    recommended_model = "XGBoost"  # High accuracy for short-term
elif forecast_hours <= 720:
    recommended_model = "Hybrid"   # Best of both worlds
else:
    recommended_model = "Prophet"  # Handles long-term trends

Making Predictions

Basic Workflow

1

Load Historical Data

The system automatically fetches historical OHLCV data from Kraken:
from data.collectors import CryptoDataCollector

collector = CryptoDataCollector('kraken')
df = collector.fetch_ohlcv('BTC/USDT', '1h', limit=2000)
2

Initialize Predictor

Choose your prediction model:
from models.hybrid_model import HybridCryptoPredictor
from models.xgboost_model import XGBoostCryptoPredictor
from models.prophet_model import ProphetCryptoPredictor

# For optimal results, use the hybrid model
predictor = HybridCryptoPredictor()

# Or use specific models
xgb_predictor = XGBoostCryptoPredictor(
    n_estimators=200,
    learning_rate=0.07,
    max_depth=6
)
3

Train the Model

Train on historical data:
# Train hybrid model (trains both XGBoost and Prophet)
training_info = predictor.train(df)

print(f"Data points used: {training_info['data_points']}")
print(f"XGBoost metrics: {training_info['xgboost']}")
print(f"Prophet metrics: {training_info['prophet']}")
4

Generate Predictions

Predict future prices:
# Predict next 24 hours
predictions = predictor.predict_future(df, periods=24)

# For hybrid model, predictions is a dict with multiple models
best_prediction = predictions['hybrid']  # or 'recommended'

print(best_prediction.head())
# Output:
#                      predicted_price  lower_bound  upper_bound
# 2026-03-07 12:00:00     94532.45       93821.23     95243.67
# 2026-03-07 13:00:00     94612.89       93899.12     95326.66

Advanced Example: Multi-Horizon Prediction

import pandas as pd
from models.hybrid_model import HybridCryptoPredictor
from utils.long_term_predictions import aggregate_predictions, get_milestone_predictions

# Initialize and train
predictor = HybridCryptoPredictor()
predictor.train(df)

# Generate predictions for different horizons
horizons = {
    'intraday': 24,      # 1 day
    'swing': 168,        # 1 week
    'position': 720,     # 1 month
    'long_term': 2160    # 3 months
}

results = {}
for name, hours in horizons.items():
    predictions = predictor.predict_future(df, periods=hours)
    best_pred = predictor.get_best_prediction(predictions)
    results[name] = best_pred
    
    # Calculate expected return
    current_price = df['close'].iloc[-1]
    final_price = best_pred['predicted_price'].iloc[-1]
    expected_return = ((final_price - current_price) / current_price) * 100
    
    print(f"{name.upper()}: {expected_return:+.2f}% (${final_price:,.2f})")

# Aggregate long-term predictions
if 'long_term' in results:
    # Daily aggregation
    daily = aggregate_predictions(results['long_term'], 'daily')
    print(f"\nDaily average prices:\n{daily.head()}")
    
    # Key milestones (30, 60, 90 days)
    milestones = get_milestone_predictions(results['long_term'])
    for period, data in milestones.items():
        print(f"{period}: ${data['price']:,.2f} on {data['date'].strftime('%Y-%m-%d')}")

XGBoost Model

The XGBoost model uses advanced feature engineering with 50+ technical indicators:

Feature Categories

  • Price returns: 1h, 4h, 24h, 7-day windows
  • Momentum indicators: 7-day and 14-day momentum
  • Rate of change calculations
  • Simple Moving Averages (SMA): 7, 14, 30, 50 periods
  • Exponential Moving Averages (EMA): 12, 26, 50 periods
  • Price-to-MA ratios for trend detection
  • Rolling standard deviation: 7, 14, 30-day windows
  • Bollinger Bands (20-period, 2 std dev)
  • Bollinger Band position indicator
  • Volume moving averages
  • Volume ratios and changes
  • Volume-weighted features
  • RSI (normalized, oversold/overbought flags)
  • MACD (difference, signal, positive/negative flags)
  • High/Low ratios
  • Close/Open ratios
  • Hour of day (0-23)
  • Day of week (0-6)
  • Day of month (1-31)
  • Month (1-12)
  • Historical prices: 1, 2, 3, 7, 14 periods back
  • Captures temporal dependencies

Model Configuration

from models.xgboost_model import XGBoostCryptoPredictor

# Custom configuration
predictor = XGBoostCryptoPredictor(
    n_estimators=200,      # Number of boosting rounds
    learning_rate=0.07,    # Step size shrinkage
    max_depth=6,           # Maximum tree depth
    subsample=0.8,         # Subsample ratio of training data
    colsample_bytree=0.8   # Subsample ratio of features
)

# Train with custom split
metrics = predictor.train(df, train_size=0.8)  # 80% train, 20% test

print(f"Test MAE: ${metrics['test_mae']:.2f}")
print(f"Test MAPE: {metrics['test_mape']:.2f}%")
print(f"Direction Accuracy: {metrics['test_direction_accuracy']:.2f}%")

# Get feature importance
importance = predictor.get_feature_importance()
print("\nTop 10 Features:")
print(importance.head(10))

Prophet Model

Prophet excels at capturing long-term trends, seasonality, and holiday effects:

Key Features

  • Trend Detection: Automatically identifies growth patterns
  • Seasonality: Daily, weekly, and yearly patterns
  • Uncertainty Intervals: Built-in confidence bands
  • Robust to Missing Data: Handles gaps in time series

Usage Example

from models.prophet_model import ProphetCryptoPredictor, backtest_prophet

# Initialize Prophet
predictor = ProphetCryptoPredictor()

# Train
metrics = predictor.train(df)

# Predict 30 days ahead
predictions = predictor.predict_future(periods=720, freq='H')  # 720 hours = 30 days

# Predictions include uncertainty intervals
print(predictions[['predicted_price', 'lower_bound', 'upper_bound']].head())

# Backtest
backtest_results = backtest_prophet(df, predictor, test_periods=168)
print(f"Backtest MAPE: {backtest_results['metrics']['MAPE']:.2f}%")

Hybrid Model Strategy

The hybrid model intelligently combines XGBoost and Prophet using dynamic weighting:

Weighting Algorithm

# Weight calculation based on prediction horizon
xgb_weight = max(0, 1 - (periods / 168))  # Decreases as horizon increases
prophet_weight = 1 - xgb_weight

# Example weights:
# 24h prediction:  XGBoost 85%, Prophet 15%
# 72h prediction:  XGBoost 55%, Prophet 45%
# 168h prediction: XGBoost 0%,  Prophet 100%

Ensemble Prediction

from models.hybrid_model import HybridCryptoPredictor

predictor = HybridCryptoPredictor()
predictor.train(df)

# Predict with automatic model selection
predictions = predictor.predict_future(df, periods=72)

# Check which models were used
if 'weights' in predictions:
    weights = predictions['weights']
    print(f"XGBoost: {weights['xgboost']:.1%}")
    print(f"Prophet: {weights['prophet']:.1%}")

# Get best prediction
best = predictor.get_best_prediction(predictions)

# Compare all models
for model_name in ['xgboost', 'prophet', 'hybrid']:
    if model_name in predictions:
        pred_df = predictions[model_name]
        final_price = pred_df['predicted_price'].iloc[-1]
        print(f"{model_name}: ${final_price:,.2f}")

Prediction Confidence

All predictions include confidence intervals to quantify uncertainty:
from models.xgboost_model import create_prediction_intervals

# Generate predictions
predictions = predictor.predict_future(df, periods=24)

# Add confidence intervals (95% default)
predictions_with_ci = create_prediction_intervals(predictions, confidence=0.95)

# Calculate prediction bands
for idx, row in predictions_with_ci.iterrows():
    pred = row['predicted_price']
    lower = row['lower_bound']
    upper = row['upper_bound']
    uncertainty = ((upper - lower) / pred) * 100
    
    print(f"{idx}: ${pred:,.2f}{uncertainty:.1f}%)")
Uncertainty increases with prediction horizon. Short-term predictions (1-24h) typically have ±2-5% bands, while long-term predictions (30+ days) can have ±15-30% bands.

Best Practices

Recommendations

  1. Data Quality: Use at least 500 data points for training (2000+ recommended)
  2. Model Selection: Follow automatic recommendations or use hybrid for flexibility
  3. Horizon Matching: Don’t use XGBoost for predictions beyond 72 hours
  4. Regular Retraining: Retrain models with fresh data every 24-48 hours
  5. Confidence Intervals: Always consider uncertainty bounds in decision-making
  6. Backtesting: Validate model performance before live trading

Code Reference

Key files for prediction functionality:
  • models/xgboost_model.py:226 - XGBoost prediction loop
  • models/hybrid_model.py:49 - Hybrid model prediction strategy
  • models/prophet_model.py - Prophet implementation
  • utils/long_term_predictions.py - Aggregation utilities
  • app.py:706 - Training workflow in UI
Predictions are for educational purposes only and do not constitute financial advice. Cryptocurrency markets are highly volatile and unpredictable.

Build docs developers (and LLMs) love