lowkey_backtest/INSTRUCTIONS_MVRV.md

1.4 KiB

MVRV Strategy Port Instructions

This document explains how to run the ported MVRV/NUPL strategy.

Prerequisites

  1. Dependencies: Ensure you have installed the required packages:
    uv add requests xgboost scikit-learn numba python-dotenv
    
  2. API Key: Your CryptoQuant API key is set in .env (CRYPTOQUANT_API_KEY).
  3. Data: You need a high-frequency (1m or 15m) OHLCV CSV file for BTC/USDT.

Workflow

1. Prepare Data

Fetch on-chain data from CryptoQuant, merge it with your price data, and generate features.

python prepare_data.py --csv <path_to_your_ohlcv.csv> --days 730

Output: data/features.csv

2. Train Model

Train the XGBoost model using the generated features.

python train_model.py

Output: data/model.pkl

3. Run Backtest

Run the strategy backtest using the trained model and your price data.

python backtest_mvrv.py --csv <path_to_your_ohlcv.csv>

Output: Logs in logs/mvrv_trade_log.csv and summary printed to console.

Configuration

You can adjust strategy parameters in strategy_config.py:

  • PROB_THRESHOLD: ML probability threshold for entry (default 0.55).
  • SL_ATR_MULT: Stop Loss ATR multiplier (default 0.8).
  • TP_ATR_MULT: Take Profit ATR multiplier (default 1.5).
  • MVRV_Z_THRESH: Overheated MVRV Z-score threshold (default 1.5).
  • NUPL_THRESH: Overheated NUPL threshold (default 0.6).