Files
pandas-ta/pandas_ta/trend/increasing.py
T
2020-10-01 16:18:01 +01:00

59 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
from pandas_ta.utils import get_offset, verify_series
def increasing(close, length=None, asint=True, offset=None, **kwargs):
"""Indicator: Increasing"""
# Validate Arguments
close = verify_series(close)
length = int(length) if length and length > 0 else 1
offset = get_offset(offset)
# Calculate Result
increasing = close.diff(length) > 0
if asint:
increasing = increasing.astype(int)
# Offset
if offset != 0:
increasing = increasing.shift(offset)
# Handle fills
if "fillna" in kwargs:
increasing.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
increasing.fillna(method=kwargs["fill_method"], inplace=True)
# Name and Categorize it
increasing.name = f"INC_{length}"
increasing.category = "trend"
return increasing
increasing.__doc__ = """Increasing
Returns True or False if the series is increasing over a periods. By default,
it returns True and False as 1 and 0 respectively with kwarg 'asint'.
Sources:
Calculation:
increasing = close.diff(length) > 0
if asint:
increasing = increasing.astype(int)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 1
asint (bool): Returns as binary. Default: True
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: New feature generated.
"""