Skip to content

On Balance Volume

OBV measures buying and selling pressure based on volume flow.

Method

tm.ta.obv(source_close, source_volume)

Inputs

ParameterArgument typeDescriptionDefault Value
source_closepd.SeriesClose prices series-
source_volumepd.SeriesVolume series-

Outputs

OutputType
obvnp.ndarray

Example usage

strategy.py
import tradomate as tm
@tm.strategy()
def my_strategy(config: tm.TradomateConfig, data: tm.TradomateData):
# Trying out On Balance Volume
obv = tm.ta.obv(data.close, data.volume)
# Get the last value and print
last_value = obv.iloc[-1]
tm.log(f"Last value of On Balance Volume is {last_value}")
# Plot the values of obv
tm.plot(obv, title="On Balance Volume", overlay=False)