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.0.0.tar.gz (10.5 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.0.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for btcvol-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e11e51242b2527c3614f544cb0c5dc25702acf80c151dd2e384cc514654ecf6a
MD5 a9afbd3fa243be02e65e095ec302825b
BLAKE2b-256 6073ac5998c0fc7316a9b68c8e1e6a37598fc0c6dfab2d2c3e97f38a33a99ce5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: btcvol-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9ae24b052f321f3b1cef7c5ce90021ed5e4bb9efabf6235ab057fbf69d87f70
MD5 bd064dd364831c8fd532fa1facc201bf
BLAKE2b-256 648ec66549de8bec6032de069e8045ed5d689e32a522d97afc97be975d43ac9d

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