MAINT slope refactoring

This commit is contained in:
Kevin Johnson
2020-09-10 10:26:22 -07:00
parent 9c5889e99a
commit 3388ca8d5e
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ from pandas_ta.volatility import *
from pandas_ta.volume import *
from pandas_ta.utils import *
version = ".".join(("0", "2", "04b"))
version = ".".join(("0", "2", "05b"))
# Strategy (Data)Class
+9 -9
View File
@@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
from math import atan, pi
from ..utils import get_offset, verify_series
from pandas_ta.utils import get_offset, verify_series
def slope(close, length=None, as_angle=None, to_degrees=None, offset=None, **kwargs):
def slope(close, length=None, as_angle=None, to_degrees=None, vertical=None, offset=None, **kwargs):
"""Indicator: Slope"""
# Validate arguments
close = verify_series(close)
length = int(length) if length and length > 0 else 1
as_angle = True if as_angle and isinstance(as_angle, bool) else False
to_degrees = True if to_degrees and isinstance(to_degrees, bool) else False
as_angle = True if isinstance(as_angle, bool) else False
to_degrees = True if isinstance(to_degrees, bool) else False
offset = get_offset(offset)
# Calculate Result
@@ -23,14 +23,14 @@ def slope(close, length=None, as_angle=None, to_degrees=None, offset=None, **kwa
slope = slope.shift(offset)
# Handle fills
if 'fillna' in kwargs:
slope.fillna(kwargs['fillna'], inplace=True)
if 'fill_method' in kwargs:
slope.fillna(method=kwargs['fill_method'], inplace=True)
if "fillna" in kwargs:
slope.fillna(kwargs["fillna"], inplace=True)
if "fill_method" in kwargs:
slope.fillna(method=kwargs["fill_method"], inplace=True)
# Name and Categorize it
slope.name = f"SLOPE_{length}" if not as_angle else f"ANGLE{'d' if to_degrees else 'r'}_{length}"
slope.category = 'momentum'
slope.category = "momentum"
return slope