mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-06-27 16:10:07 +08:00
ENH added missing fill options
This commit is contained in:
@@ -97,7 +97,7 @@ $ pip install pandas_ta
|
||||
|
||||
Latest Version
|
||||
--------------
|
||||
Best choice! Version: *0.2.72b*
|
||||
Best choice! Version: *0.2.73b*
|
||||
```sh
|
||||
$ pip install -U git+https://github.com/twopirllc/pandas-ta
|
||||
```
|
||||
|
||||
@@ -25,7 +25,6 @@ def cdl_inside(open_, high, low, close, asbool=False, offset=None, **kwargs):
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
inside.fillna(kwargs["fillna"], inplace=True)
|
||||
|
||||
if "fill_method" in kwargs:
|
||||
inside.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
|
||||
@@ -66,11 +66,7 @@ def td_seq(close, asint=None, offset=None, **kwargs):
|
||||
up_seq.category = down_seq.category = "momentum"
|
||||
|
||||
# Prepare Dataframe to return
|
||||
data = {
|
||||
up_seq.name: up_seq,
|
||||
down_seq.name: down_seq
|
||||
}
|
||||
df = DataFrame(data)
|
||||
df = DataFrame({up_seq.name: up_seq, down_seq.name: down_seq})
|
||||
df.name = "TD_SEQ"
|
||||
df.category = up_seq.category
|
||||
|
||||
|
||||
@@ -21,6 +21,12 @@ def dema(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
dema = dema.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
dema.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
dema.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
dema.name = f"DEMA_{length}"
|
||||
dema.category = "overlap"
|
||||
|
||||
@@ -26,6 +26,12 @@ def ema(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
ema = ema.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
ema.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
ema.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
ema.name = f"EMA_{length}"
|
||||
ema.category = "overlap"
|
||||
|
||||
@@ -20,6 +20,12 @@ def fwma(close, length=None, asc=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
fwma = fwma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
fwma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
fwma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
fwma.name = f"FWMA_{length}"
|
||||
fwma.category = "overlap"
|
||||
|
||||
@@ -25,6 +25,12 @@ def hma(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
hma = hma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
hma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
hma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
hma.name = f"HMA_{length}"
|
||||
hma.category = "overlap"
|
||||
|
||||
@@ -41,6 +41,12 @@ def kama(close, length=None, fast=None, slow=None, drift=None, offset=None, **kw
|
||||
if offset != 0:
|
||||
kama = kama.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
kama.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
kama.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
kama.name = f"KAMA_{length}_{fast}_{slow}"
|
||||
kama.category = "overlap"
|
||||
|
||||
@@ -20,6 +20,12 @@ def pwma(close, length=None, asc=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
pwma = pwma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
pwma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
pwma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
pwma.name = f"PWMA_{length}"
|
||||
pwma.category = "overlap"
|
||||
|
||||
@@ -19,6 +19,12 @@ def rma(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
rma = rma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
rma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
rma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
rma.name = f"RMA_{length}"
|
||||
rma.category = "overlap"
|
||||
|
||||
@@ -24,6 +24,12 @@ def sinwma(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
sinwma = sinwma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
sinwma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
sinwma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
sinwma.name = f"SINWMA_{length}"
|
||||
sinwma.category = "overlap"
|
||||
|
||||
@@ -48,6 +48,12 @@ def ssf(close, length=None, poles=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
ssf = ssf.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
ssf.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
ssf.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
ssf.name = f"SSF_{length}_{poles}"
|
||||
ssf.category = "overlap"
|
||||
|
||||
@@ -22,6 +22,12 @@ def swma(close, length=None, asc=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
swma = swma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
swma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
swma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
swma.name = f"SWMA_{length}"
|
||||
swma.category = "overlap"
|
||||
|
||||
@@ -31,6 +31,12 @@ def t3(close, length=None, a=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
t3 = t3.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
t3.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
t3.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
t3.name = f"T3_{length}_{a}"
|
||||
t3.category = "overlap"
|
||||
|
||||
@@ -22,6 +22,12 @@ def tema(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
tema = tema.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
tema.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
tema.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
tema.name = f"TEMA_{length}"
|
||||
tema.category = "overlap"
|
||||
|
||||
@@ -21,6 +21,12 @@ def trima(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
trima = trima.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
trima.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
trima.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
trima.name = f"TRIMA_{length}"
|
||||
trima.category = "overlap"
|
||||
|
||||
@@ -41,6 +41,12 @@ def vidya(close, length=None, drift=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
vidya = vidya.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
vidya.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
vidya.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
vidya.name = f"VIDYA_{length}"
|
||||
vidya.category = "overlap"
|
||||
|
||||
@@ -27,6 +27,12 @@ def vwap(high, low, close, volume, anchor=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
vwap = vwap.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
vwap.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
vwap.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
vwap.name = f"VWAP_{anchor}"
|
||||
vwap.category = "overlap"
|
||||
|
||||
@@ -21,6 +21,12 @@ def vwma(close, volume, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
vwma = vwma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
vwma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
vwma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
vwma.name = f"VWMA_{length}"
|
||||
vwma.category = "overlap"
|
||||
|
||||
@@ -17,6 +17,12 @@ def wcp(high, low, close, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
wcp = wcp.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
wcp.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
wcp.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
wcp.name = "WCP"
|
||||
wcp.category = "overlap"
|
||||
|
||||
@@ -32,6 +32,12 @@ def wma(close, length=None, asc=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
wma = wma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
wma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
wma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
wma.name = f"WMA_{length}"
|
||||
wma.category = "overlap"
|
||||
|
||||
@@ -35,6 +35,12 @@ def zlma(close, length=None, mamode=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
zlma = zlma.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
zlma.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
zlma.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
zlma.name = f"ZL_{zlma.name}"
|
||||
zlma.category = "overlap"
|
||||
|
||||
@@ -21,6 +21,12 @@ def entropy(close, length=None, base=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
entropy = entropy.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
entropy.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
entropy.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
entropy.name = f"ENTP_{length}"
|
||||
entropy.category = "statistics"
|
||||
|
||||
@@ -19,6 +19,12 @@ def kurtosis(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
kurtosis = kurtosis.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
kurtosis.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
kurtosis.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
kurtosis.name = f"KURT_{length}"
|
||||
kurtosis.category = "statistics"
|
||||
|
||||
@@ -24,6 +24,12 @@ def mad(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
mad = mad.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
mad.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
mad.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
mad.name = f"MAD_{length}"
|
||||
mad.category = "statistics"
|
||||
|
||||
@@ -19,6 +19,12 @@ def median(close, length=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
median = median.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
median.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
median.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
median.name = f"MEDIAN_{length}"
|
||||
median.category = "statistics"
|
||||
|
||||
@@ -20,6 +20,12 @@ def quantile(close, length=None, q=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
quantile = quantile.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
quantile.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
quantile.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
quantile.name = f"QTL_{length}_{q}"
|
||||
quantile.category = "statistics"
|
||||
|
||||
@@ -21,6 +21,12 @@ def stdev(close, length=None, ddof=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
stdev = stdev.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
stdev.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
stdev.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
stdev.name = f"STDEV_{length}"
|
||||
stdev.category = "statistics"
|
||||
|
||||
@@ -20,6 +20,12 @@ def variance(close, length=None, ddof=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
variance = variance.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
variance.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
variance.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
variance.name = f"VAR_{length}"
|
||||
variance.category = "statistics"
|
||||
|
||||
@@ -23,6 +23,12 @@ def zscore(close, length=None, std=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
zscore = zscore.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
zscore.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
zscore.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
zscore.name = f"Z_{length}"
|
||||
zscore.category = "statistics"
|
||||
|
||||
@@ -21,6 +21,12 @@ def pdist(open_, high, low, close, drift=None, offset=None, **kwargs):
|
||||
if offset != 0:
|
||||
pdist = pdist.shift(offset)
|
||||
|
||||
# Handle fills
|
||||
if "fillna" in kwargs:
|
||||
pdist.fillna(kwargs["fillna"], inplace=True)
|
||||
if "fill_method" in kwargs:
|
||||
pdist.fillna(method=kwargs["fill_method"], inplace=True)
|
||||
|
||||
# Name & Category
|
||||
pdist.name = "PDIST"
|
||||
pdist.category = "volatility"
|
||||
|
||||
@@ -39,14 +39,11 @@ Sources:
|
||||
https://www.fmlabs.com/reference/default.htm?url=PVrank.htm
|
||||
|
||||
Calculation:
|
||||
if 'close change' >= 0 and 'volume change' >= 0
|
||||
return 1
|
||||
if 'close change' >= 0 and 'volume change' < 0
|
||||
return 2
|
||||
if 'close change' < 0 and 'volume change' >= 0
|
||||
return 3
|
||||
if 'close change' < 0 and 'volume change' < 0
|
||||
return 4
|
||||
return 1 if 'close change' >= 0 and 'volume change' >= 0
|
||||
return 2 if 'close change' >= 0 and 'volume change' < 0
|
||||
return 3 if 'close change' < 0 and 'volume change' >= 0
|
||||
return 4 if 'close change' < 0 and 'volume change' < 0
|
||||
|
||||
Args:
|
||||
close (pd.Series): Series of 'close's
|
||||
volume (pd.Series): Series of 'volume's
|
||||
|
||||
Reference in New Issue
Block a user