MCPcopy Create free account
hub / github.com/ScottfreeLLC/AlphaPy / diminus

Function diminus

alphapy/transforms.py:228–259  ·  view source on GitHub ↗

r"""Calculate the Minus Directional Indicator (-DI). Parameters ---------- f : pandas.DataFrame Dataframe with columns ``high`` and ``low``. p : int The period over which to calculate the -DI. Returns ------- new_column : pandas.Series (float) Th

(f, p = 14)

Source from the content-addressed store, hash-verified

226#
227
228def diminus(f, p = 14):
229 r"""Calculate the Minus Directional Indicator (-DI).
230
231 Parameters
232 ----------
233 f : pandas.DataFrame
234 Dataframe with columns ``high`` and ``low``.
235 p : int
236 The period over which to calculate the -DI.
237
238 Returns
239 -------
240 new_column : pandas.Series (float)
241 The array containing the new feature.
242
243 References
244 ----------
245 *A component of the average directional index (ADX) that is used to
246 measure the presence of a downtrend. When the -DI is sloping downward,
247 it is a signal that the downtrend is getting stronger* [IP_NDI]_.
248
249 .. [IP_NDI] http://www.investopedia.com/terms/n/negativedirectionalindicator.asp
250
251 """
252 tr = 'truerange'
253 vexec(f, tr)
254 atr = USEP.join(['atr', str(p)])
255 vexec(f, atr)
256 dmm = 'dmminus'
257 f[dmm] = dminus(f)
258 new_column = 100 * dminus(f).ewm(span=p).mean() / f[atr]
259 return new_column
260
261
262#

Callers

nothing calls this directly

Calls 2

vexecFunction · 0.90
dminusFunction · 0.85

Tested by

no test coverage detected