mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-08-02 12:50:22 +08:00
BUG swma triangle correction
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user