add went_up and went_down helpers

This commit is contained in:
Janne Sinivirta 2018-02-13 11:37:59 +02:00
parent e3d222912d
commit cf013140a6
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,9 @@
from pandas import Series
def went_up(series: Series) -> Series:
return series > series.shift(1)
def went_down(series: Series) -> Series:
return series < series.shift(1)

View File

@ -0,0 +1,12 @@
import pandas as pd
from freqtrade.indicator_helpers import went_up, went_down
def test_went_up():
series = pd.Series([1, 2, 3, 1])
assert went_up(series).equals(pd.Series([False, True, True, False]))
def test_went_down():
series = pd.Series([1, 2, 3, 1])
assert went_down(series).equals(pd.Series([False, False, False, True]))