Ulcer Index (UI)

get_ulcer_index(quotes, lookback_periods=14)

Parameters

name type notes
quotes Iterable[Quote] Iterable of the Quote class or its sub-class.
See here for usage with pandas.DataFrame
lookback_periods int, default 14 Number of periods (N) for review. Must be greater than 0.

Historical quotes requirements

You must have at least N periods of quotes to cover the warmup periods.

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

UlcerIndexResults[UlcerIndexResult]

UlcerIndexResult

name type notes
date datetime Date
ui float, Optional Ulcer Index

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 UI(14)
results = indicators.get_ulcer_index(quotes, 14)

About Ulcer Index (UI)

Created by Peter Martin, the Ulcer Index is a measure of downside Close price volatility over a lookback window. [Discuss] 💬

image

Sources