Volatility

Volatility Indicators — Measure the magnitude of price fluctuations.

Functions

ATR — Average True Range NATR — Normalized Average True Range TRANGE — True Range CHAIKIN_VOL — Chaikin Volatility MASS — Mass Index BBPERCENT — Bollinger %B BBWIDTH — Bollinger Bandwidth HISTORICAL_VOLATILITY — Annualized close-to-close volatility ULCER_INDEX — Ulcer Index STARC — Stoller Average Range Channels

ferro_ta.volatility.ATR(high, low, close, timeperiod=14, *, nan_policy='propagate')[source]

Average True Range.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Smoothing period (default 14).

  • nan_policy ({"propagate", "skip"}, optional) – "propagate" (default, TA-Lib semantics): a NaN input poisons every later value. "skip": rows with a non-finite input are dropped, the indicator runs on the remaining rows, and NaN is written back at the dropped rows (matches the streaming classes tick for tick).

Returns:

Array of ATR values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.volatility.BBPERCENT(close, timeperiod=5, nbdevup=2.0, nbdevdn=2.0)[source]

Bollinger %B — (close - lower) / (upper - lower).

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Bollinger window (default 5).

  • nbdevup (float, optional) – Upper-band standard deviations (default 2.0).

  • nbdevdn (float, optional) – Lower-band standard deviations (default 2.0).

Returns:

Array of %B values. Leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.volatility.BBWIDTH(close, timeperiod=5, nbdevup=2.0, nbdevdn=2.0)[source]

Bollinger Bandwidth — (upper - lower) / middle.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Bollinger window (default 5).

  • nbdevup (float, optional) – Upper-band standard deviations (default 2.0).

  • nbdevdn (float, optional) – Lower-band standard deviations (default 2.0).

Returns:

Array of bandwidth values. Leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.volatility.CHAIKIN_VOL(high, low, timeperiod=10, rocperiod=10)[source]

Chaikin Volatility — ROC of an EMA of the high–low range.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • timeperiod (int, optional) – EMA period of the range (default 10).

  • rocperiod (int, optional) – Rate-of-change lookback of that EMA (default 10).

Returns:

Array of Chaikin Volatility values (percent).

Return type:

numpy.ndarray

ferro_ta.volatility.HISTORICAL_VOLATILITY(close, timeperiod=20, annual=252.0)[source]

Close-to-close historical volatility, annualized and in percent.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Log-return window (default 20).

  • annual (float, optional) – Annualization factor (default 252).

Returns:

stddev(ln returns) * sqrt(annual) * 100. First valid value is at index timeperiod.

Return type:

numpy.ndarray

ferro_ta.volatility.MASS(high, low, timeperiod=9, sumperiod=25)[source]

Mass Index — rolling sum of the single/double EMA ratio of the range.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • timeperiod (int, optional) – EMA period (default 9).

  • sumperiod (int, optional) – Rolling-sum length of the EMA ratio (default 25).

Returns:

Array of Mass Index values.

Return type:

numpy.ndarray

ferro_ta.volatility.NATR(high, low, close, timeperiod=14)[source]

Normalized Average True Range.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of NATR values (percentage); leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.volatility.STARC(high, low, close, timeperiod=15, atr_period=15, multiplier=2.0)[source]

Stoller Average Range Channels — SMA(close) ± multiplier * ATR.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – SMA period of close (default 15).

  • atr_period (int, optional) – ATR period (default 15).

  • multiplier (float, optional) – ATR multiple (default 2.0).

Returns:

(upper, middle, lower).

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

ferro_ta.volatility.TRANGE(high, low, close)[source]

True Range.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • close (array-like) – Sequence of closing prices.

Returns:

Array of True Range values.

Return type:

numpy.ndarray

ferro_ta.volatility.ULCER_INDEX(close, timeperiod=14)[source]

Ulcer Index — RMS of percent drawdowns versus the rolling peak.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Peak and RMS lookback (default 14).

Returns:

Array of Ulcer Index values.

Return type:

numpy.ndarray