Indicators¶
Technical indicators for Codon strategies. Two types:
- Batch — compute over an entire array at once (calls C++ via C API)
- Streaming — update one value at a time per tick (pure Codon, compiled to native)
Batch indicators¶
from flox.indicators import ema, sma, rsi, atr, macd, bollinger
from flox.indicators import Skewness, Kurtosis, RollingZScore, ShannonEntropy
from flox.indicators import ParkinsonVol, RogersSatchellVol, Correlation
Single value — returns List[float]:
ema(data, period), sma(data, period), rma(data, period), rsi(data, period), dema(data, period), tema(data, period), kama(data, period)
OHLC / multi-input — returns List[float]:
atr(high, low, close, period), ParkinsonVol.compute(high, low, period), RogersSatchellVol.compute(open, high, low, close, period), Correlation.compute(x, y, period)
Statistical — returns List[float]:
Skewness.compute(data, period), Kurtosis.compute(data, period), RollingZScore.compute(data, period), ShannonEntropy.compute(data, period, bins)
Multi-output:
macd(data, fast=12, slow=26, signal=9) — returns MacdResult: .line, .signal, .histogram
bollinger(data, period=20, multiplier=2.0) — returns BollingerResult: .upper, .middle, .lower
values = ema(prices, 20)
m = macd(prices, 12, 26, 9)
print(m.line[-1], m.signal[-1])
ranges = atr(highs, lows, closes, 14)
Streaming indicators¶
All streaming indicators share the same pattern: call update() each tick, read .value, check .ready. All support .reset() to clear state.
from flox.indicators import EMA, SMA, RSI, ATR, MACD, Bollinger
from flox.indicators import RMA, DEMA, TEMA, KAMA, Slope
from flox.indicators import OBV, VWAP, CVD
from flox.indicators import Skewness, Kurtosis, RollingZScore, ShannonEntropy
from flox.indicators import ParkinsonVol, RogersSatchellVol, Correlation
Single-price indicators¶
EMA¶
SMA¶
Uses a circular buffer for O(1) updates.
RMA¶
Wilder's Moving Average (used internally by RSI and ATR).
DEMA¶
Double Exponential Moving Average. .ready is true after 2 * period values.
TEMA¶
Triple Exponential Moving Average. .ready is true after 3 * period values.
KAMA¶
Kaufman's Adaptive Moving Average.
Slope¶
Linear regression slope over a rolling window.
RSI¶
Skewness¶
Fisher-Pearson skewness. Requires period >= 3.
Kurtosis¶
Fisher excess kurtosis. Requires period >= 4.
RollingZScore¶
(x - mean) / std.
ShannonEntropy¶
Rolling Shannon entropy, normalized to [0, 1].
Multi-value indicators¶
ATR¶
MACD¶
macd = MACD(fast=12, slow=26, signal=9)
macd.update(price)
if macd.ready:
print(macd.line, macd.signal, macd.histogram)
Bollinger¶
bb = Bollinger(period=20, multiplier=2.0)
bb.update(price)
if bb.ready:
print(bb.upper, bb.middle, bb.lower)
ParkinsonVol¶
Parkinson high-low volatility estimator.
RogersSatchellVol¶
Rogers-Satchell OHLC volatility estimator.
Correlation¶
Rolling Pearson correlation between two series.
Volume indicators¶
OBV¶
On-Balance Volume.
VWAP¶
Volume Weighted Average Price.
CVD¶
Cumulative Volume Delta.
Aliases¶
StreamingEMA and StreamingSMA are available as aliases for EMA and SMA for backward compatibility.
Indicator catalog¶
Every indicator below is one Codon class with both a batch
compute() method and streaming update() / value / ready / reset().
| Indicator | Constructor | Kind |
|---|---|---|
EMA |
flox.EMA(size_t period) |
SingleInput |
SMA |
flox.SMA(size_t period) |
SingleInput |
RMA |
flox.RMA(size_t period) |
SingleInput |
RSI |
flox.RSI(size_t period) |
SingleInput |
KAMA |
flox.KAMA(size_t period, size_t fast, size_t slow) |
SingleInput |
DEMA |
flox.DEMA(size_t period) |
SingleInput |
TEMA |
flox.TEMA(size_t period) |
SingleInput |
Slope |
flox.Slope(size_t length) |
SingleInput |
Skewness |
flox.Skewness(size_t period) |
SingleInput |
Kurtosis |
flox.Kurtosis(size_t period) |
SingleInput |
RollingZScore |
flox.RollingZScore(size_t period) |
SingleInput |
ShannonEntropy |
flox.ShannonEntropy(size_t period, size_t bins) |
SingleInput |
AutoCorrelation |
flox.AutoCorrelation(size_t window, size_t lag) |
SingleInput |
ATR |
flox.ATR(size_t period) |
BarInput |
CCI |
flox.CCI(size_t period) |
BarInput |
Stochastic |
flox.Stochastic(size_t k_period, size_t d_period) |
BarInput |
ParkinsonVol |
flox.ParkinsonVol(size_t period) |
HighLowInput |
RogersSatchellVol |
flox.RogersSatchellVol(size_t period) |
OhlcInput |
Correlation |
flox.Correlation(size_t period) |
PairInput |
MACD |
flox.MACD(size_t fast, size_t slow, size_t signal) |
MultiOutput |
Bollinger |
flox.Bollinger(size_t period, double stddev) |
MultiOutput |