LoginSignup
0
1

テクニカル分析

Posted at

テクニカル分析

移動平均

# SMAを算出
df["sma5"] = ta.sma(df["cl"], length=5)
df["sma10"] = ta.sma(df["cl"], length=10)

plt.figure(figsize=(12,6))
plt.title("終値価格系列とSMA10")

#終値系列
plt.plot(df.index, df.cl, label="終値")
plt.legend(loc='lower right')
plt.ylabel("終値価格系列", fontsize=10)
plt.xlabel('Date')

#軸と凡例の設定
plt.plot([],[],color='r',label='SMA')
plt.legend(loc='lower right')
plt.twinx()

#sma
plt.plot(df["sma5"],color="r", label="SMA5")
plt.plot(df["sma10"],color="r", label="SMA10")
plt.ylim([min(df["sma10"].dropna())-100, max(df["sma10"].dropna())+100])
plt.ylabel("SMA", fontsize=10)

ボリンジャーバンド

bbands = ta.bbands(df["cl"], length=10)

df["BBL_10_2.0"] = bbands["BBL_10_2.0"] # 下の線
df["BBM_10_2.0"] = bbands["BBM_10_2.0"] # 移動平均線
df["BBU_10_2.0"] = bbands["BBU_10_2.0"] # 上の線

df["BBB_10_2.0"] = bbands["BBB_10_2.0"] # バンドの幅
df["BBP_10_2.0"] = bbands["BBP_10_2.0"] # (close - lower) / (upper-lower)

plt.figure(figsize=(12,6))
plt.title("終値価格系列とボリンジャーバンド")

#終値系列
plt.plot(df.index, df.cl, label="終値")
plt.legend(loc='lower right')
plt.ylabel("終値価格系列", fontsize=10)
plt.xlabel('Date')

#軸と凡例の設定
plt.plot([],[],color='r',label='bbands')
plt.legend(loc='lower right')
plt.twinx()

#bbands
plt.plot(df['BBL_10_2.0'],color="r", label="BBL")
plt.plot(df['BBM_10_2.0'],color="r", label="bbands")
plt.plot(df['BBU_10_2.0'],color="r", label="BBU")
plt.ylim([min(df["BBL_10_2.0"].dropna())-100, max(df["BBU_10_2.0"].dropna())+100])
plt.ylabel("BBands", fontsize=10)

サイクル分析(一目均衡表)

ichimoku_visible, _ = ta.ichimoku(df["hi"], df["lo"], df["cl"])
df["ISA_9"] = ichimoku_visible["ISA_9"] # spanA
df["ISB_26"] = ichimoku_visible["ISB_26"] # spanB
df["ITS_9"] = ichimoku_visible["ITS_9"] # 転換線
df["IKS_26"] = ichimoku_visible["IKS_26"] # 基準線
# df["ICS_26"] = ichimoku_visible["ICS_26"] # 一目スパン(現在の値がNoneになるので利用しません)

plt.figure(figsize=(12,6))
plt.title("終値価格系列と一目均衡表")

#終値系列
plt.plot(df.index, df.cl, label="終値")
plt.legend(loc='lower right')
plt.ylabel("終値価格系列", fontsize=10)
plt.xlabel('Date')

#軸と凡例の設定
plt.plot([],[],color='r',label='一目均衡表')
plt.legend(loc='lower right')
plt.twinx()

#ichomoku
plt.plot(df["ISA_9"],color="r", label="ISA_9")
plt.plot(df["ISB_26"],color="r", label="ISB_26")
plt.plot(df["ITS_9"],color="r", label="ITS_9")
plt.plot(df["IKS_26"],color="r", label="IKS_26")
plt.ylim([min(df["IKS_26"].dropna())-100, max(df["IKS_26"].dropna())+100])
plt.ylabel("一目均衡表", fontsize=10)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1