3
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?

📈そろそろ来るかも?株&投資信託の“兆し”を分析して自動ポストする仕組みを作った話 - その5(ボリジャーバンド)

Last updated at Posted at 2025-12-14

1.はじめに

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

2. ボリジャーバンド

■ 概要
以前の記事で以下のような画像のスクリーニング1号機を作り内部ロジックで「移動平均乖離率」を入れましたが、今回は「ボリジャーバンド」というロジックも試しに入れてみようと思っています。

■ ボリジャーバンド
移動平均線と標準偏差で構成されており、移動平均を表す線とその上下に値動きの幅を示す線を加えた指標で、「価格の大半がこの帯(バンド)の中に収まる」という統計学を応用したテクニカル指標のひとつです。特徴は、収束と拡散を繰り返していることで、この動きにあわせて「順張り」「逆張り」それぞれの投資に利用することができる。

$$ C_t<μ_t−2σ_t$$

■ コーディング
以下のようにボリジャーバンドを実装しました。買いシグナルがあるものをピックアップする式にしているので、一般的なソースとは別かもしれません。

ボリジャーバンド
def screen_bollingerbands(df):
    df = df.copy()
    df['BB_MID'] = df['Close'].rolling(window=20).mean()
    df['BB_STD'] = df['Close'].rolling(window=20).std()
    df['BB_UPPER'] = df['BB_MID'] + (df['BB_STD'] * 2)
    df['BB_LOWER'] = df['BB_MID'] - (df['BB_STD'] * 2)

    last = df.iloc[-1]
    BollingerBands_flag = False
    if last["Close"] < last["BB_LOWER"]:
        BollingerBands_flag = True

    return BollingerBands_flag

■ 実行結果
前回のSMA乖離率のスクリーニングよりも1/10まで削ることができました。前回に引き続き、ゴリゴリ削れているのがわかります。

4.おわりに

今回は兆しシリーズのKK-FinancialEaterの一号機を進めていきました。前回に引き続きゴリゴリ削れていますが、より買い目がある銘柄を見つけるには精度を高める必要があると思いました。

📈 KK-FinancialEater

■ 原点(KK-Adam)
■ その1:プロトタイプ編
■ その2:収集器強化編
■ その3-番外編:グランビルの法則 - 設計編
■ その3:グランビルの法則
■ その4:移動平均乖離率

参考文献

3
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
3
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?