Skip to main content

ATR-adaptive Laguerre RSI for non-anticipative feature engineering in seq-2-seq forecasting

Project description

ATR-Adaptive Laguerre RSI

Non-anticipative volatility-adaptive momentum indicator for sequence-to-sequence forecasting.

Overview

This library implements the ATR-Adaptive Laguerre RSI indicator, designed for robust feature engineering in financial time series forecasting. The indicator combines:

  • True Range (TR) - Volatility measurement including gaps
  • ATR with Min/Max Tracking - Rolling volatility envelope
  • Adaptive Coefficient - Volatility-normalized adaptation
  • Laguerre 4-Stage Cascade - Low-lag smoothing filter
  • Laguerre RSI - Momentum from filter stage differences

Key Features

  • Non-anticipative: Guaranteed no lookahead bias
  • O(1) Incremental: Efficient streaming updates with .update() method
  • Multi-interval: Supports 1s-1d timeframes with 79-feature extraction (121 without filtering)
  • Redundancy filtering: Optional 121→79 feature reduction (|ρ| > 0.9 removed)
  • Flexible datetime: Works with DatetimeIndex, 'date' column, or custom column names
  • Validated: Information coefficient > 0.03 on k-step-ahead returns

Installation

uv add atr-adaptive-laguerre

Feature Modes: Choose Your Use Case

This package supports two operational modes with very different capabilities:

Mode Features Lookback Use Case
Multi-Interval (Recommended) 79 360 bars Production ML pipelines - includes cross-timeframe analysis
Single-Interval 27 30 bars Minimal data requirements or single-timeframe analysis

⚠️ Important: Multi-Interval Mode is Recommended

If you're building ML features, you want multi-interval mode (79 features), which includes:

  • Base interval features (16)
  • First multiplier interval features (15)
  • Second multiplier interval features (17)
  • Cross-interval analysis features (31) ← Unique to multi-interval mode!

Cross-interval features detect multi-timeframe patterns like:

  • Regime alignment across timeframes
  • Divergence detection
  • Momentum cascades
  • Gradient analysis
  • Statistical stability metrics

Quick Start

Multi-Interval Mode (Recommended - 79 Features)

from atr_adaptive_laguerre import ATRAdaptiveLaguerreRSI, ATRAdaptiveLaguerreRSIConfig

# RECOMMENDED: Use multi-interval mode for full feature set
config = ATRAdaptiveLaguerreRSIConfig.multi_interval(
    multiplier_1=4,   # 4x base interval (e.g., 2h → 8h)
    multiplier_2=12   # 12x base interval (e.g., 2h → 24h)
)
indicator = ATRAdaptiveLaguerreRSI(config)

# Extract 79 features across 3 timeframes
features_df = indicator.fit_transform_features(df)

print(f"Features extracted: {indicator.n_features}")  # 79
print(f"Min data required: {indicator.min_lookback_base_interval} bars")  # 360

Single-Interval Mode (Minimal Lookback - 27 Features)

Use this mode only if you have limited historical data or need single-timeframe analysis:

from atr_adaptive_laguerre import ATRAdaptiveLaguerreRSI, ATRAdaptiveLaguerreRSIConfig

# Single-interval mode (WARNING: only 27 features, missing cross-timeframe analysis)
config = ATRAdaptiveLaguerreRSIConfig(
    atr_period=14,
    smoothing_period=5,
    date_column='date'  # Or use DatetimeIndex
)
indicator = ATRAdaptiveLaguerreRSI(config)

# Get single RSI value
rsi_series = indicator.fit_transform(df)  # Returns pd.Series (single RSI column)

# Or get 27 single-interval features
features_df = indicator.fit_transform_features(df)  # Returns DataFrame with 27 columns

print(f"Features extracted: {indicator.n_features}")  # 27
print(f"Min data required: {indicator.min_lookback} bars")  # 30

Advanced: Incremental Updates (O(1) Streaming)

Both modes support efficient incremental updates:

# After initial fit_transform
new_row = {'open': 100, 'high': 101, 'low': 99, 'close': 100.5, 'volume': 1000}
new_rsi = indicator.update(new_row)  # Returns float (O(1) complexity)

Disabling Redundancy Filtering (79 → 121 Features)

# Disable redundancy filtering to get all 121 features
config = ATRAdaptiveLaguerreRSIConfig.multi_interval(
    multiplier_1=4,
    multiplier_2=12,
    filter_redundancy=False  # Get all 121 features
)
feature = ATRAdaptiveLaguerreRSI(config)

# Returns DataFrame with 121 columns (all features, including 42 redundant ones)
features_df = feature.fit_transform_features(df)

# Verify feature count
print(f"Features: {feature.n_features}")  # 121 (79 by default)

# Redundancy filtering (enabled by default):
# - Data: 3 years of 2h OHLCV (BTCUSDT, ETHUSDT, SOLUSDT)
# - Threshold: |ρ| > 0.9 (perfect correlations and near-redundant features)
# - Removes: Base RSI values, redundant distance metrics, duplicate regime features
# - Retains: Rate-of-change, cross-interval, and temporal features
# - IC validation: +45.54% improvement (PASSED)

Documentation

License

MIT License - Eon Labs Ltd.

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

atr_adaptive_laguerre-1.0.7.tar.gz (275.4 kB view details)

Uploaded Source

Built Distribution

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

atr_adaptive_laguerre-1.0.7-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

Details for the file atr_adaptive_laguerre-1.0.7.tar.gz.

File metadata

File hashes

Hashes for atr_adaptive_laguerre-1.0.7.tar.gz
Algorithm Hash digest
SHA256 6ad54dacb942d4bf78e3bbd0be46c03d447a99995f1582c5baceb18515b322c3
MD5 aee2303794c050ba37d45853bd77332f
BLAKE2b-256 40dfa472f243e9aa1cec0bfdabfd92cb47790d7d69112ee3ab9ea52db066b718

See more details on using hashes here.

File details

Details for the file atr_adaptive_laguerre-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for atr_adaptive_laguerre-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d124f0ed5d6ea90b1853ed7182f0def0c47cb6121fb38672a9b8e04507a20e59
MD5 3923a55b62b85f0d1f1176152bbcbdca
BLAKE2b-256 db58084d62b08be51ec0e09d5ebd0adcf4ba5fe56b2dd0170cea12d7d2cc9f03

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