Calculate the On-Balance Volume (OBV) for a given price series.

The On-Balance Volume (OBV) is a technical indicator that uses volume flow to predict changes in stock price. It accumulates the volume on up days and subtracts the volume on down days. The resulting OBV line provides insights into the buying and selling pressure behind price movements.

The formula is as follows:

\[\text{OBV} = \text{Previous OBV} + \text{Volume if Close} > \text{Previous Close},\;\; \text{Previous OBV - Volume if Close < Previous Close},\;\; \text{and Previous OBV otherwise}\]

The level of OBV has no meaning by itself, since it depends on the first date of the data; only its direction and its divergences from price matter. A rising OBV while price moves sideways is read as accumulation ahead of a breakout, a falling OBV as distribution. A single day of very high volume, such as an index rebalance or an earnings day, can move the line for a long time.

Also known as: OBV, volume momentum.

On-Balance Volume (OBV) in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_on_balance_volume as shown below.

from financetoolkit import Toolkit

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

toolkit.technicals.get_on_balance_volume().tail(5)

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

How did the on-balance volume of Bitcoin, counted from the start of 2021, build up from 27 to 31 December 2025?

Which returns:

Date BTCUSD Benchmark
2025-12-27 -1.15162e+12 1.48569e+09
2025-12-28 -1.13646e+12 1.48569e+09
2025-12-29 -1.18487e+12 1.42314e+09
2025-12-30 -1.14929e+12 1.37597e+09
2025-12-31 -1.18312e+12 1.30183e+09

Parameters

get_on_balance_volume 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"
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 OBV. 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
Share