LPPLS Model Implementation


This directory contains a complete implementation of the Log-Periodic Power Law Singularity (LPPLS) model for Bitcoin bubble detection and prediction, as described in LPPLS-model.md.


Files


Core Implementation

Quick Start



from lppls_backtest import LPPLSBacktest

# Initialize the system
lppls = LPPLSBacktest()

# Run backtest on recent data
results = lppls.run_backtest(
    start_date='2024-01-01',
    end_date='2024-11-30',
    window=10,           # Days for slope calculation
    tc_threshold=5,      # Days before critical time for signals
    slope_threshold=0.001 # Signal sensitivity
)

# Get future predictions
future_pred = lppls.predict_future(days_ahead=30)

Model Overview


The LPPLS model identifies financial bubbles by fitting price data to:



p(t) = A + B(tc - t)^m (1 + C * cos(ω * log(tc - t) + φ))

Where:

Key Features


LPPLS Model Fitting - Uses differential evolution optimization for robust parameter estimation


Local Slopes Analysis - Calculates trend slopes over moving windows to enhance signal quality


Signal Generation - Generates buy/sell signals when approaching critical times with favorable trends


Backtesting Framework - Complete portfolio simulation with performance metrics


Future Prediction - Extrapolates model to predict future prices and critical events


Flexible Data Sources - Supports both yfinance API and local CSV data


Comprehensive Analysis - Includes Sharpe ratio, max drawdown, and trade analysis


Usage Examples


Basic Analysis


python lppls_usage_guide.py

Comprehensive Demo


python lppls_comprehensive_demo.py

Simple Backtest


python demo_lppls.py

Parameters Guide


Model Parameters

Optimization Parameters

Interpretation


Critical Time (tc)

Signals

Performance Metrics

Limitations


🔴 CRITICAL: Extreme Window Sensitivity Detected


The LPPLS model exhibits 100%+ prediction variance depending on training window size. A comprehensive sensitivity analysis (see full report) revealed:


⚠️ DO NOT use single LPPLS predictions for investment decisions!


Recommended approach:

See also:



Other Limitations


⚠️ Best for Bubble Detection: Model designed for bubble periods, not general prediction


⚠️ Historical Data Required: Needs 100+ days for reliable fitting


⚠️ Parameter Sensitivity: Results depend on parameter choices (window size is the most critical)


⚠️ No Guarantees: Statistical model, not deterministic prediction


⚠️ Research Tool: Use for analysis, not standalone trading


Research Background


Based on the work of:

Technical Notes


Future Enhancements


Potential improvements:



For detailed technical information, see the original research documentation in LPPLS-model.md.