data_df.loc[:, "X_SMA"] = ta.sma(close=data_df.Close, length=10)
data_df.loc[:, "X_WMA"] = ta.wma(close=data_df.Close, length=10)
data_df.loc[:, "X_EMA"] = ta.ema(close=data_df.Close, length=10)
data_df.loc[:, "T_SMA"] = data_df.X_SMA < data_df.Close
data_df.loc[:, "T_WMA"] = data_df.X_WMA < data_df.Close
data_df.loc[:, "T_EMA"] = data_df.X_EMA < data_df.Close
kdj = ta.kdj(high=data_df.High, low=data_df.Low, close=data_df.Close, length=14)
data_df.loc[:, "X_WILLR"] = ta.willr(
high=data_df.High, low=data_df.Low, close=data_df.Close, length=14
)
data_df.loc[:, "X_STCK"] = kdj[kdj.columns[0]]
data_df.loc[:, "X_STCD"] = kdj[kdj.columns[1]]
data_df.loc[:, "T_WILLR"] = data_df.X_WILLR > data_df.X_WILLR.shift(1)
data_df.loc[:, "T_STCK"] = data_df.X_STCK > data_df.X_STCK.shift(1)
data_df.loc[:, "T_STCD"] = data_df.X_STCD > data_df.X_STCD.shift(1)
data_df.loc[:, "X_RSI"] = ta.rsi(close=data_df.Close, length=6)
def rsi_trend(x):
if x[0] > 70:
return False
elif x[0] < 30:
return True
else:
return x[0] > x[1]
data_df.loc[:, "T_RSI"] = pd.concat(
[data_df.X_RSI, data_df.X_RSI.shift(1)], axis=1
).apply(rsi_trend, axis=1)
data_df.loc[:, "X_CCI"] = ta.cci(
high=data_df.High, low=data_df.Low, close=data_df.Close, length=14
)
def cci_trend(x):
if x[0] > 200:
return False
elif x[0] < -200:
return True
else:
return x[0] > x[1]
data_df.loc[:, "T_CCI"] = pd.concat(
[data_df.X_CCI, data_df.X_CCI.shift(1)], axis=1
).apply(cci_trend, axis=1)
動量 > 0 ,看多
動量 <= 0,看空
data_df.loc[:, "X_MOM"] = ta.mom(close=data_df.Close, length=10)
data_df.loc[:, "T_MOM"] = data_df.X_MOM > 0
使用原始指標準確率:
使用趨勢指標準確率:
看起來是有增長,趨勢化資料明顯減輕了Overfitting狀況,明天考慮修改些指標的參數看是否會有所提升。