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 85-feature extraction (133 without filtering)
  • Redundancy filtering: Optional 133→85 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

PyPI (Public)

# Core package (indicators, features, backtesting.py integration)
uv add atr-adaptive-laguerre

# With optional Binance data adapter (BinanceAdapter, Parquet caching)
uv add "atr-adaptive-laguerre[data]"

AWS CodeArtifact (EonLabs Private)

The package is also available in the EonLabs CodeArtifact repository for internal use.

For details on setting up CodeArtifact publishing and credentials, see CodeArtifact Setup Guide.

Install from CodeArtifact

# Configure CodeArtifact credentials (see CODEARTIFACT_SETUP.md)
uv add atr-adaptive-laguerre --index-url <codeartifact-url>

# With optional data adapter
uv add "atr-adaptive-laguerre[data]" --index-url <codeartifact-url>

Feature Modes: Choose Your Use Case

This package supports two operational modes with very different capabilities:

Mode Features Lookback Use Case
Multi-Interval (Recommended) 85 360 bars Production ML pipelines - includes cross-timeframe analysis
Single-Interval 31 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 (85 features), which includes:

  • Base interval features (31)
  • First multiplier interval features (31)
  • Second multiplier interval features (31)
  • Cross-interval analysis features (40) ← Unique to multi-interval mode!
  • Redundancy filtered: 133 → 85 features (48 redundant features removed)

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 - 85 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 85 features across 3 timeframes (31 per interval + 40 cross-interval, filtered)
features_df = indicator.fit_transform_features(df)

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

Single-Interval Mode (Minimal Lookback - 31 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 31 features, missing cross-timeframe analysis)
config = ATRAdaptiveLaguerreRSIConfig.single_interval(
    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 31 single-interval features
features_df = indicator.fit_transform_features(df)  # Returns DataFrame with 31 columns

print(f"Features extracted: {indicator.n_features}")  # 31
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 (85 → 133 Features)

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

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

# Verify feature count
print(f"Features: {feature.n_features}")  # 133 (85 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, temporal features, and tail risk features
# - IC validation: Tail risk features validated on out-of-sample data (2025-10-08)

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-2.0.3.tar.gz (291.6 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-2.0.3-py3-none-any.whl (55.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: atr_adaptive_laguerre-2.0.3.tar.gz
  • Upload date:
  • Size: 291.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for atr_adaptive_laguerre-2.0.3.tar.gz
Algorithm Hash digest
SHA256 e797c33f72f402e132001787c62d9ce089d3ff21ea443f2717fb18b8029b9291
MD5 f7cd64b6933b26438a7e70d5e013a929
BLAKE2b-256 0a4d1a4cfefc0138a6f8bc62f7c9b0444e9d5f8a30a26d8ca4e7fab3aca0c261

See more details on using hashes here.

Provenance

The following attestation bundles were made for atr_adaptive_laguerre-2.0.3.tar.gz:

Publisher: publish.yml on terrylica/atr-adaptive-laguerre

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for atr_adaptive_laguerre-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d836bf13bd3c37e5fbbf6da9315aa53d7004a3179323778e70e039b60b25c263
MD5 3d2bdec50fda6034a692572168dbbb05
BLAKE2b-256 6219772ad73d77b731fec552440ea36d403e9b223ce394be08ef5b5e17f4c68a

See more details on using hashes here.

Provenance

The following attestation bundles were made for atr_adaptive_laguerre-2.0.3-py3-none-any.whl:

Publisher: publish.yml on terrylica/atr-adaptive-laguerre

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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