Ethereum Volatility Prediction Model
Model Description
This model is designed to predict the volatility of Ethereum (ETH) prices over the next 3, 6, 12, and 24 hours using hourly historical price data. The model employs machine learning techniques utilizing rolling volatility features calculated from ETH prices over different time intervals.
The training dataset consists of hourly ETH price data for one month, including price and volatility calculations such as 3-hour (vol_3h), 6-hour (vol_6h), 12-hour (vol_12h), and 24-hour (vol_24h) volatilities. Volatility is computed as the standard deviation of log returns over the specified periods.
This model aims to assist in understanding and anticipating short-term Ethereum price fluctuations, useful for risk analysis, trading strategies, and portfolio management.
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
def train_model(df):
"""
Train a simple linear regression model to predict 24h volatility from shorter-term volatilities.
Args:
df (pd.DataFrame): dataframe with columns vol_3h, vol_6h, vol_12h, vol_24h
Returns:
model: trained sklearn model
float: R2 score on training data
"""
X = df[['vol_3h', 'vol_6h', 'vol_12h']].values
y = df['vol_24h'].values
model = LinearRegression()
model.fit(X, y)
preds = model.predict(X)
score = r2_score(y, preds)
return model, score
During training, a simple linear regression algorithm was used as a baseline with evaluation based on the R² (coefficient of determination) metric. You can extend this with more advanced models such as XGBoost or LSTM for better performance.
Intended Uses & Limitations
Intended Uses
- ETH volatility prediction over short time horizons (3–24 hours)
- Risk analysis tool and trading decision support
- Foundation for further crypto price prediction models
Limitations
- The model predicts volatility, not direct prices.
- Accuracy depends on historical data quality and feature set.
- Does not replace fundamental or news analysis.
- Should not be the sole basis for investment decisions.
How to Use
Example usage of the model for predicting 24-hour volatility:
1import pandas as pd
2from src.model import train_model
3
4# Load dataset
5df = pd.read_csv('data/eth_volatility_1month_hourly.csv')
6
7# Train model and evaluate
8model, r2_score = train_model(df)
9print(f"Model R² score: {r2_score:.4f}")
10
11# Predict with latest features (example)
12latest_features = df[['vol_3h', 'vol_6h', 'vol_12h']].iloc[-1:].values
13pred_vol_24h = model.predict(latest_features)
14print(f"Predicted 24-hour volatility: {pred_vol_24h[0]:.6f}")