Skip to main content

Bitcoin Implied Volatility Prediction Competition - Participant Package

Project description

btcvol

Python package for building and testing Bitcoin implied volatility prediction models for CrunchDAO competitions.

PyPI version Python 3.9+ License: MIT

Installation

# Install from GitHub
pip install git+https://github.com/jberros/btcvol-python.git

# Or from PyPI (coming soon)
pip install btcvol

Quick Start

from btcvol import TrackerBase, test_model_locally
from btcvol.examples import GARCHVolatilityModel
import numpy as np

# Option 1: Use the built-in GARCH model
model = GARCHVolatilityModel(base_vol=0.42)
predictions = model.predict("BTC", horizon=3600, step=900)
print(f"Generated {len(predictions)} predictions: {predictions}")

# Option 2: Create your own custom model
class MyVolatilityModel(TrackerBase):
    def predict(self, asset: str, horizon: int, step: int):
        """
        Generate volatility predictions.
        
        Args:
            asset: Asset to predict (e.g., "BTC")
            horizon: Time horizon in seconds (e.g., 3600 for 1h, 86400 for 24h)
            step: Prediction resolution in seconds (e.g., 900 for 15 min)
        
        Returns:
            List of predicted volatility values (0-1 range, e.g., 0.40 = 40%)
        """
        num_predictions = horizon // step
        base_vol = 0.42
        
        # Apply mean reversion based on horizon
        horizon_hours = horizon / 3600
        adjustment = 1.0 / np.sqrt(horizon_hours / 24.0)
        
        return [base_vol * adjustment] * num_predictions

# Test your model locally
if __name__ == "__main__":
    test_model_locally(MyVolatilityModel)

Features

  • TrackerBase: Abstract base class for building volatility prediction models
  • test_model_locally(): Validate your model before submission
  • Example Models: Pre-built models to help you get started
    • GARCHVolatilityModel: Mean-reverting GARCH-style predictions
    • RandomWalkModel: Random walk with configurable volatility
    • LinearDecayModel: Linear decay from start to end volatility

Example Models

GARCH-Style Model

from btcvol.examples import GARCHVolatilityModel

model = GARCHVolatilityModel(base_vol=0.42)
predictions = model.predict("BTC", horizon=3600, step=900)
# Returns 4 predictions for 1-hour horizon with 15-min steps

Custom Model

import numpy as np
from btcvol import TrackerBase

class AdvancedModel(TrackerBase):
    def __init__(self):
        super().__init__()
        # Initialize your model parameters
        
    def predict(self, asset: str, horizon: int, step: int):
        num_predictions = horizon // step
        # Your sophisticated prediction logic here
        return [0.40] * num_predictions

Competition Details

This package is designed for CrunchDAO's Bitcoin DVOL prediction competition:

  • Target: Deribit 30-day Bitcoin Implied Volatility (DVOL)
  • Prediction Frequency: Every 15 minutes
  • Horizons: 1 hour (3600s) and 24 hours (86400s)
  • Evaluation: Mean Squared Error (MSE) over 30-day period

Testing Your Model

from btcvol import test_model_locally
from your_module import YourModel

# Run validation tests
test_model_locally(YourModel)

The test validates:

  • ✓ Model inherits from TrackerBase
  • ✓ Predict method is implemented
  • ✓ Returns correct number of predictions
  • ✓ All predictions are numeric
  • ✓ Values are in reasonable range

API Reference

TrackerBase

Base class for all volatility prediction models.

Methods:

  • predict(asset, horizon, step) - [Abstract] Generate predictions
  • fetch_price_data(asset, days) - Helper to fetch historical prices
  • fetch_dvol_data(days) - Helper to fetch historical DVOL data

test_model_locally(model_class, verbose=True)

Validate your model implementation.

Parameters:

  • model_class: Your model class (not an instance)
  • verbose: Print detailed test results

Returns:

  • bool: True if all tests pass

Development

# Clone the repository
git clone https://github.com/yourusername/btcvol-python.git
cd btcvol-python

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest tests/

Requirements

  • Python >= 3.9
  • pandas >= 2.0.0
  • numpy >= 1.24.0

License

MIT License - see LICENSE file for details.

Links

Support

For competition-specific questions, visit the CrunchDAO Discord.

For package issues, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

btcvol-1.2.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

btcvol-1.2.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file btcvol-1.2.0.tar.gz.

File metadata

  • Download URL: btcvol-1.2.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for btcvol-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d8ded827b5753e3f0ee9dc73aa49799f2c916a4b58c237ba722016269b571959
MD5 b6aae49a845dc20fdfec7af80f9a8f9b
BLAKE2b-256 ea5fbe8545b88a68df02c00ab45e952cf8c05994ed8335a070ca02717c48e54c

See more details on using hashes here.

File details

Details for the file btcvol-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: btcvol-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for btcvol-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a0d6fae0749a1e411204b46377d43ba36e00d2af38ce622a45caa49d3646dae
MD5 2e9d797d83f4777aa0499cbbe885f819
BLAKE2b-256 6b16a4289ce4ab17bb7cf9edc4b7d6986117762235869a9b6b1bc16ebd9b902d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page