mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-08-15 12:45:08 +08:00
ENH #215 hwma indicator TST added DOC readme
This commit is contained in:
@@ -496,7 +496,7 @@ print(bothhl2.name) # "pre_HL2_post"
|
||||
|:--------:|
|
||||
|  |
|
||||
|
||||
### **Overlap** (30)
|
||||
### **Overlap** (31)
|
||||
|
||||
* _Double Exponential Moving Average_: **dema**
|
||||
* _Exponential Moving Average_: **ema**
|
||||
@@ -506,6 +506,7 @@ print(bothhl2.name) # "pre_HL2_post"
|
||||
* _High-Low-Close Average_: **hlc3**
|
||||
* Commonly known as 'Typical Price' in Technical Analysis literature
|
||||
* _Hull Exponential Moving Average_: **hma**
|
||||
* _Holt-Winter Moving Average_: **hwma**
|
||||
* _Ichimoku Kinkō Hyō_: **ichimoku**
|
||||
* Use: help(ta.ichimoku). Returns two DataFrames.
|
||||
* Drop the Chikou Span Column, the final column of the first resultant DataFrame, remove potential data leak.
|
||||
@@ -686,6 +687,7 @@ result = ta.cagr(df.close)
|
||||
* _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)```
|
||||
* _Holt-Winter Moving Average_ (**hwma**) is a three-parameter moving average by the Holt-Winter method.
|
||||
* _McGinley Dynamic_ (**mcgd**) is an overlap indicator developed by John R. McGinley, a Certified Market Technician. See: ```help(ta.mcgd)```
|
||||
* _Price Volume Rank_ (**pvr**) was created by Anthony J. Macek. See: ```help(ta.pvr)```
|
||||
* _Quantitative Qualitative Estimation_ (**qqe**) is like SuperTrend for a Smoothed RSI. See: ```help(ta.qqe)```
|
||||
|
||||
+10
-12
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# import numpy as np
|
||||
from pandas import Series
|
||||
from pandas_ta.utils import get_offset, verify_series
|
||||
|
||||
@@ -16,8 +15,8 @@ def hwma(close, na=None, nb=None, nc=None, offset=None, **kwargs):
|
||||
# Initialize ..
|
||||
m = close.size
|
||||
last_f = close[0]
|
||||
last_v = 0
|
||||
last_a = 0
|
||||
# last_a, last_v = 0, 0
|
||||
last_a = last_v = 0
|
||||
result = []
|
||||
|
||||
# Calculate ..
|
||||
@@ -25,14 +24,10 @@ def hwma(close, na=None, nb=None, nc=None, offset=None, **kwargs):
|
||||
F = (1.0 - na) * (last_f + last_v + 0.5 * last_a) + na * close[i]
|
||||
V = (1.0 - nb) * (last_v + last_a) + nb * (F - last_f)
|
||||
A = (1.0 - nc) * last_a + nc * (V - last_v)
|
||||
# print('F|V|A:', F, V, A)
|
||||
result.append((F + V + 0.5 * A))
|
||||
# update values
|
||||
last_a = A
|
||||
last_f = F
|
||||
last_v = V
|
||||
last_a, last_f, last_v = A, F, V
|
||||
|
||||
# Serialize ..
|
||||
hwma = Series(result, index=close.index)
|
||||
|
||||
# Offset
|
||||
@@ -45,8 +40,8 @@ def hwma(close, na=None, nb=None, nc=None, offset=None, **kwargs):
|
||||
if "fill_method" in kwargs:
|
||||
hwma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
suffix = f'{na}_{nb}_{nc}'
|
||||
# Name & Category
|
||||
suffix = f"{na}_{nb}_{nc}"
|
||||
hwma.name = f"HWMA_{suffix}"
|
||||
hwma.category = "overlap"
|
||||
|
||||
@@ -58,8 +53,11 @@ hwma.__doc__ = \
|
||||
"""HWMA (Holt-Winter Moving Average)
|
||||
|
||||
Indicator HWMA (Holt-Winter Moving Average) is a three-parameter moving average
|
||||
by the Holt-Winter method; the three parameters should be selected to obtain a forecast.
|
||||
This version has been implemented for Pandas TA by rengel8 based on a publication for MetaTrader 5.
|
||||
by the Holt-Winter method; the three parameters should be selected to obtain a
|
||||
forecast.
|
||||
|
||||
This version has been implemented for Pandas TA by rengel8 based
|
||||
on a publication for MetaTrader 5.
|
||||
|
||||
Sources:
|
||||
https://www.mql5.com/en/code/20856
|
||||
|
||||
@@ -53,6 +53,11 @@ class TestOverlapExtension(TestCase):
|
||||
self.assertIsInstance(self.data, DataFrame)
|
||||
self.assertEqual(self.data.columns[-1], "HMA_10")
|
||||
|
||||
def test_hwma_ext(self):
|
||||
self.data.ta.hwma(append=True)
|
||||
self.assertIsInstance(self.data, DataFrame)
|
||||
self.assertEqual(self.data.columns[-1], "HWMA_0.2_0.1_0.1")
|
||||
|
||||
def test_kama_ext(self):
|
||||
self.data.ta.kama(append=True)
|
||||
self.assertIsInstance(self.data, DataFrame)
|
||||
|
||||
@@ -99,6 +99,13 @@ class TestOverlap(TestCase):
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "HMA_10")
|
||||
|
||||
def test_hwma(self):
|
||||
result = pandas_ta.hwma(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
self.assertEqual(result.name, "HWMA_0.2_0.1_0.1")
|
||||
print(f"\n{result.head(30)}")
|
||||
print(f"\n{result.tail(30)}")
|
||||
|
||||
def test_kama(self):
|
||||
result = pandas_ta.kama(self.close)
|
||||
self.assertIsInstance(result, Series)
|
||||
|
||||
Reference in New Issue
Block a user