def Math_Transform(dataframe): #Math Transform Functions #ACOS - Vector Trigonometric ACos df[f'{ratio}_ACOS'] = talib.ACOS(Close) #ASIN - Vector Trigonometric ASin df[f'{ratio}_ASIN'] = talib.ASIN(Close) #ATAN - Vector Trigonometric ATan df[f'{ratio}_ATAN'] = talib.ATAN(Close) #CEIL - Vector Ceil df[f'{ratio}_CEIL'] = talib.CEIL(Close) #COS - Vector Trigonometric Cos df[f'{ratio}_COS'] = talib.COS(Close) #COSH - Vector Trigonometric Cosh df[f'{ratio}_COSH'] = talib.COSH(Close) #EXP - Vector Arithmetic Exp df[f'{ratio}_EXP'] = talib.EXP(Close) #FLOOR - Vector Floor df[f'{ratio}_FLOOR'] = talib.FLOOR(Close) #LN - Vector Log Natural df[f'{ratio}_LN'] = talib.LN(Close) #LOG10 - Vector Log10 df[f'{ratio}_LOG10'] = talib.LOG10(Close) #SIN - Vector Trigonometric Sin df[f'{ratio}_SIN'] = talib.SIN(Close) #SINH - Vector Trigonometric Sinh df[f'{ratio}_SINH'] = talib.SINH(Close) #SQRT - Vector Square Root df[f'{ratio}_SQRT'] = talib.SQRT(Close) #TAN - Vector Trigonometric Tan df[f'{ratio}_TAN'] = talib.TAN(Close) #TANH - Vector Trigonometric Tanh df[f'{ratio}_TANH'] = talib.TANH(Close) return
def math_transform_process(event): print(event.widget.get()) math_transform = event.widget.get() upperband, middleband, lowerband = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0) fig, axes = plt.subplots(2, 1, sharex=True) ax1, ax2 = axes[0], axes[1] axes[0].plot(close, 'rd-', markersize=3) axes[0].plot(upperband, 'y-') axes[0].plot(middleband, 'b-') axes[0].plot(lowerband, 'y-') axes[0].set_title(math_transform, fontproperties="SimHei") if math_transform == '反余弦': real = ta.ACOS(close) axes[1].plot(real, 'r-') elif math_transform == '反正弦': real = ta.ASIN(close) axes[1].plot(real, 'r-') elif math_transform == '反正切': real = ta.ATAN(close) axes[1].plot(real, 'r-') elif math_transform == '向上取整': real = ta.CEIL(close) axes[1].plot(real, 'r-') elif math_transform == '余弦': real = ta.COS(close) axes[1].plot(real, 'r-') elif math_transform == '双曲余弦': real = ta.COSH(close) axes[1].plot(real, 'r-') elif math_transform == '指数': real = ta.EXP(close) axes[1].plot(real, 'r-') elif math_transform == '向下取整': real = ta.FLOOR(close) axes[1].plot(real, 'r-') elif math_transform == '自然对数': real = ta.LN(close) axes[1].plot(real, 'r-') elif math_transform == '常用对数': real = ta.LOG10(close) axes[1].plot(real, 'r-') elif math_transform == '正弦': real = ta.SIN(close) axes[1].plot(real, 'r-') elif math_transform == '双曲正弦': real = ta.SINH(close) axes[1].plot(real, 'r-') elif math_transform == '平方根': real = ta.SQRT(close) axes[1].plot(real, 'r-') elif math_transform == '正切': real = ta.TAN(close) axes[1].plot(real, 'r-') elif math_transform == '双曲正切': real = ta.TANH(close) axes[1].plot(real, 'r-') plt.show()
def TAN(close): ''' Vector Trigonometric Tan 正切函数,三角函数 分组: Math Transform 数学变换 简介: real = TAN(close) ''' return talib.TAN(close)
def tan(client, symbol, timeframe="6m", col="close"): """This will return a dataframe of Vector Trigonometric Tan for the given symbol across the given timeframe Args: client (pyEX.Client); Client symbol (string); Ticker timeframe (string); timeframe to use, for pyEX.chart col (string); column to use to calculate Returns: DataFrame: result """ df = client.chartDF(symbol, timeframe) x = t.TAN(df[col].values) return pd.DataFrame({col: df[col].values, "tan": x})
def TAN(data, **kwargs): _check_talib_presence() prices = _extract_series(data) return talib.TAN(prices, **kwargs)
def add_ta_features(df, ta_settings): """Add technial analysis features from typical financial dataset that typically include columns such as "open", "high", "low", "price" and "volume". http://mrjbq7.github.io/ta-lib/ Args: df(pandas.DataFrame): original DataFrame. ta_settings(dict): configuration. Returns: pandas.DataFrame: DataFrame with new features included. """ open = df['open'] high = df['high'] low = df['low'] close = df['price'] volume = df['volume'] if ta_settings['overlap']: df['ta_overlap_bbands_upper'], df['ta_overlap_bbands_middle'], df[ 'ta_overlap_bbands_lower'] = ta.BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0) df['ta_overlap_dema'] = ta.DEMA( close, timeperiod=15) # NOTE: Changed to avoid a lot of Nan values df['ta_overlap_ema'] = ta.EMA(close, timeperiod=30) df['ta_overlap_kama'] = ta.KAMA(close, timeperiod=30) df['ta_overlap_ma'] = ta.MA(close, timeperiod=30, matype=0) df['ta_overlap_mama_mama'], df['ta_overlap_mama_fama'] = ta.MAMA(close) period = np.random.randint(10, 20, size=len(close)).astype(float) df['ta_overlap_mavp'] = ta.MAVP(close, period, minperiod=2, maxperiod=30, matype=0) df['ta_overlap_midpoint'] = ta.MIDPOINT(close, timeperiod=14) df['ta_overlap_midprice'] = ta.MIDPRICE(high, low, timeperiod=14) df['ta_overlap_sar'] = ta.SAR(high, low, acceleration=0, maximum=0) df['ta_overlap_sarext'] = ta.SAREXT(high, low, startvalue=0, offsetonreverse=0, accelerationinitlong=0, accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0) df['ta_overlap_sma'] = ta.SMA(close, timeperiod=30) df['ta_overlap_t3'] = ta.T3(close, timeperiod=5, vfactor=0) df['ta_overlap_tema'] = ta.TEMA( close, timeperiod=12) # NOTE: Changed to avoid a lot of Nan values df['ta_overlap_trima'] = ta.TRIMA(close, timeperiod=30) df['ta_overlap_wma'] = ta.WMA(close, timeperiod=30) # NOTE: Commented to avoid a lot of Nan values # df['ta_overlap_ht_trendline'] = ta.HT_TRENDLINE(close) if ta_settings['momentum']: df['ta_momentum_adx'] = ta.ADX(high, low, close, timeperiod=14) df['ta_momentum_adxr'] = ta.ADXR(high, low, close, timeperiod=14) df['ta_momentum_apo'] = ta.APO(close, fastperiod=12, slowperiod=26, matype=0) df['ta_momentum_aroondown'], df['ta_momentum_aroonup'] = ta.AROON( high, low, timeperiod=14) df['ta_momentum_aroonosc'] = ta.AROONOSC(high, low, timeperiod=14) df['ta_momentum_bop'] = ta.BOP(open, high, low, close) df['ta_momentum_cci'] = ta.CCI(high, low, close, timeperiod=14) df['ta_momentum_cmo'] = ta.CMO(close, timeperiod=14) df['ta_momentum_dx'] = ta.DX(high, low, close, timeperiod=14) df['ta_momentum_macd_macd'], df['ta_momentum_macd_signal'], df[ 'ta_momentum_macd_hist'] = ta.MACD(close, fastperiod=12, slowperiod=26, signalperiod=9) df['ta_momentum_macdext_macd'], df['ta_momentum_macdext_signal'], df[ 'ta_momentum_macdext_hist'] = ta.MACDEXT(close, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0) df['ta_momentum_macdfix_macd'], df['ta_momentum_macdfix_signal'], df[ 'ta_momentum_macdfix_hist'] = ta.MACDFIX(close, signalperiod=9) df['ta_momentum_mfi'] = ta.MFI(high, low, close, volume, timeperiod=14) df['ta_momentum_minus_di'] = ta.MINUS_DI(high, low, close, timeperiod=14) df['ta_momentum_minus_dm'] = ta.MINUS_DM(high, low, timeperiod=14) df['ta_momentum_mom'] = ta.MOM(close, timeperiod=10) df['ta_momentum_plus_di'] = ta.PLUS_DI(high, low, close, timeperiod=14) df['ta_momentum_plus_dm'] = ta.PLUS_DM(high, low, timeperiod=14) df['ta_momentum_ppo'] = ta.PPO(close, fastperiod=12, slowperiod=26, matype=0) df['ta_momentum_roc'] = ta.ROC(close, timeperiod=10) df['ta_momentum_rocp'] = ta.ROCP(close, timeperiod=10) df['ta_momentum_rocr'] = ta.ROCR(close, timeperiod=10) df['ta_momentum_rocr100'] = ta.ROCR100(close, timeperiod=10) df['ta_momentum_rsi'] = ta.RSI(close, timeperiod=14) df['ta_momentum_slowk'], df['ta_momentum_slowd'] = ta.STOCH( high, low, close, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0) df['ta_momentum_fastk'], df['ta_momentum_fastd'] = ta.STOCHF( high, low, close, fastk_period=5, fastd_period=3, fastd_matype=0) df['ta_momentum_fastk'], df['ta_momentum_fastd'] = ta.STOCHRSI( close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0) df['ta_momentum_trix'] = ta.TRIX( close, timeperiod=12) # NOTE: Changed to avoid a lot of Nan values df['ta_momentum_ultosc'] = ta.ULTOSC(high, low, close, timeperiod1=7, timeperiod2=14, timeperiod3=28) df['ta_momentum_willr'] = ta.WILLR(high, low, close, timeperiod=14) if ta_settings['volume']: df['ta_volume_ad'] = ta.AD(high, low, close, volume) df['ta_volume_adosc'] = ta.ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10) df['ta_volume_obv'] = ta.OBV(close, volume) if ta_settings['volatility']: df['ta_volatility_atr'] = ta.ATR(high, low, close, timeperiod=14) df['ta_volatility_natr'] = ta.NATR(high, low, close, timeperiod=14) df['ta_volatility_trange'] = ta.TRANGE(high, low, close) if ta_settings['price']: df['ta_price_avgprice'] = ta.AVGPRICE(open, high, low, close) df['ta_price_medprice'] = ta.MEDPRICE(high, low) df['ta_price_typprice'] = ta.TYPPRICE(high, low, close) df['ta_price_wclprice'] = ta.WCLPRICE(high, low, close) if ta_settings['cycle']: df['ta_cycle_ht_dcperiod'] = ta.HT_DCPERIOD(close) df['ta_cycle_ht_phasor_inphase'], df[ 'ta_cycle_ht_phasor_quadrature'] = ta.HT_PHASOR(close) df['ta_cycle_ht_trendmode'] = ta.HT_TRENDMODE(close) # NOTE: Commented to avoid a lot of Nan values # df['ta_cycle_ht_dcphase'] = ta.HT_DCPHASE(close) # df['ta_cycle_ht_sine_sine'], df['ta_cycle_ht_sine_leadsine'] = ta.HT_SINE(close) if ta_settings['pattern']: df['ta_pattern_cdl2crows'] = ta.CDL2CROWS(open, high, low, close) df['ta_pattern_cdl3blackrows'] = ta.CDL3BLACKCROWS( open, high, low, close) df['ta_pattern_cdl3inside'] = ta.CDL3INSIDE(open, high, low, close) df['ta_pattern_cdl3linestrike'] = ta.CDL3LINESTRIKE( open, high, low, close) df['ta_pattern_cdl3outside'] = ta.CDL3OUTSIDE(open, high, low, close) df['ta_pattern_cdl3starsinsouth'] = ta.CDL3STARSINSOUTH( open, high, low, close) df['ta_pattern_cdl3whitesoldiers'] = ta.CDL3WHITESOLDIERS( open, high, low, close) df['ta_pattern_cdlabandonedbaby'] = ta.CDLABANDONEDBABY(open, high, low, close, penetration=0) df['ta_pattern_cdladvanceblock'] = ta.CDLADVANCEBLOCK( open, high, low, close) df['ta_pattern_cdlbelthold'] = ta.CDLBELTHOLD(open, high, low, close) df['ta_pattern_cdlbreakaway'] = ta.CDLBREAKAWAY(open, high, low, close) df['ta_pattern_cdlclosingmarubozu'] = ta.CDLCLOSINGMARUBOZU( open, high, low, close) df['ta_pattern_cdlconcealbabyswall'] = ta.CDLCONCEALBABYSWALL( open, high, low, close) df['ta_pattern_cdlcounterattack'] = ta.CDLCOUNTERATTACK( open, high, low, close) df['ta_pattern_cdldarkcloudcover'] = ta.CDLDARKCLOUDCOVER( open, high, low, close, penetration=0) df['ta_pattern_cdldoji'] = ta.CDLDOJI(open, high, low, close) df['ta_pattern_cdldojistar'] = ta.CDLDOJISTAR(open, high, low, close) df['ta_pattern_cdldragonflydoji'] = ta.CDLDRAGONFLYDOJI( open, high, low, close) df['ta_pattern_cdlengulfing'] = ta.CDLENGULFING(open, high, low, close) df['ta_pattern_cdleveningdojistar'] = ta.CDLEVENINGDOJISTAR( open, high, low, close, penetration=0) df['ta_pattern_cdleveningstar'] = ta.CDLEVENINGSTAR(open, high, low, close, penetration=0) df['ta_pattern_cdlgapsidesidewhite'] = ta.CDLGAPSIDESIDEWHITE( open, high, low, close) df['ta_pattern_cdlgravestonedoji'] = ta.CDLGRAVESTONEDOJI( open, high, low, close) df['ta_pattern_cdlhammer'] = ta.CDLHAMMER(open, high, low, close) df['ta_pattern_cdlhangingman'] = ta.CDLHANGINGMAN( open, high, low, close) df['ta_pattern_cdlharami'] = ta.CDLHARAMI(open, high, low, close) df['ta_pattern_cdlharamicross'] = ta.CDLHARAMICROSS( open, high, low, close) df['ta_pattern_cdlhighwave'] = ta.CDLHIGHWAVE(open, high, low, close) df['ta_pattern_cdlhikkake'] = ta.CDLHIKKAKE(open, high, low, close) df['ta_pattern_cdlhikkakemod'] = ta.CDLHIKKAKEMOD( open, high, low, close) df['ta_pattern_cdlhomingpigeon'] = ta.CDLHOMINGPIGEON( open, high, low, close) df['ta_pattern_cdlidentical3crows'] = ta.CDLIDENTICAL3CROWS( open, high, low, close) df['ta_pattern_cdlinneck'] = ta.CDLINNECK(open, high, low, close) df['ta_pattern_cdlinvertedhammer'] = ta.CDLINVERTEDHAMMER( open, high, low, close) df['ta_pattern_cdlkicking'] = ta.CDLKICKING(open, high, low, close) df['ta_pattern_cdlkickingbylength'] = ta.CDLKICKINGBYLENGTH( open, high, low, close) df['ta_pattern_cdlladderbottom'] = ta.CDLLADDERBOTTOM( open, high, low, close) df['ta_pattern_cdllongleggeddoji'] = ta.CDLLONGLEGGEDDOJI( open, high, low, close) df['ta_pattern_cdllongline'] = ta.CDLLONGLINE(open, high, low, close) df['ta_pattern_cdlmarubozu'] = ta.CDLMARUBOZU(open, high, low, close) df['ta_pattern_cdlmatchinglow'] = ta.CDLMATCHINGLOW( open, high, low, close) df['ta_pattern_cdlmathold'] = ta.CDLMATHOLD(open, high, low, close, penetration=0) df['ta_pattern_cdlmorningdojistar'] = ta.CDLMORNINGDOJISTAR( open, high, low, close, penetration=0) df['ta_pattern_cdlmorningstar'] = ta.CDLMORNINGSTAR(open, high, low, close, penetration=0) df['ta_pattern_cdllonneck'] = ta.CDLONNECK(open, high, low, close) df['ta_pattern_cdlpiercing'] = ta.CDLPIERCING(open, high, low, close) df['ta_pattern_cdlrickshawman'] = ta.CDLRICKSHAWMAN( open, high, low, close) df['ta_pattern_cdlrisefall3methods'] = ta.CDLRISEFALL3METHODS( open, high, low, close) df['ta_pattern_cdlseparatinglines'] = ta.CDLSEPARATINGLINES( open, high, low, close) df['ta_pattern_cdlshootingstar'] = ta.CDLSHOOTINGSTAR( open, high, low, close) df['ta_pattern_cdlshortline'] = ta.CDLSHORTLINE(open, high, low, close) df['ta_pattern_cdlspinningtop'] = ta.CDLSPINNINGTOP( open, high, low, close) df['ta_pattern_cdlstalledpattern'] = ta.CDLSTALLEDPATTERN( open, high, low, close) df['ta_pattern_cdlsticksandwich'] = ta.CDLSTICKSANDWICH( open, high, low, close) df['ta_pattern_cdltakuri'] = ta.CDLTAKURI(open, high, low, close) df['ta_pattern_cdltasukigap'] = ta.CDLTASUKIGAP(open, high, low, close) df['ta_pattern_cdlthrusting'] = ta.CDLTHRUSTING(open, high, low, close) df['ta_pattern_cdltristar'] = ta.CDLTRISTAR(open, high, low, close) df['ta_pattern_cdlunique3river'] = ta.CDLUNIQUE3RIVER( open, high, low, close) df['ta_pattern_cdlupsidegap2crows'] = ta.CDLUPSIDEGAP2CROWS( open, high, low, close) df['ta_pattern_cdlxsidegap3methods'] = ta.CDLXSIDEGAP3METHODS( open, high, low, close) if ta_settings['statistic']: df['ta_statistic_beta'] = ta.BETA(high, low, timeperiod=5) df['ta_statistic_correl'] = ta.CORREL(high, low, timeperiod=30) df['ta_statistic_linearreg'] = ta.LINEARREG(close, timeperiod=14) df['ta_statistic_linearreg_angle'] = ta.LINEARREG_ANGLE(close, timeperiod=14) df['ta_statistic_linearreg_intercept'] = ta.LINEARREG_INTERCEPT( close, timeperiod=14) df['ta_statistic_linearreg_slope'] = ta.LINEARREG_SLOPE(close, timeperiod=14) df['ta_statistic_stddev'] = ta.STDDEV(close, timeperiod=5, nbdev=1) df['ta_statistic_tsf'] = ta.TSF(close, timeperiod=14) df['ta_statistic_var'] = ta.VAR(close, timeperiod=5, nbdev=1) if ta_settings['math_transforms']: df['ta_math_transforms_atan'] = ta.ATAN(close) df['ta_math_transforms_ceil'] = ta.CEIL(close) df['ta_math_transforms_cos'] = ta.COS(close) df['ta_math_transforms_floor'] = ta.FLOOR(close) df['ta_math_transforms_ln'] = ta.LN(close) df['ta_math_transforms_log10'] = ta.LOG10(close) df['ta_math_transforms_sin'] = ta.SIN(close) df['ta_math_transforms_sqrt'] = ta.SQRT(close) df['ta_math_transforms_tan'] = ta.TAN(close) if ta_settings['math_operators']: df['ta_math_operators_add'] = ta.ADD(high, low) df['ta_math_operators_div'] = ta.DIV(high, low) df['ta_math_operators_min'], df['ta_math_operators_max'] = ta.MINMAX( close, timeperiod=30) df['ta_math_operators_minidx'], df[ 'ta_math_operators_maxidx'] = ta.MINMAXINDEX(close, timeperiod=30) df['ta_math_operators_mult'] = ta.MULT(high, low) df['ta_math_operators_sub'] = ta.SUB(high, low) df['ta_math_operators_sum'] = ta.SUM(close, timeperiod=30) return df
def main(): # read csv file and transform it to datafeed (df): df = pd.read_csv(current_dir + "/" + base_dir + "/" + in_dir + "/" + in_dir + '_' + stock_symbol + '.csv') # set numpy datafeed from df: df_numpy = { 'Date': np.array(df['date']), 'Open': np.array(df['open'], dtype='float'), 'High': np.array(df['high'], dtype='float'), 'Low': np.array(df['low'], dtype='float'), 'Close': np.array(df['close'], dtype='float'), 'Volume': np.array(df['volume'], dtype='float') } date = df_numpy['Date'] openp = df_numpy['Open'] high = df_numpy['High'] low = df_numpy['Low'] close = df_numpy['Close'] volume = df_numpy['Volume'] ######################################### ##### Math Transform Functions ###### ######################################### #ACOS - Vector Trigonometric ACos acos = ta.ACOS(close) #ASIN - Vector Trigonometric ASin asin = ta.ASIN(close) #ATAN - Vector Trigonometric ATan atan = ta.ATAN(close) #CEIL - Vector Ceil ceil = ta.CEIL(close) #COS - Vector Trigonometric Cos cos = ta.COS(close) #COSH - Vector Trigonometric Cosh cosh = ta.COSH(close) #EXP - Vector Arithmetic Exp exp = ta.EXP(close) #FLOOR - Vector Floor floor = ta.FLOOR(close) #LN - Vector Log Natural ln = ta.LN(close) #LOG10 - Vector Log10 log10 = ta.LOG10(close) #SIN - Vector Trigonometric Sin sin = ta.SIN(close) #SINH - Vector Trigonometric Sinh sinh = ta.SINH(close) #SQRT - Vector Square Root sqrt = ta.SQRT(close) #TAN - Vector Trigonometric Tan tan = ta.TAN(close) #TANH - Vector Trigonometric Tanh tanh = ta.TANH(close) df_save = pd.DataFrame( data={ 'date': np.array(df['date']), 'acos': acos, 'asin': asin, 'atan': atan, 'ceil': ceil, 'cos': cos, 'cosh': cosh, 'exp': exp, 'floor': floor, 'ln': ln, 'log10': log10, 'sin': sin, 'sinh': sinh, 'sqrt': sqrt, 'tan': tan, 'tanh': tanh }) df_save.to_csv(current_dir + "/" + base_dir + "/" + out_dir + '/' + stock_symbol + "/" + out_dir + '_ta_math_transform_' + stock_symbol + '.csv', index=False)
def TAN(Close): return Close.apply(lambda col: ta.TAN(col), axis=0)
def TAN(self, name, **parameters): data = self.__data[name] return talib.TAN(data, **parameters)
def get_talib_indicators(df, freq_lst=(5, 15, 30), divided_by_close=False): """ Additional indicators with different indicator parameters customized :param df: pandas.DataFrame with {'open', 'close', 'high', 'low', 'volume'} and index == date :return: pandas.DataFrame """ for n in freq_lst: # Overlap Studies Functions #BBANDS df['BBANDS_' + str(n) + '_UP'], df['BBANDS_' + str(n) + '_MID'], df['BBANDS_' + str(n) + '_LOW'] = ta.BBANDS( df.close, timeperiod=n, nbdevup=2, nbdevdn=2, matype=0) #DEMA df['DEMA' + str(n)] = ta.DEMA(df.close, timeperiod=n) #EMA df['EMA' + str(n)] = ta.EMA(df.close, timeperiod=n) #KAMA df['KAMA' + str(n)] = ta.KAMA(df.close, timeperiod=n) #MA df['MA' + str(n)] = ta.MA(df.close, timeperiod=n) #MAMA(ERROR) #df['MAMA' + str(n)] = ta.MAMA(df.close, fastlimit=0, slowlimit=0) #MAVP(periods 参数暂时无法确定) #df['' + str(n)] = ta.MAVP(df.close, periods, minperiod=2, maxperiod=30, matype=0) #MIDPOINT df['MIDPOINT' + str(n)] = ta.MIDPOINT(df.close, timeperiod=n) #MIDPRICE df['MIDPRICE' + str(n)] = ta.MIDPRICE(df.high, df.low, timeperiod=n) #SAR df['SAR' + str(n)] = ta.SAR(df.high, df.low, acceleration=0, maximum=0) #SAREXT(参数太多,暂时无法知道如何设置) #df['SAREXT' + str(n)] = ta.SAREXT(df.high, df.low, startvalue=0, offsetonreverse=0, accelerationinitlong=0, accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0) #SMA df['SMA' + str(n)] = ta.SMA(df.close, timeperiod=n) #T3 df['T3' + str(n)] = ta.T3(df.close, timeperiod=n, vfactor=0.7) #TEMA df['TEMA' + str(n)] = ta.TEMA(df.close, timeperiod=n) #TRIMA df['TRIMA' + str(n)] = ta.TRIMA(df.close, timeperiod=n) #WMA df['WMA' + str(n)] = ta.WMA(df.close, timeperiod=n) #Momentum Indicator Functions #ADX df['ADX' + str(n)] = ta.ADX(df.high, df.low, df.close, timeperiod=n) #ADXR df['ADXR' + str(n)] = ta.ADXR(df.high, df.low, df.close, timeperiod=n) #APO df['APO' + str(n)] = ta.APO(df.close, fastperiod=12, slowperiod=26, matype=0) #AROON df['AROON_DOWN_' + str(n)], df['AROON_UP_' + str(n)] = ta.AROON( df.high, df.low, timeperiod=n) #AROONOSC df['AROONOSC' + str(n)] = ta.AROONOSC(df.high, df.low, timeperiod=n) #CCI df['CCI' + str(n)] = ta.CCI(df.high, df.low, df.close, timeperiod=n) #CMO df['CMO' + str(n)] = ta.CMO(df.close, timeperiod=n) #DX df['DX' + str(n)] = ta.DX(df.high, df.low, df.close, timeperiod=n) #MFI df['MFI' + str(n)] = ta.MFI(df.high, df.low, df.close, df.volume, timeperiod=n) #MINUS_DI df['MINUS_DI' + str(n)] = ta.MINUS_DI(df.high, df.low, df.close, timeperiod=n) #MINUS_DM df['MINUS_DM' + str(n)] = ta.MINUS_DM(df.high, df.low, timeperiod=n) #MOM df['MOM' + str(n)] = ta.MOM(df.close, timeperiod=n) #PLUS_DI df['PLUS_DI' + str(n)] = ta.PLUS_DI(df.high, df.low, df.close, timeperiod=n) #PLUS_DM df['PLUS_DM' + str(n)] = ta.PLUS_DM(df.high, df.low, timeperiod=n) #ROC df['ROC' + str(n)] = ta.ROC(df.close, timeperiod=n) #ROCP df['ROCP' + str(n)] = ta.ROCP(df.close, timeperiod=n) #ROCR df['ROCR' + str(n)] = ta.ROCR(df.close, timeperiod=n) #ROCR100 df['ROCR100_' + str(n)] = ta.ROCR100(df.close, timeperiod=n) #RSI df['RSI' + str(n)] = ta.RSI(df.close, timeperiod=n) #TRIX df['TRIX' + str(n)] = ta.TRIX(df.close, timeperiod=n) #WILLR df['WILLR' + str(n)] = ta.WILLR(df.high, df.low, df.close, timeperiod=n) #Volatility Indicator Functions #ATR df['ATR' + str(n)] = ta.ATR(df.high, df.low, df.close, timeperiod=n) #NATR df['NATR' + str(n)] = ta.NATR(df.high, df.low, df.close, timeperiod=n) # Statistic Functions #BETA df['BETA' + str(n)] = ta.BETA(df.high, df.low, timeperiod=n) #CORREL df['CORREL' + str(n)] = ta.CORREL(df.high, df.low, timeperiod=n) #LINEARREG df['LINEARREG' + str(n)] = ta.LINEARREG(df.close, timeperiod=n) #LINEARREG_ANGLE df['LINEARREG_ANGLE' + str(n)] = ta.LINEARREG_ANGLE(df.close, timeperiod=n) #LINEARREG_INTERCEPT df['LINEARREG_INTERCEPT' + str(n)] = ta.LINEARREG_INTERCEPT( df.close, timeperiod=n) #LINEARREG_SLOPE df['LINEARREG_SLOPE' + str(n)] = ta.LINEARREG_SLOPE(df.close, timeperiod=n) #STDDEV df['STDDEV' + str(n)] = ta.STDDEV(df.close, timeperiod=n, nbdev=1) #TSF df['TSF' + str(n)] = ta.TSF(df.close, timeperiod=n) #VAR df['VAR' + str(n)] = ta.VAR(df.close, timeperiod=n, nbdev=1) # Math Operator Functions #MAX df['MAX' + str(n)] = ta.MAX(df.close, timeperiod=n) #MAXINDEX #df['MAXINDEX' + str(n)] = ta.MAXINDEX(df.close, timeperiod=n) #MIN df['MIN' + str(n)] = ta.MIN(df.close, timeperiod=n) #MININDEX #df['MININDEX' + str(n)] = ta.MININDEX(df.close, timeperiod=n) #SUM #df['SUM' + str(n)] = ta.SUM(df.close, timeperiod=n) # HT_TRENDLINE df['HT_TRENDLINE'] = ta.HT_TRENDLINE(df.close) # BOP df['BOP'] = ta.BOP(df.open, df.high, df.low, df.close) # MACD df['MACD'], df['MACD_SIGNAL'], df['MACD_HIST'] = ta.MACD(df.close, fastperiod=12, slowperiod=26, signalperiod=9) # STOCH df['slowk'], df['slowd'] = ta.STOCH(df.high, df.low, df.close, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0) # STOCHF df['fsatk'], df['fastd'] = ta.STOCHF(df.high, df.low, df.close, fastk_period=5, fastd_period=3, fastd_matype=0) # STOCHRSI df['fsatk_RSI'], df['fastd_RSI'] = ta.STOCHRSI(df.close, timeperiod=n, fastk_period=5, fastd_period=3, fastd_matype=0) # PPO df['PPO'] = ta.PPO(df.close, fastperiod=12, slowperiod=26, matype=0) # ULTOSC df['ULTOSC'] = ta.ULTOSC(df.high, df.low, df.close, timeperiod1=7, timeperiod2=14, timeperiod3=28) # Volume Indicator Functions # AD #df['AD'] = ta.AD(df.high, df.low, df.close, df.volume) # ADOSC #df['ADOSC'] = ta.ADOSC(df.high, df.low, df.close, df.volume, fastperiod=3, slowperiod=10) # OBV # OBV is too large #df['OBV'] = ta.OBV(df.close, df.volume) # TRANGE df['TRANGE'] = ta.TRANGE(df.high, df.low, df.close) # Price Indicator Functions # AVGPRICE df['AVGPRICE'] = ta.AVGPRICE(df.open, df.high, df.low, df.close) # MEDPRICE df['MEDPRICE'] = ta.MEDPRICE(df.high, df.low) # TYPPRICE df['TYPPRICE'] = ta.TYPPRICE(df.high, df.low, df.close) # WCLPRICE df['WCLPRICE'] = ta.WCLPRICE(df.high, df.low, df.close) # Cycle Indicator Functions # HT_DCPERIOD df['HT_DCPERIOD'] = ta.HT_DCPERIOD(df.close) # HT_DCPHASE df['HT_DCPHASE'] = ta.HT_DCPHASE(df.close) # HT_PHASOR df['HT_PHASOR_inphase'], df['HT_PHASOR_quadrature'] = ta.HT_PHASOR( df.close) # HT_SINE df['HT_SINE_sine'], df['HT_SINE_leadsine'] = ta.HT_SINE(df.close) # HT_TRENDMODE df['HT_TRENDMODE'] = ta.HT_TRENDMODE(df.close) #Indicators regardless of time_period #Pattern Recognition Functions #CDL2CROWS '''df['CDL2CROWS'] = ta.CDL2CROWS(df.open, df.high, df.low, df.close) # CDL3BLACKCROWS df['CDL3BLACKCROWS'] = ta.CDL3BLACKCROWS(df.open, df.high, df.low, df.close) # CDL3INSIDE df['CDL3INSIDE'] = ta.CDL3INSIDE(df.open, df.high, df.low, df.close) # CDL3LINESTRIKE df['CDL3LINESTRIKE'] = ta.CDL3LINESTRIKE(df.open, df.high, df.low, df.close) # CDL3OUTSIDE df['CDL3OUTSIDE'] = ta.CDL3OUTSIDE(df.open, df.high, df.low, df.close) # CDL3STARSINSOUTH df['CDL3STARSINSOUTH'] = ta.CDL3STARSINSOUTH(df.open, df.high, df.low, df.close) # CDL3WHITESOLDIERS df['CDL3WHITESOLDIERS'] = ta.CDL3WHITESOLDIERS(df.open, df.high, df.low, df.close) # CDLABANDONEDBABY df['CDLABANDONEDBABY'] = ta.CDLABANDONEDBABY(df.open, df.high, df.low, df.close, penetration=0) # CDLADVANCEBLOCK df['CDLADVANCEBLOCK'] = ta.CDLADVANCEBLOCK(df.open, df.high, df.low, df.close) # CDLBELTHOLD df['CDLBELTHOLD'] = ta.CDLBELTHOLD(df.open, df.high, df.low, df.close) # CDLBREAKAWAY df['CDLBREAKAWAY'] = ta.CDLBREAKAWAY(df.open, df.high, df.low, df.close) # CDLCLOSINGMARUBOZU df['CDLCLOSINGMARUBOZU'] = ta.CDLCLOSINGMARUBOZU(df.open, df.high, df.low, df.close) # CDLCONCEALBABYSWALL df['CDLCONCEALBABYSWALL'] = ta.CDLCONCEALBABYSWALL(df.open, df.high, df.low, df.close) # CDLCOUNTERATTACK df['CDLCOUNTERATTACK'] = ta.CDLCOUNTERATTACK(df.open, df.high, df.low, df.close) # CDLDARKCLOUDCOVER df['CDLDARKCLOUDCOVER'] = ta.CDLDARKCLOUDCOVER(df.open, df.high, df.low, df.close, penetration=0) # CDLDOJI df['CDLDOJI'] = ta.CDLDOJI(df.open, df.high, df.low, df.close) # CDLDOJISTAR df['CDLDOJISTAR'] = ta.CDLDOJISTAR(df.open, df.high, df.low, df.close) # CDLDRAGONFLYDOJI df['CDLDRAGONFLYDOJI'] = ta.CDLDRAGONFLYDOJI(df.open, df.high, df.low, df.close) # CDLENGULFING df['CDLENGULFING'] = ta.CDLENGULFING(df.open, df.high, df.low, df.close) # CDLEVENINGDOJISTAR df['CDLEVENINGDOJISTAR'] = ta.CDLEVENINGDOJISTAR(df.open, df.high, df.low, df.close, penetration=0) # CDLEVENINGSTAR df['CDLEVENINGSTAR'] = ta.CDLEVENINGSTAR(df.open, df.high, df.low, df.close, penetration=0) # CDLGAPSIDESIDEWHITE df['CDLGAPSIDESIDEWHITE'] = ta.CDLGAPSIDESIDEWHITE(df.open, df.high, df.low, df.close) # CDLGRAVESTONEDOJI df['CDLGRAVESTONEDOJI'] = ta.CDLGRAVESTONEDOJI(df.open, df.high, df.low, df.close) # CDLHAMMER df['CDLHAMMER'] = ta.CDLHAMMER(df.open, df.high, df.low, df.close) # CDLHANGINGMAN df['CDLHANGINGMAN'] = ta.CDLHANGINGMAN(df.open, df.high, df.low, df.close) # CDLHARAMI df['CDLHARAMI'] = ta.CDLHARAMI(df.open, df.high, df.low, df.close) # CDLHARAMICROSS df['CDLHARAMICROSS'] = ta.CDLHARAMICROSS(df.open, df.high, df.low, df.close) # CDLHIGHWAVE df['CDLHIGHWAVE'] = ta.CDLHIGHWAVE(df.open, df.high, df.low, df.close) # CDLHIKKAKE df['CDLHIKKAKE'] = ta.CDLHIKKAKE(df.open, df.high, df.low, df.close) # CDLHIKKAKEMOD df['CDLHIKKAKEMOD'] = ta.CDLHIKKAKEMOD(df.open, df.high, df.low, df.close) # CDLHOMINGPIGEON df['CDLHOMINGPIGEON'] = ta.CDLHOMINGPIGEON(df.open, df.high, df.low, df.close) # CDLIDENTICAL3CROWS df['CDLIDENTICAL3CROWS'] = ta.CDLIDENTICAL3CROWS(df.open, df.high, df.low, df.close) # CDLINNECK df['CDLINNECK'] = ta.CDLINNECK(df.open, df.high, df.low, df.close) # CDLINVERTEDHAMMER df['CDLINVERTEDHAMMER'] = ta.CDLINVERTEDHAMMER(df.open, df.high, df.low, df.close) # CDLKICKING df['CDLKICKING'] = ta.CDLKICKING(df.open, df.high, df.low, df.close) # CDLKICKINGBYLENGTH df['CDLKICKINGBYLENGTH'] = ta.CDLKICKINGBYLENGTH(df.open, df.high, df.low, df.close) # CDLLADDERBOTTOM df['CDLLADDERBOTTOM'] = ta.CDLLADDERBOTTOM(df.open, df.high, df.low, df.close) # CDLLONGLEGGEDDOJI df['CDLLONGLEGGEDDOJI'] = ta.CDLLONGLEGGEDDOJI(df.open, df.high, df.low, df.close) # CDLLONGLINE df['CDLLONGLINE'] = ta.CDLLONGLINE(df.open, df.high, df.low, df.close) # CDLMARUBOZU df['CDLMARUBOZU'] = ta.CDLMARUBOZU(df.open, df.high, df.low, df.close) # CDLMATCHINGLOW df['CDLMATCHINGLOW'] = ta.CDLMATCHINGLOW(df.open, df.high, df.low, df.close) # CDLMATHOLD df['CDLMATHOLD'] = ta.CDLMATHOLD(df.open, df.high, df.low, df.close, penetration=0) # CDLMORNINGDOJISTAR df['CDLMORNINGDOJISTAR'] = ta.CDLMORNINGDOJISTAR(df.open, df.high, df.low, df.close, penetration=0) # CDLMORNINGSTAR df['CDLMORNINGSTAR'] = ta.CDLMORNINGSTAR(df.open, df.high, df.low, df.close, penetration=0) # CDLONNECK df['CDLONNECK'] = ta.CDLONNECK(df.open, df.high, df.low, df.close) # CDLPIERCING df['CDLPIERCING'] = ta.CDLPIERCING(df.open, df.high, df.low, df.close) # CDLRICKSHAWMAN df['CDLRICKSHAWMAN'] = ta.CDLRICKSHAWMAN(df.open, df.high, df.low, df.close) # CDLRISEFALL3METHODS df['CDLRISEFALL3METHODS'] = ta.CDLRISEFALL3METHODS(df.open, df.high, df.low, df.close) # CDLSEPARATINGLINES df['CDLSEPARATINGLINES'] = ta.CDLSEPARATINGLINES(df.open, df.high, df.low, df.close) # CDLSHOOTINGSTAR df['CDLSHOOTINGSTAR'] = ta.CDLSHOOTINGSTAR(df.open, df.high, df.low, df.close) # CDLSHORTLINE df['CDLSHORTLINE'] = ta.CDLSHORTLINE(df.open, df.high, df.low, df.close) # CDLSPINNINGTOP df['CDLSPINNINGTOP'] = ta.CDLSPINNINGTOP(df.open, df.high, df.low, df.close) # CDLSTALLEDPATTERN df['CDLSTALLEDPATTERN'] = ta.CDLSTALLEDPATTERN(df.open, df.high, df.low, df.close) # CDLSTICKSANDWICH df['CDLSTICKSANDWICH'] = ta.CDLSTICKSANDWICH(df.open, df.high, df.low, df.close) # CDLTAKURI df['CDLTAKURI'] = ta.CDLTAKURI(df.open, df.high, df.low, df.close) # CDLTASUKIGAP df['CDLTASUKIGAP'] = ta.CDLTASUKIGAP(df.open, df.high, df.low, df.close) # CDLTHRUSTING df['CDLTHRUSTING'] = ta.CDLTHRUSTING(df.open, df.high, df.low, df.close) # CDLTRISTAR df['CDLTRISTAR'] = ta.CDLTRISTAR(df.open, df.high, df.low, df.close) # CDLUNIQUE3RIVER df['CDLUNIQUE3RIVER'] = ta.CDLUNIQUE3RIVER(df.open, df.high, df.low, df.close) # CDLUPSIDEGAP2CROWS df['CDLUPSIDEGAP2CROWS'] = ta.CDLUPSIDEGAP2CROWS(df.open, df.high, df.low, df.close) # CDLXSIDEGAP3METHODS df['CDLXSIDEGAP3METHODS'] = ta.CDLXSIDEGAP3METHODS(df.open, df.high, df.low, df.close)''' # Math Transform Functions #ACOS #df['ACOS'] = ta.ACOS(df.close) #ASIN #df['ASIN'] = ta.ASIN(df.close) #ATAN df['ATAN'] = ta.ATAN(df.close) #CEIL #df['CEIL'] = ta.CEIL(df.close) #COS df['COS'] = ta.COS(df.close) #COSH #df['COSH'] = ta.COSH(df.close) #EXP #df['EXP'] = ta.EXP(df.close) #FLOOR #df['FLOOR'] = ta.FLOOR(df.close) #LN df['LN'] = ta.LN(df.close) #LOG10 df['LOG10'] = ta.LOG10(df.close) #SIN df['SIN'] = ta.SIN(df.close) #SINH #df['SINH'] = ta.SINH(df.close) #SQRT df['SQRT'] = ta.SQRT(df.close) #TAN df['TAN'] = ta.TAN(df.close) #TANH df['TANH'] = ta.TANH(df.close) # Math Operator Functions # ADD #df['ADD'] = ta.ADD(df.high, df.low) # DIV #df['DIV'] = ta.DIV(df.high, df.low) # MULT #df['MULT'] = ta.MULT(df.high, df.low) # ADD #df['SUB'] = ta.SUB(df.high, df.low) if divided_by_close: bias = 1 df['BBANDS_5_UP'] = df['BBANDS_5_UP'] / df.close - bias df['BBANDS_5_MID'] = df['BBANDS_5_MID'] / df.close - bias df['BBANDS_5_LOW'] = df['BBANDS_5_LOW'] / df.close - bias df['DEMA5'] = df['DEMA5'] / df.close - bias df['EMA5'] = df['EMA5'] / df.close - bias df['KAMA5'] = df['KAMA5'] / df.close - bias df['MA5'] = df['MA5'] / df.close - bias df['MIDPOINT5'] = df['MIDPOINT5'] / df.close - bias df['MIDPRICE5'] = df['MIDPRICE5'] / df.close - bias df['SMA5'] = df['SMA5'] / df.close - bias df['T35'] = df['T35'] / df.close - bias df['TEMA5'] = df['TEMA5'] / df.close - bias df['TRIMA5'] = df['TRIMA5'] / df.close - bias df['WMA5'] = df['WMA5'] / df.close - bias df['LINEARREG5'] = df['LINEARREG5'] / df.close - bias df['LINEARREG_INTERCEPT5'] = df[ 'LINEARREG_INTERCEPT5'] / df.close - bias df['TSF5'] = df['TSF5'] / df.close - bias df['MAX5'] = df['MAX5'] / df.close - bias df['MIN5'] = df['MIN5'] / df.close - bias df['BBANDS_15_UP'] = df['BBANDS_15_UP'] / df.close - bias df['BBANDS_15_MID'] = df['BBANDS_15_MID'] / df.close - bias df['BBANDS_15_LOW'] = df['BBANDS_15_LOW'] / df.close - bias df['DEMA15'] = df['DEMA15'] / df.close - bias df['EMA15'] = df['EMA15'] / df.close - bias df['KAMA15'] = df['KAMA15'] / df.close - bias df['MA15'] = df['MA15'] / df.close - bias df['MIDPOINT15'] = df['MIDPOINT15'] / df.close - bias df['MIDPRICE15'] = df['MIDPRICE15'] / df.close - bias df['SMA15'] = df['SMA15'] / df.close - bias df['T315'] = df['T315'] / df.close - bias df['TEMA15'] = df['TEMA15'] / df.close - bias df['TRIMA15'] = df['TRIMA15'] / df.close - bias df['WMA15'] = df['WMA15'] / df.close - bias df['LINEARREG15'] = df['LINEARREG15'] / df.close - bias df['LINEARREG_INTERCEPT15'] = df[ 'LINEARREG_INTERCEPT15'] / df.close - bias df['TSF15'] = df['TSF15'] / df.close - bias df['MAX15'] = df['MAX15'] / df.close - bias df['MIN15'] = df['MIN15'] / df.close - bias df['BBANDS_30_UP'] = df['BBANDS_30_UP'] / df.close - bias df['BBANDS_30_MID'] = df['BBANDS_30_MID'] / df.close - bias df['BBANDS_30_LOW'] = df['BBANDS_30_LOW'] / df.close - bias df['DEMA30'] = df['DEMA30'] / df.close - bias df['EMA30'] = df['EMA30'] / df.close - bias df['KAMA30'] = df['KAMA30'] / df.close - bias df['MA30'] = df['MA30'] / df.close - bias df['MIDPOINT30'] = df['MIDPOINT30'] / df.close - bias df['MIDPRICE30'] = df['MIDPRICE30'] / df.close - bias df['SMA30'] = df['SMA30'] / df.close - bias df['T330'] = df['T330'] / df.close - bias df['TEMA30'] = df['TEMA30'] / df.close - bias df['TRIMA30'] = df['TRIMA30'] / df.close - bias df['WMA30'] = df['WMA30'] / df.close - bias df['LINEARREG_INTERCEPT30'] = df[ 'LINEARREG_INTERCEPT30'] / df.close - bias df['TSF30'] = df['TSF30'] / df.close - bias df['MAX30'] = df['MAX30'] / df.close - bias df['MIN30'] = df['MIN30'] / df.close - bias df['HT_TRENDLINE'] = df['HT_TRENDLINE'] / df.close - bias df['AVGPRICE'] = df['AVGPRICE'] / df.close - bias df['MEDPRICE'] = df['MEDPRICE'] / df.close - bias df['TYPPRICE'] = df['TYPPRICE'] / df.close - bias df['WCLPRICE'] = df['WCLPRICE'] / df.close - bias df['open'] = df['open'] / df.close - bias df['high'] = df['high'] / df.close - bias df['low'] = df['low'] / df.close - bias