ENH #216 alma indicator TST added DOC readme

This commit is contained in:
Kevin Johnson
2021-02-19 11:06:03 -08:00
parent fb916b884a
commit 82f12be4e6
5 changed files with 28 additions and 13 deletions
+5 -3
View File
@@ -14,7 +14,7 @@ Pandas TA - A Technical Analysis Library in Python 3
![Example Chart](/images/TA_Chart.png)
_Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that leverages the Pandas library with more than 120 Indicators and Utility functions. Many commonly used indicators are included, such as: _Simple Moving Average_ (**sma**) _Moving Average Convergence Divergence_ (**macd**), _Hull Exponential Moving Average_ (**hma**), _Bollinger Bands_ (**bbands**), _On-Balance Volume_ (**obv**), _Aroon & Aroon Oscillator_ (**aroon**), _Squeeze_ (**squeeze**) and **_many more_**.
_Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that leverages the Pandas library with more than 130 Indicators and Utility functions. Many commonly used indicators are included, such as: _Simple Moving Average_ (**sma**) _Moving Average Convergence Divergence_ (**macd**), _Hull Exponential Moving Average_ (**hma**), _Bollinger Bands_ (**bbands**), _On-Balance Volume_ (**obv**), _Aroon & Aroon Oscillator_ (**aroon**), _Squeeze_ (**squeeze**) and **_many more_**.
<br/>
@@ -59,7 +59,7 @@ _Pandas Technical Analysis_ (**Pandas TA**) is an easy to use library that lever
# **Features**
* Has 120+ indicators and utility functions.
* Has 130+ indicators and utility functions.
* Indicators are tightly correlated with the de facto [TA Lib](https://mrjbq7.github.io/ta-lib/) if they share common indicators.
* Have the need for speed? By using the DataFrame _strategy_ method, you get **multiprocessing** for free!
* Easily add _prefixes_ or _suffixes_ or both to columns names. Useful for Custom Chained Strategies.
@@ -496,8 +496,9 @@ print(bothhl2.name) # "pre_HL2_post"
|:--------:|
| ![Example MACD](/images/SPY_MACD.png) |
### **Overlap** (30)
### **Overlap** (31)
* _Arnaud Legoux Moving Average_: **alma**
* _Double Exponential Moving Average_: **dema**
* _Exponential Moving Average_: **ema**
* _Fibonacci's Weighted Moving Average_: **fwma**
@@ -683,6 +684,7 @@ result = ta.cagr(df.close)
## **New Indicators**
* _Arnaud Legoux Moving Average_ (**alma**) uses the curve of the Normal (Gauss) distribution to allow regulating the smoothness and high sensitivity of the indicator. See: ```help(ta.alma)```
* _Drawdown_ (**drawdown**) shows the peak-to-trough decline during a specific period for an investment,
trading account, or fund. See: ```help(ta.drawdown)```
* _Gann High-Low Activator_ (**hilo**) was created by Robert Krausz in a 1998. See: ```help(ta.hilo)```
+11 -8
View File
@@ -18,8 +18,8 @@ def alma(close, length=None, sigma=None, distribution_offset=None, offset=None,
m = (distribution_offset * (length - 1))
s = length / sigma
wtd = list(range(length))
for j in range(0, length):
wtd[j] = math.exp(-1 * ((j - m) * (j - m)) / (2 * s * s))
for i in range(0, length):
wtd[i] = math.exp(-1 * ((i - m) * (i - m)) / (2 * s * s))
# Calculate Result
result = [npNaN for _ in range(0, length - 1)] + [0]
@@ -49,7 +49,7 @@ def alma(close, length=None, sigma=None, distribution_offset=None, offset=None,
alma.fillna(method=kwargs["fill_method"], inplace=True)
# Name & Category
alma.name = f"ALMA_{length}"
alma.name = f"ALMA_{length}_{sigma}_{distribution_offset}"
alma.category = "overlap"
return alma
@@ -58,10 +58,11 @@ def alma(close, length=None, sigma=None, distribution_offset=None, offset=None,
alma.__doc__ = \
"""Arnaud Legoux Moving Average (ALMA)
The ALMA moving average uses the curve of the Normal (Gauss) distribution, which can be shifted
from 0 to 1. This allows regulating the smoothness and high sensitivity of the indicator.
Sigma is another parameter that is responsible for the shape of the curve coefficients. This moving average
reduces lag of the data in conjunction with smoothing to reduce noise.
The ALMA moving average uses the curve of the Normal (Gauss) distribution, which
can be shifted from 0 to 1. This allows regulating the smoothness and high
sensitivity of the indicator. Sigma is another parameter that is responsible for
the shape of the curve coefficients. This moving average reduces lag of the data
in conjunction with smoothing to reduce noise.
Implemented for Pandas TA by rengel8 based on the source provided below.
@@ -75,7 +76,9 @@ Args:
close (pd.Series): Series of 'close's
length (int): It's period, window size. Default: 10
sigma (float): Smoothing value. Default 6.0
distribution_offset (float): Value to offset the distribution min 0 (smoother), max 1 (more responsive). Default 0.85
distribution_offset (float):
Value to offset the distribution min 0 (smoother),
max 1 (more responsive). Default 0.85
offset (int): How many periods to offset the result. Default: 0
Kwargs:
+2 -2
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from distutils.core import setup
long_description = "An easy to use Python 3 Pandas Extension with 115+ Technical Analysis Indicators. Can be called from a Pandas DataFrame or standalone like TA-Lib. Correlation tested with TA-Lib."
long_description = "An easy to use Python 3 Pandas Extension with 130+ Technical Analysis Indicators. Can be called from a Pandas DataFrame or standalone like TA-Lib. Correlation tested with TA-Lib."
setup(
name="pandas_ta",
@@ -17,7 +17,7 @@ setup(
"pandas_ta.volatility",
"pandas_ta.volume"
],
version=".".join(("0", "2", "42b")),
version=".".join(("0", "2", "43b")),
description=long_description,
long_description=long_description,
author="Kevin Johnson",
+5
View File
@@ -18,6 +18,11 @@ class TestOverlapExtension(TestCase):
def tearDown(self): pass
def test_alma_ext(self):
self.data.ta.alma(append=True)
self.assertIsInstance(self.data, DataFrame)
self.assertEqual(self.data.columns[-1], "ALMA_10_6.0_0.85")
def test_dema_ext(self):
self.data.ta.dema(append=True)
self.assertIsInstance(self.data, DataFrame)
+5
View File
@@ -34,6 +34,11 @@ class TestOverlap(TestCase):
def tearDown(self): pass
def test_alma(self):
result = pandas_ta.alma(self.close)# , length=None, sigma=None, distribution_offset=)
self.assertIsInstance(result, Series)
self.assertEqual(result.name, "ALMA_10_6.0_0.85")
def test_dema(self):
result = pandas_ta.dema(self.close)
self.assertIsInstance(result, Series)