def test_adx_neg(self): target = '-DI14' result = adx_neg(high=self._df['High'], low=self._df['Low'], close=self._df['Close'], n=14, fillna=False) pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)
def test_adx_neg(self): target = '-DI14' result = adx_neg(**self._params) pd.testing.assert_series_equal(self._df[target].tail(), result.tail(), check_names=False)
def calculate_Trend_Indicators(): JSON_sent = request.get_json() if len(JSON_sent[0]) > 0: df = pd.DataFrame(JSON_sent[0]) _, sma, ema, macdDict, macdSignal, adxDict, adxPos, adxNeg, VIpos, VIneg, trixDict, mi, dpoDict = JSON_sent if sma['displaySMA']: indicator_sma = sma_indicator(close=df['close'], n=sma['nForSMA']) df['sma'] = indicator_sma if ema['displayEMA']: indicator_ema = ema_indicator(close=df['close'], n=ema['nForEMA']) df['ema'] = indicator_ema if macdDict['displayMACD']: indicator_macd = macd(close=df['close'], n_slow=macdDict['nSlowForMACD'], n_fast=macdDict['nFastForMACD']) df['macd'] = indicator_macd if macdSignal['displayMACDsignal']: indicator_macdSignal = macd_signal( close=df['close'], n_slow=macdSignal['nSlowForMACDsignal'], n_fast=macdSignal['nFastForMACDsignal'], n_sign=macdSignal['nSignForMACDsignal']) df['macds'] = indicator_macdSignal if adxDict['displayADX']: indicator_ADX = adx(high=df['high'], low=df['low'], close=df['close'], n=adxDict['nForADX']) df['adx'] = indicator_ADX if adxPos['displayADXP']: indicator_ADXpositive = adx_pos(high=df['high'], low=df['low'], close=df['close'], n=adxPos['nForADXP']) df['adxp'] = indicator_ADXpositive if adxNeg['displayADXN']: indicator_ADXnegative = adx_neg(high=df['high'], low=df['low'], close=df['close'], n=adxNeg['nForADXN']) df['adxn'] = indicator_ADXnegative if VIpos['displayVIPOS']: indicator_VIpositive = vortex_indicator_pos(high=df['high'], low=df['low'], close=df['close'], n=VIpos['nForVIPOS']) df['vipos'] = indicator_VIpositive if VIneg['displayVINEG']: indicator_VInegative = vortex_indicator_neg(high=df['high'], low=df['low'], close=df['close'], n=VIneg['nForVINEG']) df['vineg'] = indicator_VInegative if trixDict['displayTRIX']: indicator_TRIX = trix(close=df['close'], n=trixDict['nForTRIX']) df['trix'] = indicator_TRIX if mi['displayMI']: indicator_MassIndex = mass_index(high=df['high'], low=df['low'], n=mi['nForMI'], n2=mi['n2ForMI']) df['mi'] = indicator_MassIndex if dpoDict['displayDPO']: indicator_dpo = dpo(close=df['close'], n=dpoDict['nForDPO']) df['dpo'] = indicator_dpo df.fillna(0, inplace=True) return (json.dumps(df.to_dict('records'))) else: df = pd.DataFrame([]) return (json.dumps(df.to_dict('records')))