BUG swma triangle correction

This commit is contained in:
Kevin Johnson
2020-06-03 09:16:27 -07:00
parent 16ee6f85bc
commit feb9960741
5 changed files with 6 additions and 5 deletions
+1
View File
@@ -58,6 +58,7 @@ All the indicators return a named Series or a DataFrame in uppercase underscore
Bollinger Bands (bbands)
Commodity Channel Index (cci)
Chande Momentum Oscillator (cmo)
Symmetric Weighted Moving Average (swma)
## What is a Pandas DataFrame Extension?
+1 -1
View File
@@ -15,7 +15,7 @@ from pandas_ta.volatility import *
from pandas_ta.volume import *
from pandas_ta.utils import *
version = ".".join(("0", "1", "68b"))
version = ".".join(("0", "1", "69b"))
def finalize(method):
@wraps(method)
+1 -1
View File
@@ -38,7 +38,7 @@ def rvi(open_, high, low, close, length=None, swma_length=None, offset=None, **k
# Name & Category
rvi.name = f"RVI_{length}_{swma_length}"
signal.name = f"RVIS_{length}_{swma_length}"
signal.name = f"RVIs_{length}_{swma_length}"
rvi.category = signal.category = 'momentum'
# Prepare DataFrame to return
+2 -2
View File
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from ..utils import get_offset, pascals_triangle, verify_series, weights
from ..utils import get_offset, symmetric_triangle, verify_series, weights
def swma(close, length=None, asc=None, offset=None, **kwargs):
"""Indicator: Symmetric Weighted Moving Average (SWMA)"""
@@ -11,7 +11,7 @@ def swma(close, length=None, asc=None, offset=None, **kwargs):
offset = get_offset(offset)
# Calculate Result
triangle = pascals_triangle(n=length - 1, weighted=True)
triangle = symmetric_triangle(length, weighted=True)
swma = close.rolling(length, min_periods=length).apply(weights(triangle), raw=True)
# Offset
+1 -1
View File
@@ -126,7 +126,7 @@ class TestMomentumExtension(TestCase):
def test_rvi_ext(self):
self.data.ta.rvi(append=True)
self.assertIsInstance(self.data, DataFrame)
self.assertEqual(list(self.data.columns[-2:]), ['RVI_14_4', 'RVIS_14_4'])
self.assertEqual(list(self.data.columns[-2:]), ['RVI_14_4', 'RVIs_14_4'])
def test_slope_ext(self):
self.data.ta.slope(append=True)