Skip to main content

Crate ta_indicators

Crate ta_indicators 

Source
Expand description

Warmup-exact batch port of TA-Lib technical indicators for Rust.

See crate README for module layout (lib.rs vs candles.rs) and parity policy.

§Example

use ta_indicators::{bollinger_bands, macd, rsi};

let closes = [100.0, 101.0, 102.0, 101.5, 103.0, 104.0, 103.5, 105.0];
let rsi_3 = rsi(&closes, 3);
let macd_out = macd(&closes, 3, 6, 3);
let bands = bollinger_bands(&closes, 3, 2.0);

assert_eq!(rsi_3.len(), closes.len());
assert_eq!(macd_out.macd.len(), closes.len());
assert_eq!(bands.middle.len(), closes.len());

Outputs use Option<f64> for numeric indicators. Warmup bars are None; emitted bars are matched against committed TA-Lib reference fixtures.

Structs§

AdxFamily
Aroon
BollingerBands
DirectionalMovement
LinearRegression
Macd
PriceContext
PriceTransforms
StochRsi

Functions§

ad
adosc
adx_family
apo
aroon
beta
Rolling BETA of real0 against real1 (TA-Lib BETA). Uses period trailing simple returns; beta = (n·Σxy − Σx·Σy) / (n·Σxx − (Σx)²) where x are real0 returns and y are real1 returns. First value at index period.
bollinger_bands
bop
cdl_2crows
Two crows: long white, then a black gapping up, then a black opening within the second body and closing within the first body. Always bearish.
cdl_3blackcrows
Three black crows: three long black candles with very short lower shadows, each opening within the prior body and closing progressively lower.
cdl_3inside
Three inside up/down: a long candle, a harami body engulfed by it, then a confirming candle of the opposite color to the first.
cdl_3linestrike
Three-line strike: three candles of one color, then a fourth of the opposite color that engulfs the prior run.
cdl_3outside
Three outside up/down: an engulfing pair confirmed by a third candle that continues in the engulfing direction.
cdl_3starsinsouth
Three stars in the south: a faltering downtrend of three black candles.
cdl_3whitesoldiers
Three white soldiers: three rising white candles with very short upper shadows and only modest body shrinkage.
cdl_abandonedbaby
Abandoned baby: a doji isolated by gaps from a long candle and a confirming candle of the opposite color.
cdl_advanceblock
Advance block: three rising white candles whose advance falters via shrinking bodies and lengthening upper shadows.
cdl_belthold
Belt hold: a long candle that opens at its extreme (no shadow on the open end).
cdl_breakaway
Breakaway: a five-candle gap-and-run that closes back through the gap.
cdl_closing_marubozu
Closing marubozu: long body with no shadow on the closing end.
cdl_concealbabyswall
Concealing baby swallow: four black candles where the third’s upper shadow pierces the second body and the fourth engulfs the third.
cdl_counterattack
Counterattack: two long opposite-colored candles that close at the same level.
cdl_darkcloudcover
Dark cloud cover: a black candle opening above a prior long white candle and closing well into its body.
cdl_doji
Doji: real body no larger than the doji-body average.
cdl_dojistar
Doji star: a long candle followed by a gapping doji.
cdl_dragonfly_doji
Dragonfly doji: doji body with a negligible upper shadow and a long lower shadow.
cdl_engulfing
Engulfing: a candle whose real body fully engulfs the prior opposite-colored body (±80 when one end exactly matches).
cdl_eveningdojistar
Evening doji star: long white, gapping doji, then a black candle closing well into the first body.
cdl_eveningstar
Evening star: long white, a short-bodied star gapping up, then a black candle closing well into the first body.
cdl_gapsidesidewhite
Up/down-gap side-by-side white lines: a gap followed by two similar white candles.
cdl_gravestone_doji
Gravestone doji: doji body with a negligible lower shadow and a long upper shadow.
cdl_hammer
Hammer: a small-bodied candle with a long lower shadow near the prior lows.
cdl_hangingman
Hanging man: a small-bodied candle with a long lower shadow near the prior highs.
cdl_harami
Harami: a small real body engulfed by the prior long body (±80 when one end matches).
cdl_haramicross
Harami cross: a harami whose inside candle is a doji.
cdl_high_wave
High-wave: small body with very long shadows on both sides.
cdl_hikkake
Hikkake: an inside bar followed by a false breakout, optionally confirmed within three bars (±200 on confirmation). Stateful across bars.
cdl_hikkakemod
Modified hikkake: a three-bar inside formation with a close near the second candle’s extreme, optionally confirmed within three bars. Stateful.
cdl_homingpigeon
Homing pigeon: a small black body engulfed by a prior long black body.
cdl_identical3crows
Identical three crows: three black candles whose opens match the prior closes.
cdl_inneck
In-neck: a black candle followed by a white one closing just into the prior body.
cdl_invertedhammer
Inverted hammer: a small-bodied candle with a long upper shadow gapping down.
cdl_kicking
Kicking: two opposite marubozu separated by a gap.
cdl_kickingbylength
Kicking by length: like kicking, but the result follows the longer marubozu.
cdl_ladderbottom
Ladder bottom: three declining black candles, a black candle with an upper shadow, then a white candle breaking out.
cdl_long_legged_doji
Long-legged doji: doji body with at least one long shadow.
cdl_long_line
Long white/black line: long body with short shadows.
cdl_marubozu
Marubozu: long body with negligible shadows on both ends.
cdl_matchinglow
Matching low: two black candles closing at the same level.
cdl_mathold
Mat hold: a long white candle, an upside gap, three holding candles, then a white candle breaking out.
cdl_morningdojistar
Morning doji star: long black, gapping doji, then a white candle closing well into the first body.
cdl_morningstar
Morning star: long black, a short-bodied star gapping down, then a white candle closing well into the first body.
cdl_onneck
On-neck: a black candle followed by a white one closing at the prior low.
cdl_piercing
Piercing: a black candle followed by a white candle opening below the prior low and closing above the prior midpoint.
cdl_rickshawman
Rickshaw man: a long-legged doji whose body sits near the high-low midpoint.
cdl_risefall3methods
Rising/falling three methods: a long candle, three small counter-trend candles held within its range, then a long continuation candle.
cdl_separatinglines
Separating lines: a candle that opens at the prior open but reverses into a long belt-hold of the opposite color.
cdl_shootingstar
Shooting star: a small-bodied candle with a long upper shadow gapping up.
cdl_short_line
Short line: short body with short shadows.
cdl_spinning_top
Spinning top: small body with both shadows longer than the body.
cdl_stalledpattern
Stalled pattern: two long white candles then a small white candle riding the second’s shoulder.
cdl_sticksandwich
Stick sandwich: a black candle, a white candle trading above it, then a black candle closing at the first close.
cdl_takuri
Takuri: a doji-bodied candle with a very long lower shadow and negligible upper shadow.
cdl_tasukigap
Tasuki gap: a gap followed by an opposite-colored candle of similar size that fails to close the gap.
cdl_thrusting
Thrusting: a black candle followed by a white candle closing into, but under the midpoint of, the prior body.
cdl_tristar
Tristar: three doji where the middle one gaps away from the others.
cdl_unique3river
Unique three river bottom: a long black candle, a black harami making a new low, then a small white candle.
cdl_upsidegap2crows
Upside gap two crows: a long white candle, a short black gapping up, then a black candle engulfing it but still closing above the first.
cdl_xsidegap3methods
Up/down-gap three methods: a gap between two same-colored candles filled by a third opposite candle.
cmo
correl
Rolling Pearson correlation of real0 and real1 (TA-Lib CORREL) over a trailing window of raw values. First value at index period - 1; when the variance product is non-positive TA-Lib emits 0.0.
dema
directional_movement
ema
ht_dcperiod
HT_DCPERIOD — dominant cycle period.
ht_dcphase
HT_DCPHASE — dominant cycle phase.
ht_phasor
HT_PHASOR — (in-phase, quadrature) components.
ht_sine
HT_SINE — (sine, lead sine) wave.
ht_trendline
HT_TRENDLINE — instantaneous trendline.
ht_trendmode
HT_TRENDMODE — trend vs cycle mode (1 = trend, 0 = cycle; warmup zero-filled).
kama
linear_regression
macd
macdext_sma
MACDEXT with all three moving averages set to SMA (TA-Lib matype = 0). fast SMA − slow SMA forms the MACD line; an SMA over the MACD line forms the signal. Matches talib.MACDEXT(.., fastmatype=0, slowmatype=0, signalmatype=0).
macdfix
mama
MAMA — (MAMA, FAMA) adaptive moving averages.
mavp
Variable-period simple moving average (TA-Lib MAVP, matype = 0). Each bar uses periods[idx] truncated to an integer and clamped to [min_period, max_period]; the global warmup is max_period - 1 so every emitted bar has a full window.
ppo
price_context
price_transforms
rolling_sum
rsi
sar
sarext
Parabolic SAR Extended (TA-Lib SAREXT). Mirrors the proven sar core but adds: explicit start value / initial direction, per-side acceleration (init/step/max for long and short), an offset-on-reverse, and TA-Lib’s sign convention where short bars are emitted as the negated SAR. First value at index 1.
stochrsi
t3
tema
trix
ultosc