3
3

More than 1 year has passed since last update.

VIX 指数が 30 以上の場合に、LINE に通知を送る。

Posted at

今までの流れ

この記事で、
VIX 指数を LINE Notify で通知するというのをやりました。

将来的には、決まった時間にプログラムを実行させたいです。
とはいえ、毎日送ってこられても鬱陶しいので、
VIX 指数が x 以上だったら通知するというようにしたいです。
今回はそのプログラムを実装してみます。

やりたいこと

取得したVIX 指数が 30 以上の場合、通知する。
なんでこの値なのかについては正直適当ですw
ご自由にいじってもらえればと思います。

コード

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options 
import time

option = Options()                          
option.add_argument('--headless')           
driver = webdriver.Chrome(ChromeDriverManager().install(),options=option)

URL = r"https://www.bloomberg.co.jp/quote/VIX:IND"
driver.get(URL)

vix_value = driver.find_element_by_xpath(r"/html/body/div[5]/main/div/div/div[1]/div/div[3]/div[2]")
vix_value = float(vix_value.text)

import requests

url = "https://notify-api.line.me/api/notify"
access_token = 'トークン'
headers = {'Authorization': 'Bearer ' + access_token}

# condition は、基準になる値です。
condition = 30
if vix_value > condition :  
    payload = {'message': vix_value }
    r = requests.post(url, headers=headers, params=payload,)
else : 
    print("the value does not meet the condition.")

driver.quit()
3
3
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
3