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

Function xmadown

alphapy/transforms.py:1568–1604  ·  view source on GitHub ↗

r"""Determine those values of the dataframe that are below the moving average. Parameters ---------- f : pandas.DataFrame Dataframe containing the column ``c``. c : str, optional Name of the column in the dataframe ``f``. pfast : int, optional The per

(f, c='close', pfast = 20, pslow = 50)

Source from the content-addressed store, hash-verified

1566#
1567
1568def xmadown(f, c='close', pfast = 20, pslow = 50):
1569 r"""Determine those values of the dataframe that are below the
1570 moving average.
1571
1572 Parameters
1573 ----------
1574 f : pandas.DataFrame
1575 Dataframe containing the column ``c``.
1576 c : str, optional
1577 Name of the column in the dataframe ``f``.
1578 pfast : int, optional
1579 The period of the fast moving average.
1580 pslow : int, optional
1581 The period of the slow moving average.
1582
1583 Returns
1584 -------
1585 new_column : pandas.Series (bool)
1586 The array containing the new feature.
1587
1588 References
1589 ----------
1590 *In the statistics of time series, and in particular the analysis
1591 of financial time series for stock trading purposes, a moving-average
1592 crossover occurs when, on plotting two moving averages each based
1593 on different degrees of smoothing, the traces of these moving averages
1594 cross* [WIKI_XMA]_.
1595
1596 .. [WIKI_XMA] https://en.wikipedia.org/wiki/Moving_average_crossover
1597
1598 """
1599 sma = ma(f, c, pfast)
1600 sma_prev = sma.shift(1)
1601 lma = ma(f, c, pslow)
1602 lma_prev = lma.shift(1)
1603 new_column = (sma < lma) & (sma_prev > lma_prev)
1604 return new_column
1605
1606
1607#

Callers

nothing calls this directly

Calls 1

maFunction · 0.85

Tested by

no test coverage detected