On-Balance Volume (OBV)

get_obv(quotes, sma_periods=None)

Parameters

name type notes
quotes Iterable[Quote] Iterable of the Quote class or its sub-class.
See here for usage with pandas.DataFrame
sma_periods int, Optional Number of periods (N) in the moving average of OBV. Must be greater than 0, if specified.

Historical quotes requirements

You must have at least two historical quotes to cover the warmup periods; however, since this is a trendline, more is recommended.

quotes is an Iterable[Quote] collection of historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

Return

OBVResults[OBVResult]

ObvResult

name type notes
date datetime Date
obv float On-balance Volume
obv_sma float, Optional Moving average (SMA) of OBV based on sma_periods periods, if specified

🚩 Warning: absolute values in OBV are somewhat meaningless. Use with caution.

Utilities

See Utilities and Helpers for more information.

Example

from stock_indicators import indicators

# This method is NOT a part of the library.
quotes = get_history_from_feed("SPY")

# Calculate
results = indicators.get_obv(quotes)

About On-Balance Volume (OBV)

Popularized by Joseph Granville, On-balance Volume is a rolling accumulation of volume based on Close price direction. [Discuss] 💬

image

Sources