Archer On-Balance Volume (AOBV)

Calculate the Archer On-Balance Volume (AOBV): a fast and a slow average of the On-Balance Volume and whether the volume trend is up or down.

The Archer On-Balance Volume adds a fast and a slow exponential moving average of On-Balance Volume and two flags for their trend, so OBV can be read like a moving average crossover system. A “long run” is a period in which the fast average rose over the last run_window periods while the slow one moved (a rising OBV trend or a potential bottom); a “short run” one in which the fast average fell (a falling trend or a potential top). The rolling minimum and maximum of OBV mark its recent range.

The formula is as follows:

\[\text{OBV} = \text{Cumulative Sum}(\operatorname{sign}(\text{Close} - \operatorname{Close}(t-1)) \cdot \text{Volume}),\;\; \text{starting at 0 on the start date}\] \[\text{Fast Average} = \operatorname{EMA}(\text{OBV},\; \text{short\_window}),\;\; \text{Slow Average} = \operatorname{EMA}(\text{OBV},\; \text{long\_window})\] \[\text{Minimum} = \min(\text{OBV},\; \text{extreme\_window}),\;\; \text{Maximum} = \max(\text{OBV},\; \text{extreme\_window})\] \[\text{Long Run} = 1 \;\text{if Fast Average rose over} \;\text{run\_window} \;\text{periods and the Slow Average changed},\;\; \text{else 0}\] \[\text{Short Run} = 1 \;\text{if Fast Average fell over} \;\text{run\_window} \;\text{periods and the Slow Average changed},\;\; \text{else 0}\]

Also known as: AOBV, Archer OBV.

Example · AAPL, MSFT · 2021 to 2025

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

from financetoolkit import Toolkit

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

archer_obv = toolkit.technicals.get_archer_on_balance_volume(
    show_columns=["On-Balance Volume", "Fast Average", "Slow Average", "Long Run", "Short Run"]
)

archer_obv.xs("AAPL", level=1, axis="columns")

Which returns:

Parameters

get_archer_on_balance_volume 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”."Close"
short_windowintThe number of periods for the fast EMA of OBV. Defaults to 4.4
long_windowintThe number of periods for the slow EMA of OBV. Defaults to 12.12
extreme_windowintThe number of periods for the rolling minimum and maximum of OBV. Defaults to 2.2
run_windowintThe number of periods over which the averages must rise or fall. Defaults to 2.2
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 indicator 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

References

  • Paper Granville, J.E. (1963). “Granville’s New Key to Stock Market Profits.” Prentice-Hall.
  • Library Referenced against pandas-ta-classic’s aobv
Share