MAINT pandas rma to core and kdj refactor

This commit is contained in:
Kevin Johnson
2021-11-27 12:23:03 -08:00
parent db8801cc6e
commit ca6b3d75e8
5 changed files with 14 additions and 7 deletions
+2 -2
View File
@@ -113,7 +113,7 @@ $ pip install pandas_ta
Latest Version
--------------
Best choice! Version: *0.3.35b*
Best choice! Version: *0.3.36b*
* Includes all fixes and updates between **pypi** and what is covered in this README.
```sh
$ pip install -U git+https://github.com/twopirllc/pandas-ta
@@ -1000,7 +1000,7 @@ print(pf.returns_stats())
<br />
# **Sources**
[Original TA-LIB](http://ta-lib.org/) | [TradingView](http://www.tradingview.com) | [Sierra Chart](https://search.sierrachart.com/?Query=indicators&submitted=true) | [MQL5](https://www.mql5.com) | [FM Labs](https://www.fmlabs.com/reference/default.htm) | [Pro Real Code](https://www.prorealcode.com/prorealtime-indicators) | [User 42](https://user42.tuxfamily.org/chart/manual/index.html)
[Original TA-LIB](http://ta-lib.org/) | [TradingView](http://www.tradingview.com) | [Sierra Chart](https://search.sierrachart.com/?Query=indicators&submitted=true) | [MQL5](https://www.mql5.com) | [FM Labs](https://www.fmlabs.com/reference/default.htm) | [Pro Real Code](https://www.prorealcode.com/prorealtime-indicators) | [User 42](https://user42.tuxfamily.org/chart/manual/index.html) | [Technical Traders](http://technical.traders.com/tradersonline/FeedTT-2014.html)
<br/>
+3 -4
View File
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame
from pandas_ta.overlap import rma
from pandas_ta.utils import get_offset, non_zero_range, verify_series
from pandas_ta.utils import get_offset, non_zero_range, rma_pandas, verify_series
def kdj(high=None, low=None, close=None, length=None, signal=None, offset=None, **kwargs):
@@ -61,8 +60,8 @@ def kdj(high=None, low=None, close=None, length=None, signal=None, offset=None,
fastk = 100 * (close - lowest_low) / non_zero_range(highest_high, lowest_low)
k = rma(fastk, length=signal)
d = rma(k, length=signal)
k = rma_pandas(fastk, length=signal)
d = rma_pandas(k, length=signal)
j = 3 * k - 2 * d
# Offset
+7
View File
@@ -67,6 +67,13 @@ def recent_minimum_index(x):
return int(argmin(x[::-1]))
def rma_pandas(series, length):
series = verify_series(series)
alpha = (1.0 / length) if length > 0 else 0.5
return series.ewm(alpha=alpha, min_periods=length).mean()
def signed_series(series: Series, initial: int, lag: int = None) -> Series:
"""Returns a Signed Series with or without an initial value
+1 -1
View File
@@ -19,7 +19,7 @@ setup(
"pandas_ta.volatility",
"pandas_ta.volume"
],
version=".".join(("0", "3", "35b")),
version=".".join(("0", "3", "36b")),
description=long_description,
long_description=long_description,
author="Kevin Johnson",
+1
View File
@@ -1,6 +1,7 @@
from .config import CORRELATION, CORRELATION_THRESHOLD, error_analysis, sample_data, VERBOSE
from .context import pandas_ta
from unittest import TestCase, skip
from unittest import TestCase
import pandas.testing as pdt
from pandas import DataFrame, Series