Relative Strength Index — Wilder's momentum oscillator, bounded 0..100:
100 − 100/(1 + avgGain/avgLoss), where the averages are
wilderValues | Wilder-smoothed over period bars.
Appends one column; undefined for the first period rows. Note that is
period, not period − 1: RSI is computed from differences, so a
period-bar average of them needs period + 1 bars of input.
Definition
This is TA-Lib's RSI, which is Wilder's original (with one deliberate
delta on a flat window — see Edges): the gain/loss averages
are seeded on the arithmetic mean of the first period differences and then
carried by avg[i] = (avg[i−1]·(period−1) + x[i]) / period. Verified against
TA-Lib bar-for-bar in the oracle fixture — agreement to 1.4e-14.
The delta worth knowing about is against implementations that smooth with a
plain first-sample-seeded EMA (α = 1/period with no seed window), which is
what you get from a naive close.ewm(alpha=1/n, adjust=False). That is a
different indicator, not a rounding difference: on this package's own oracle
input it sits up to 7.03 RSI points away, still 0.15 out 65 bars
later. If you need that variant, it is ema(...) over your own gain/loss
columns rather than an option here — one RSI, matching the reference
implementation, is worth more than two that differ invisibly.
Edges
No losses in the window (avgLoss = 0) → RSI 100, the limit of the
formula rather than a division by zero.
A perfectly flat window (avgGain = avgLoss = 0) → undefined.
This is a deliberate delta from TA-Lib, which returns 0 there. The
ratio is 0/0: there is no relative strength to report, and 0 is the
same value TA-Lib gives for "every bar fell", so it conflates the
strongest possible downtrend with no movement at all. pond's studies
distinguish "no answer" from "an answer that happens to be zero"
everywhere else, so it does here too. Everything outside this case
matches TA-Lib to 1.4e-14.
A leading gap shifts the start, it doesn't kill the study. Running
over another study's output (whose own warm-up leaves missing rows at the
head) begins that many bars later and is otherwise unaffected.
An interior gap propagates to the end, because a recursion has no
state to carry across a hole. That is inherent to Wilder smoothing rather
than a choice; fill before smoothing if you need continuity across one.
Relative Strength Index — Wilder's momentum oscillator, bounded
0..100:100 − 100/(1 + avgGain/avgLoss), where the averages are wilderValues | Wilder-smoothed overperiodbars.Appends one column;
undefinedfor the firstperiodrows. Note that isperiod, notperiod − 1: RSI is computed from differences, so aperiod-bar average of them needsperiod + 1bars of input.Definition
This is TA-Lib's RSI, which is Wilder's original (with one deliberate delta on a flat window — see Edges): the gain/loss averages are seeded on the arithmetic mean of the first
perioddifferences and then carried byavg[i] = (avg[i−1]·(period−1) + x[i]) / period. Verified against TA-Lib bar-for-bar in the oracle fixture — agreement to1.4e-14.The delta worth knowing about is against implementations that smooth with a plain first-sample-seeded EMA (
α = 1/periodwith no seed window), which is what you get from a naiveclose.ewm(alpha=1/n, adjust=False). That is a different indicator, not a rounding difference: on this package's own oracle input it sits up to 7.03 RSI points away, still 0.15 out 65 bars later. If you need that variant, it isema(...)over your own gain/loss columns rather than an option here — one RSI, matching the reference implementation, is worth more than two that differ invisibly.Edges
avgLoss = 0) → RSI100, the limit of the formula rather than a division by zero.avgGain = avgLoss = 0) →undefined. This is a deliberate delta from TA-Lib, which returns0there. The ratio is0/0: there is no relative strength to report, and0is the same value TA-Lib gives for "every bar fell", so it conflates the strongest possible downtrend with no movement at all. pond's studies distinguish "no answer" from "an answer that happens to be zero" everywhere else, so it does here too. Everything outside this case matches TA-Lib to1.4e-14.