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 ASIN(close): ''' Vector Trigonometric ASin 反正弦函数,三角函数 分组: Math Transform 数学变换 简介: real = ASIN(close) ''' return talib.ASIN(close)
def asin(client, symbol, timeframe="6m", col="close"): """This will return a dataframe of Vector Trigonometric ASin 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.ASIN(df[col].values) return pd.DataFrame({col: df[col].values, "asin": x})
def ASIN(data, **kwargs): _check_talib_presence() prices = _extract_series(data) return talib.ASIN(prices, **kwargs)
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)
import talib print talib.ASIN(10)
def ASIN(Close): return Close.apply(lambda col: ta.ASIN(col), axis=0)
def ASIN(self, name, **parameters): data = self.__data[name] return talib.ASIN(data, **parameters)