외환으로 이기기 위해 그 4 ~ LINE 통지편
7702 단어 RaspberryPiLINEmessagingAPI파이썬
값 움직임이 커지면 LINE Messageing API에서 알립니다.
다른 방법도 생각했는데,
그래서 LINE을 채용했습니다.
이번 참고는 이쪽 「파이썬으로 LINE에 메시지 보내기」입니다.
LINE Notify를 친구로 만들기
스마트 폰의 LINE에서 "LINE Notify"님을 친구에게 추가합니다.

이미 친구가 200만명 가까이 있는 것 같습니다만, 실제로 그렇게 있으면 힘들군요.
아니, 더 이상 기억할 수 없습니다.
LINE Access Token 발급
토큰을 발행합니다.
토큰명은 적당한 이름으로 합니다.

여기서 하나 실패했습니다.
그룹을 만들고 거기에 알리고 싶을 때는 이 화면에서 '알림을 보내는 토크룸'을 선택해야 했던 것 같습니다. 나중에 다시 작성하는 날개가 되었습니다.
파이썬 코드
토큰을 얻을 수 있었으므로 Python 프로그램에 포함됩니다.
코드의 전체 텍스트는 공개중의 GitHub를 참조해 주세요.
from decimal import Decimal
import requests
필요한 라이브러리를 가져옵니다.
# LINE Notify settings
line_url = "https://notify-api.line.me/api/notify"
line_access_token = "## Your LINE Access Token ##"
line_headers = {'Authorization': 'Bearer ' + line_access_token}
LINE Notify에 알리기 위한 설정입니다.
line_message = ""
# Difference high and low
diff = Decimal(raw[price]["h"]) - Decimal(raw[price]["l"])
print("{} {}: {}".format(
raw["time"].replace("000Z", "").replace("T", " "),
response["instrument"],
diff
))
if response["instrument"].find("_JPY") > -1:
if diff >= 0.1:
line_message += "'" + response["instrument"] + "' "
else:
if diff >= 0.0015:
line_message += "'" + response["instrument"] + "' "
# LINE Notify
if len(line_message) > 0:
line_payload = {"message": "There were signficant price fluctuations in " + line_message + "."}
r = requests.post(line_url, headers=line_headers, params=line_payload)
대원 시세는 0.1엔 이상, 그 이외는 0.0015 미국 달러(다른) 이상의 값 움직임이 있으면 LINE 통지 메시지를 저장합니다.
마지막으로 LINE에서 알리는 메시지를 requests.post 합니다.
결과
기본적으로 어떤 통화 쌍에 큰 가치 움직임이 있었는지 알면 좋기 때문에 이런 느낌이 듭니다.
차트를 확인하고 걱정이 있으면 거래하는 것도 좋을 것입니다.

Raspberry Pi 시작시 실행
스타트업 등록해 두면 편리합니다.
/home/pi/.config/autostart/market.desktop
[Desktop Entry]
Type=Application
Name=Market Monitor
Exec=/usr/bin/python3 -B /home/pi/python/MarketMonitor/oanda_candle.py
Terminal=false
동작 확인
시스템을 재부팅하여 작동하는지 phpmyadmin을 사용하여 데이터베이스에 갇혀 있는지 확인할 수 있다면 괜찮을 것입니다.
LINE 통지는 평상시, 별로 오지 않는다고 생각하기 때문에.

환경 주위가 되었기 때문에,
포털 사이트적인 것을 만들고 싶습니다.
계속.
Reference
이 문제에 관하여(외환으로 이기기 위해 그 4 ~ LINE 통지편), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Kazuya_Murakami/items/6dce328bd988bfcafd98텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)