Skip to main content

Overview

The Prophet model is optimized for medium to long-term predictions (1 week to 1 month) of cryptocurrency prices. Built by Meta (Facebook), Prophet excels at capturing trends and seasonality patterns. Best for: Weekly and monthly forecasts, trend analysis, seasonal patterns Source: source/models/prophet_model.py

When to Use Prophet

Long-term Trends

Predictions from 1 week to 1 month ahead

Seasonality Detection

Automatically identifies daily and weekly patterns

Confidence Intervals

Built-in uncertainty quantification

Robust to Gaps

Handles missing data gracefully

Model Parameters

The ProphetCryptoPredictor accepts the following initialization parameters:
ParameterDefaultRangeDescription
changepoint_prior_scale0.50.001-0.5Flexibility for trend changes (higher = more flexible)
seasonality_prior_scale101-20Strength of seasonality component
interval_width0.950.8-0.99Width of confidence intervals
The default changepoint_prior_scale=0.5 is higher than Prophet’s default (0.05) to handle cryptocurrency volatility.

Prophet Configuration

The model is pre-configured with settings optimized for crypto:
Prophet(
    changepoint_prior_scale=0.5,      # High flexibility for volatile crypto
    seasonality_prior_scale=10,       # Strong seasonality modeling
    interval_width=0.95,              # 95% confidence intervals
    daily_seasonality=True,           # Detect daily patterns
    weekly_seasonality=True,          # Detect weekly patterns  
    yearly_seasonality=False,         # Disabled (not relevant for crypto)
    seasonality_mode='multiplicative' # Better for % changes
)

Seasonality Modes

  • Multiplicative (default): Seasonality scales with trend magnitude
    Better for crypto where volatility increases with price
  • Additive: Seasonality is constant regardless of trend
    Use for more stable assets

Usage Example

import pandas as pd
from models.prophet_model import ProphetCryptoPredictor

# Initialize with custom parameters
predictor = ProphetCryptoPredictor(
    changepoint_prior_scale=0.3,  # Less flexible
    seasonality_prior_scale=15,   # Stronger seasonality
    interval_width=0.90           # Narrower confidence bands
)

# Load historical data
df = pd.read_csv('eth_hourly.csv', index_col='timestamp', parse_dates=True)

# Train the model
metrics = predictor.train(df)
print(f"MAPE: {metrics['mape']:.2f}%")
print(f"Direction Accuracy: {metrics['direction_accuracy']:.2f}%")

# Predict next 7 days (168 hours)
predictions = predictor.predict_future(periods=168, freq='H')

# Access predictions with confidence intervals
print(predictions[['predicted_price', 'lower_bound', 'upper_bound', 'trend']])

Training Process

Data Requirements

  • Minimum: 100 data points
  • Recommended: 1000+ hourly data points (6+ weeks) for robust seasonality
  • Format: DataFrame with close column and DatetimeIndex
  • Frequency: Works with hourly (‘H’) or daily (‘D’) data

Data Preparation

Prophet requires data in a specific format:
# Internal transformation (automatic)
# Input: df with 'close' column and datetime index
# Output: Prophet format
prophet_df = pd.DataFrame({
    'ds': df.index,      # Dates/timestamps
    'y': df['close']     # Values to predict
})
The prepare_data() method handles this transformation automatically. You only need standard OHLCV data.

Training Steps

  1. Data Preparation (line 53-70)
    Converts to Prophet’s ds/y format
  2. Model Fitting (line 88)
    Prophet decomposes into trend + seasonality + holidays
  3. Validation (line 92-103)
    Generates in-sample predictions for metrics

Performance Metrics

The train() method returns:
{
    'mae': float,                    # Mean Absolute Error
    'rmse': float,                   # Root Mean Square Error  
    'mape': float,                   # Mean Absolute Percentage Error
    'direction_accuracy': float,     # % correct price direction
    'training_points': int           # Number of data points used
}

Prediction Horizons

HorizonTypical MAPEDirection AccuracyUse Case
1-3 days5-8%55-60%Short-term trend
1 week8-12%50-58%Weekly analysis
2-4 weeks12-20%48-55%Monthly outlook
Prophet works best for horizons of 1 week or longer. For predictions under 72 hours, use the XGBoost model.

Predictions with Uncertainty

Prophet automatically generates confidence intervals:
# Predict next 14 days
predictions = predictor.predict_future(periods=336, freq='H')  # 336 = 14*24

# Result DataFrame columns:
# - timestamp: Prediction date/time
# - predicted_price: Point estimate (yhat)
# - lower_bound: Lower confidence bound (yhat_lower)
# - upper_bound: Upper confidence bound (yhat_upper)
# - trend: Trend component only

# Example usage
for idx, row in predictions.iterrows():
    print(f"{idx}: ${row['predicted_price']:.2f} "
          f"[${row['lower_bound']:.2f} - ${row['upper_bound']:.2f}]")
The confidence intervals widen further into the future, reflecting increasing uncertainty.

Frequency Options

The predict_future() method accepts different frequencies:
# Hourly predictions (default for crypto)
predictions = predictor.predict_future(periods=168, freq='H')

# Daily predictions (for longer horizons)
predictions = predictor.predict_future(periods=30, freq='D')

# Other pandas frequency codes:
# '30min' - 30 minutes
# '4H' - 4 hours  
# 'D' - daily
# 'W' - weekly
Use hourly frequency for crypto to capture intraday patterns. Switch to daily for very long-term predictions (1+ month).

Backtesting

Use the backtest_prophet() utility function:
from models.prophet_model import backtest_prophet

predictor = ProphetCryptoPredictor()

# Test on last 168 hours (1 week)
results = backtest_prophet(
    df, 
    predictor, 
    test_periods=168
)

print("Train Metrics:", results['train_metrics'])
print("Test Metrics:", results['test_metrics'])

# Access actual vs predicted
train_actual = results['train_actual']
test_actual = results['test_actual']
test_predicted = results['test_predicted']

# Full prediction DataFrame with intervals
predictions = results['predictions']

Backtesting Process

  1. Split data: all except last test_periods for training
  2. Train Prophet on training data
  3. Predict test_periods into the future
  4. Compare predictions against actual held-out data
  5. Calculate test metrics (MAE, RMSE, MAPE, direction accuracy)

Trend Analysis

Prophet decomposes predictions into components:
# After training and prediction
predictions = predictor.predict_future(periods=168, freq='H')

# Extract trend (no seasonality)
trend = predictions['trend']

# Identify trend direction
if trend.iloc[-1] > trend.iloc[0]:
    print("Upward trend detected")
else:
    print("Downward trend detected")

# Measure trend strength
trend_change_pct = ((trend.iloc[-1] - trend.iloc[0]) / trend.iloc[0]) * 100
print(f"Trend change: {trend_change_pct:.2f}%")

Configuration Examples

Conservative (Stable, smooth predictions)

predictor = ProphetCryptoPredictor(
    changepoint_prior_scale=0.1,   # Less flexible trend
    seasonality_prior_scale=5,     # Weaker seasonality
    interval_width=0.90            # Narrower confidence
)

Aggressive (Reactive to changes)

predictor = ProphetCryptoPredictor(
    changepoint_prior_scale=0.5,   # High flexibility (default)
    seasonality_prior_scale=15,    # Strong seasonality
    interval_width=0.95            # Wide confidence bands
)

Long-term Forecasting (1+ month)

predictor = ProphetCryptoPredictor(
    changepoint_prior_scale=0.3,   # Moderate flexibility
    seasonality_prior_scale=20,    # Very strong seasonality
    interval_width=0.80            # Tighter bounds for stability
)

# Use daily frequency for speed
predictions = predictor.predict_future(periods=60, freq='D')

Understanding Changepoint Prior Scale

This parameter controls how flexible the trend is:
  • 0.001-0.01: Very rigid, smooth trend (ignores volatility)
  • 0.05: Prophet default (too smooth for crypto)
  • 0.1-0.3: Moderate flexibility (good for stable crypto)
  • 0.4-0.5: High flexibility (default, handles volatility)
Crypto markets are more volatile than traditional stocks, so we use 0.5 instead of Prophet’s default 0.05.

Performance Optimization

  • Prophet uses MCMC sampling (slower than XGBoost)
  • Typical training time: 5-30 seconds for 1000 data points
  • Use daily frequency for datasets >10,000 points
  • Consider downsampling very long histories
  • Lightweight compared to XGBoost
  • Stores trend components and seasonality
  • Minimal feature engineering (just ds/y format)
  • Fast once trained (~50-100ms for 168 predictions)
  • No iterative process (predicts all periods at once)
  • Much faster than XGBoost for long horizons

Advantages Over XGBoost

  1. Direct multi-step prediction: Predicts entire future in one pass (no error accumulation)
  2. Uncertainty quantification: Built-in confidence intervals
  3. Trend decomposition: Separate trend from seasonality
  4. Missing data handling: Automatically handles gaps
  5. Interpretability: Clear trend and seasonal components

Limitations

  1. Short-term Accuracy: Less accurate than XGBoost for <72 hour predictions
  2. Feature Engineering: Cannot use technical indicators (RSI, MACD, etc.)
  3. Training Time: Slower to train than XGBoost
  4. Regime Changes: May lag during sudden market shifts
  5. Volatility: Assumes relatively stable variance (crypto can be chaotic)

When to Choose Prophet

Use Prophet

  • Predictions >1 week ahead
  • Need confidence intervals
  • Want trend decomposition
  • Weekly/monthly planning
  • Seasonal pattern analysis

Use XGBoost

  • Predictions <72 hours
  • Need highest accuracy
  • Have technical indicators
  • Intraday trading
  • Short-term momentum

Next Steps

XGBoost Model

Learn about short-term predictions (1-72 hours)

Hybrid Model

Combine XGBoost + Prophet automatically

Model Comparison

Compare all three models side-by-side

API Reference

Detailed API documentation

Build docs developers (and LLMs) love