kylejusticemagnuson / pyti

Python library of various financial technical indicators
MIT License
656 stars 164 forks source link

Much faster code for aroon #19

Open cynseok opened 6 years ago

cynseok commented 6 years ago

def aroon_up(data, period): return (1 + data.rolling(period).apply(lambda x: pd.Series(x).idxmax(skipna = True))) / period * 100

def aroon_down(data, period): return (1 + data.rolling(period).apply(lambda x: pd.Series(x).idxmin(skipna = True))) / period * 100

data must be a pandas.Series object - we could wrap it as pd.Series(data) first.

Current code executes at around 8 seconds on 16285 rows of data. Code above executes at around 1.36 seconds