Stochastic RSI

Calculate the Stochastic RSI for a given price series.

The Stochastic RSI applies the Stochastic Oscillator to the Relative Strength Index instead of to price: it shows where the current RSI sits within its own high-low range over the last stochastic_window periods. Chande and Kroll (1994, “The New Technical Trader”) designed it because the RSI can spend long stretches between 30 and 70 without reaching either extreme; the Stochastic RSI reaches 0 and 100 far more often.

The formula is as follows:

\[\text{RSI} = \text{Relative Strength Index}(\text{Close},\; \text{window}),\;\; \text{with Wilder's smoothing}\] \[\%K = \frac{100 \cdot (\text{RSI} - \text{Lowest RSI})}{\text{Highest RSI} - \text{Lowest RSI}},\;\; \text{over the last stochastic\_window RSI values}\] \[\%D = \operatorname{SMA}(\%K,\; \text{smooth\_window})\]

The defaults follow Chande and Kroll’s definition, a 14-period stochastic of a 14-period RSI, which StockCharts and TradingView use as well. StockCharts shows this %K on a scale of 0 to 1; TradingView smooths it over 3 periods, so its %K is the %D here. TA-Lib’s STOCHRSI defaults to a 5-period stochastic instead (timeperiod 14, fastk_period 5 and fastd_period 3 with a simple average): pass stochastic_window=5 for its %K and %D. A %K of 100 means the RSI is at its highest of the window, not that the price is overbought, so the readings above 80 and below 20 come and go quickly and are mostly read together with the trend.

For more information, see the following sources:

Also known as: StochRSI, Stoch RSI.

Stochastic RSI in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_stochastic_relative_strength_index as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["NVDA"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2024-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_stochastic_relative_strength_index().xs("NVDA", level=1, axis="columns").tail(5)

Or, after setting up the Finance Toolkit MCP, ask:

How did the Stochastic RSI of Nvidia move from 24 to 31 December 2025?

Which returns:

Date Stochastic RSI %D Stochastic RSI %K
2025-12-24 98.8179 96.4537
2025-12-26 98.8179 100
2025-12-29 94.1715 86.0606
2025-12-30 89.3317 81.9345
2025-12-31 81.1377 75.418

Parameters

get_stochastic_relative_strength_index accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
windowintThe number of periods of the RSI. Defaults to 14.20
stochastic_windowintThe number of periods of RSI values whose high-low range gives %K. Defaults to 14.14
smooth_windowintThe number of periods used to smooth %K into the %D signal line. Defaults to 3.5
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the %K and %D values. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column
Share