Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:51bitquant Ai hedge fund crypto Technical Indicators

From Leeroopedia
Knowledge Sources
Domains Technical_Analysis, Signal_Generation
Last Updated 2026-10-28 14:00 GMT

Overview

Concrete tool for computing the five quantitative signal families (trend, mean-reversion, momentum, volatility, statistical-arbitrage) and their supporting indicators provided by the `general_indicators` module.

Description

The general_indicators module exposes five signal calculators and a combiner used by MacdStrategy:

  • calculate_trend_signals — EMAs(8,21,55) + ADX(14); bullish/bearish when short & medium EMA agree, confidence from ADX strength.
  • calculate_mean_reversion_signals — 50-period z-score + Bollinger Band position + RSI(14,28); bullish when z<-2 & price near lower band, bearish when z>2 & price near upper band.
  • calculate_momentum_signals — 1m/3m/6m return momentum with volume confirmation; bullish/bearish when |score|>0.05 and volume ratio >1.0.
  • calculate_volatility_signals — annualized historical volatility (21d), regime ratio (63d MA), vol z-score, ATR ratio; bullish in low-vol expansion, bearish in high-vol contraction.
  • calculate_stat_arb_signals — rolling skew/kurtosis (63d) + Hurst exponent; directional when H<0.4 and |skew|>1.

Each returns `{"signal": "bullish"|"neutral"|"bearish", "confidence": float, "metrics": {...}}`.

Usage

Import these functions when building a custom strategy that needs individual technical signals, or when extending the ensemble in `MacdStrategy`. Each function takes an OHLCV `pd.DataFrame` (with `open`, `high`, `low`, `close`, `volume` columns).

Code Reference

Source Location

Signature

def calculate_trend_signals(prices_df: pd.DataFrame) -> dict
def calculate_mean_reversion_signals(prices_df: pd.DataFrame) -> dict
def calculate_momentum_signals(prices_df: pd.DataFrame) -> dict
def calculate_volatility_signals(prices_df: pd.DataFrame) -> dict
def calculate_stat_arb_signals(prices_df: pd.DataFrame) -> dict

# Supporting indicators
def calculate_rsi(prices_df: pd.DataFrame, period: int = 14) -> pd.Series
def calculate_bollinger_bands(prices_df: pd.DataFrame, window: int = 20) -> tuple[pd.Series, pd.Series]
def calculate_ema(df: pd.DataFrame, window: int) -> pd.Series
def calculate_adx(df: pd.DataFrame, period: int = 14) -> pd.DataFrame
def calculate_atr(df: pd.DataFrame, period: int = 14) -> pd.Series
def calculate_hurst_exponent(price_series: pd.Series, max_lag: int = 20) -> float

Import

from src.indicators.general_indicators import (
    calculate_trend_signals,
    calculate_mean_reversion_signals,
    calculate_momentum_signals,
    calculate_volatility_signals,
    calculate_stat_arb_signals,
    calculate_rsi,
    calculate_bollinger_bands,
    calculate_ema,
    calculate_adx,
    calculate_atr,
    calculate_hurst_exponent,
)

I/O Contract

Inputs

Name Type Required Description
prices_df pd.DataFrame Yes OHLCV DataFrame with columns `open`, `high`, `low`, `close`, `volume`
period/window int No Lookback window for supporting indicators (per-function defaults)

Outputs

Name Type Description
signal result dict `{"signal": str, "confidence": float (0-1), "metrics": dict}`
rsi / bollinger / ema / atr tuple Computed indicator series
adx pd.DataFrame Columns `["adx", "+di", "-di"]`
hurst_exponent float H in [0,1]; H<0.5 mean-reverting, H>0.5 trending

Usage Examples

Compute Individual Signals

from src.indicators.general_indicators import (
    calculate_trend_signals,
    calculate_mean_reversion_signals,
    calculate_rsi,
)

# df is an OHLCV DataFrame from BinanceDataProvider
trend = calculate_trend_signals(df)
print(trend["signal"], trend["confidence"], trend["metrics"]["adx"])

mean_rev = calculate_mean_reversion_signals(df)
print(mean_rev["metrics"]["z_score"], mean_rev["metrics"]["rsi_14"])

rsi = calculate_rsi(df, period=14)
print("Latest RSI:", rsi.iloc[-1])

Build a Custom Ensemble

from src.indicators.general_indicators import (
    calculate_trend_signals, calculate_momentum_signals, weighted_signal_combination,
)

signals = {
    "trend": calculate_trend_signals(df),
    "momentum": calculate_momentum_signals(df),
}
weights = {"trend": 0.6, "momentum": 0.4}
combined = weighted_signal_combination(signals, weights)
print(combined["signal"], combined["confidence"])

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment