Math Transform Functions数学转换函数

  TA-Lib提供了三角函数(正余弦、正余切、双曲)、取整、对数、平方根等数学转换函数,均是基于时间序列的向量变换。

SIN : Vector Trigonometric Sin 正弦函数:ta.SIN(close)

COS : Vector Trigonometric Cos 余弦函数:ta.COS(close)

TAN : Vector Trigonometric Tan 正切函数:ta.TAN(close)

ASIN : Vector Trigonometric ASIN 反正弦函数:ta.ASIN(close)

ACOS : Vector Trigonometric ACOS 反余弦函数:ta.ACOS(close)

ATAN : Vector Trigonometric ATAN 反正切函数:ta.ATAN(close)

SINH : Vector Trigonometric Sinh 双曲正弦函数:ta.SINH(close)

COSH : Vector Trigonometric Cosh 反曲余弦函数:ta.COSH(close)

TANH : Vector Trigonometric Tanh 反曲正切函数:ta.TANH(close)

CEIL : vector Ceil 向上取整数:ta.CEIL(close)

FLOOR : Vector Floor 向下取整数:ta.FLOOR(close)

EXP : Vector Arithmetic Ecp 指数曲线:ta.EXP(close)

LN : Vector Log Natural 自然对数:ta.LN(close)

LOG10 : Vector log 10 以10为底对数:ta.LOG10(close)

SQRT : Vector Square Root 平方根:ta.SQRT(close)

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import talib as ta
import tushare as ts

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False

def get_data(code, start='2015-01-01'):
    df = ts.get_k_data(code, start)
    df.index = pd.to_datetime(df.date)
    df = df.sort_index()
    return df

df = get_data('sh')[['open', 'close', 'high', 'low']]
df['sin'] = ta.SIN(df.close)
df['cos'] = ta.COS(df.close)
df['ln'] = ta.LN(df.close)

df[['close', 'sin', 'cos', 'ln']
].plot(figsize=(18,8), subplots=True, layout=(2,2))
plt.subplots_adjust(wspace=0, hspace=0.2)

原文地址:https://www.cnblogs.com/wintalau/p/11618631.html