BUG #365 #369 #373 #397 #405 ENH #370 #399 stochastic sample added

This commit is contained in:
Kevin Johnson
2021-10-15 17:14:38 -07:00
parent eeba463596
commit cf44f89c21
5 changed files with 27 additions and 5 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ $ pip install pandas_ta
Latest Version
--------------
Best choice! Version: *0.3.33b*
Best choice! Version: *0.3.34b*
* 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
+9
View File
@@ -578,6 +578,7 @@ class AnalysisIndicators(BasePandasObject):
"exchange",
"last_run",
"reverse",
"sample",
"ticker",
"time_range",
"to_utc",
@@ -615,6 +616,14 @@ class AnalysisIndicators(BasePandasObject):
s += f"\nTotal Candles, Indicators and Utilities: {_count}"
print(s)
def sample(self, **kwargs):
"""sample
See help(ta.sample) for parameters.
"""
return sample(**kwargs)
def strategy(self, *args, **kwargs):
"""Strategy Method
+15 -2
View File
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from numpy import nan as npNaN
from pandas import Series
from pandas_ta.overlap.ma import ma
from pandas_ta.utils import get_drift, get_offset, non_zero_range, verify_series
def kama(close, length=None, fast=None, slow=None, drift=None, offset=None, **kwargs):
def kama(close, length=None, fast=None, slow=None, mamode=None, drift=None, offset=None, **kwargs):
"""Kaufman's Adaptive Moving Average (KAMA)
Developed by Perry Kaufman, Kaufman's Adaptive Moving Average (KAMA) is a moving average
@@ -26,6 +27,9 @@ def kama(close, length=None, fast=None, slow=None, drift=None, offset=None, **kw
length (int): It's period. Default: 10
fast (int): Fast MA period. Default: 2
slow (int): Slow MA period. Default: 30
mamode (str): See ```help(ta.ma)```. Valid MAs that support initialize
the first value: 'ema', 'fwma', 'linreg', 'midpoint', 'pwma', 'rma',
'sinwma', 'sma', 'swma', 'trima', 'wma'. Default: 'sma'
drift (int): The difference period. Default: 1
offset (int): How many periods to offset the result. Default: 0
@@ -41,6 +45,14 @@ def kama(close, length=None, fast=None, slow=None, drift=None, offset=None, **kw
fast = int(fast) if fast and fast > 0 else 2
slow = int(slow) if slow and slow > 0 else 30
close = verify_series(close, max(fast, slow, length))
valid_ma = [
"ema", "fwma", "linreg", "midpoint", "pwma", "rma",
"sinwma", "sma", "swma", "trima", "wma"
]
if isinstance(mamode, str) and mamode.lower() in valid_ma:
mamode = mamode.lower()
else:
mamode = "sma"
drift = get_drift(drift)
offset = get_offset(offset)
@@ -61,7 +73,8 @@ def kama(close, length=None, fast=None, slow=None, drift=None, offset=None, **kw
sc = x * x
m = close.size
result = [npNaN for _ in range(0, length - 1)] + [0]
ma0 = ma(mamode, close.iloc[:length], length=length, **kwargs).iloc[-1]
result = [npNaN for _ in range(0, length - 1)] + [ma0]
for i in range(length, m):
result.append(sc.iloc[i] * close.iloc[i] + (1 - sc.iloc[i]) * result[i - 1])
+1 -1
View File
@@ -19,7 +19,7 @@ setup(
"pandas_ta.volatility",
"pandas_ta.volume"
],
version=".".join(("0", "3", "33b")),
version=".".join(("0", "3", "34b")),
description=long_description,
long_description=long_description,
author="Kevin Johnson",
+1 -1
View File
@@ -18,7 +18,7 @@ sample_data = read_csv(
)
sample_data.set_index(DatetimeIndex(sample_data["date"]), inplace=True, drop=True)
sample_data.drop("date", axis=1, inplace=True)
# sample_data = sample_data[:200]
sample_data = sample_data[:200]
def error_analysis(df, kind, msg, icon=INFO, newline=True):