0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

📈そろそろ来るかも?株&投資信託の“兆し”を分析して自動ポストする仕組みを作った話 - その13(パラボリック)

0
Posted at

1.はじめに

どうも、趣味でデータ分析している猫背なエンジニアです。
今回は、前回に引き続き兆しシリーズのロジックについて考えたので記録していきます。

2. パラボリック

■ 概要
以前の記事で以下のように投稿ロジックを加えましたが、今回は1号機の粒度をさらに濃くするために「パラボリック」というロジックも試しに入れてみようと思っています。

■ パラボリック
パラボリックは、RSIやDMIを生み出したJ.W.ワイルダー(米国)によって考案された指標。パラボリックは、チャートの上または下に放物線のラインを表示するテクニカル指標で、主に相場のトレンド転換点を探る時に有効的。
描かれた放物線(SAR)と実際の価格の交差するポイントが売買転換点を示し、保有しているポジションを正反対にすることを繰り返して行うのがパラボリックの狙い。

$$ SAR_n = SAR_{n-1} + AF_{n-1} * (EP_{n-1} - SAR_{n-1}) $$

■ コーディング
以下のようにパラボリックを実装しました。パラボリックは厳格にしたものだったので、スペシャル枠として実装しました。

SAR
def screen_parabolic(df, af_start=0.02, af_step=0.02, af_max=0.2):
    df = df.copy()

    high = df['High'].values
    low = df['Low'].values
    close = df['Close'].values

    sar = [low[0]]  # 初期値
    trend = 1  # 1=上昇, -1=下降
    ep = high[0]
    af = af_start

    for i in range(1, len(df)):
        prev_sar = sar[-1]

        new_sar = prev_sar + af * (ep - prev_sar)

        if trend == 1:
            if low[i] < new_sar:
                trend = -1
                new_sar = ep
                ep = low[i]
                af = af_start
            else:
                if high[i] > ep:
                    ep = high[i]
                    af = min(af + af_step, af_max)

        else:
            if high[i] > new_sar:
                trend = 1
                new_sar = ep
                ep = high[i]
                af = af_start
            else:
                if low[i] < ep:
                    ep = low[i]
                    af = min(af + af_step, af_max)

        sar.append(new_sar)

    df['SAR'] = sar
    last = df.iloc[-1]
    return last["Close"] > last["SAR"]

■ 実行結果
記事執筆時点での結果では残念ながらパラボリックを通過する銘柄がいなかったようです。通過した銘柄があったら報告しますね(笑)

4.おわりに

今回は兆しシリーズのKK-FinancialEaterの一号機を進めていきました。最近はずっとスペシャル枠を進めていますが、なかなか当たらないので頭を悩ませています(笑)
次回も引き続きスペシャル枠の整備をやっていくと思うので、よろしくお願いします(笑)

📈 KK-FinancialEater

■ 原点(KK-Adam)
■ その1:プロトタイプ編
■ その2:収集器強化編
■ その3-番外編:グランビルの法則 - 設計編
■ その3:グランビルの法則
■ その4:移動平均乖離率
■ その5:ボリンジャーバンド
■ その6:RSI
■ その7:Stochastic
■ その8:Volume ratio
■ その9:DMI
■ その10 -番外編:ロジック変更
■ その10 -投稿編
■ その11:MACD
■ その12:一目均衡表

参考文献

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?