Random Walk Index

Calculate Poulos’ Random Walk Index (RWI): how much larger the move up (or down) is than a random walk would make over the same number of periods, so above 1 a trend.

A random walk moves on average by its average range times the square root of the number of periods. The Random Walk Index of Poulos (1991) divides the move from a low (high) k periods ago to the current high (low) by that expected move and takes the largest ratio over the lookbacks from 2 to the window. An RWI High above 1 means the prices rose further than chance would carry them, an uptrend; an RWI Low above 1 a downtrend. When both are below 1 the market moves at random.

\(\text{ATR}_{k}\) is the average True Range over the last k periods, and the max runs over k from 2 to window.

The formula is as follows:

\[\text{ATR}_{k} = \text{SMA}(\text{True Range}, k)\] \[\text{RWI High} = \max\left(\frac{\text{High} - \text{Low}_{t-k}}{\text{ATR}_{k} \cdot \sqrt{k}}\right)\] \[\text{RWI Low} = \max\left(\frac{\text{High}_{t-k} - \text{Low}}{\text{ATR}_{k} \cdot \sqrt{k}}\right)\]

Also known as: RWI, Random Walk Index.

Example · AAPL · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_random_walk_index:

from financetoolkit import Toolkit

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

toolkit.technicals.get_random_walk_index().xs("AAPL", level=1, axis="columns")

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

Did Apple's share price trend up or down more than a random walk would over the last five trading days of 2025, by the Random Walk Index on data from 2021?

Which returns:

Parameters

get_random_walk_index accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the high and low prices are adjusted for dividends in the same way."Close"
windowintThe longest lookback, at least 2. Defaults to 14.20
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 Random Walk Index. 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
transformstr | list[str] | NoneTime series steps applied in order, such as “sma:12” (moving average), “ema:12”, “std:12”, “zscore:60”, “percentile:120”, “yoy”, “pct_change:3,annualize:3”, “log”, “diff”, “cumsum” or “hp_trend” and “hp_cycle” (Hodrick-Prescott), before growth. A window needs that many periods of history, so the first periods can be empty. Defaults to None.None
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

References

  • Paper Poulos, E.M. (1991). “Of Trends and Random Walks.” Technical Analysis of Stocks & Commodities, 9(2), 49-52.
  • Library Shares similar logic as pandas-ta’s rwi
Share