Y〇zo砲botです.SFDの変更通知が来ると思われますので公開しておきます.BitFlyer公式Twitterを2秒ごとに監視して,”SFD”,”乖離”という文字列が含まれる場合はショートして,lineに通知します.ロットは0.01に設定してあります.(Bitflyer,Twitter,lineのアクセストークン類は自分で用意してください.)
乖離がマイナスになった場合の処理(ロングする),クローズ注文の処理などを加えるとよいかもしれません.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import tweepy import pybitflyer as pbf import time import datetime import requests #ビットフライヤー key = "" secret = "" flyer_api = pbf.API(key, secret) product_code = "FX_BTC_JPY" #Twitter consumer_key = "" consumer_secret = "" access_key = "" access_secret = "" #ラインに稼働状況を通知 line_notify_token = '' line_notify_api = 'https://notify-api.line.me/api/notify' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) api = tweepy.API(auth) targets = ["乖離", "SFD"] isCanonFired = 0 #ツイート取得 while True: time.sleep(2) if datetime.datetime.now().minute % 3 == 0 and datetime.datetime.now().second < 5: message = 'Waiting for 加納砲.' payload = {'message': message} headers = {'Authorization': 'Bearer ' + line_notify_token} # 発行したトークン requests.post(line_notify_api, data=payload, headers=headers) tweet_text = [] for tweet in tweepy.Cursor(api.user_timeline,screen_name = "bitFlyer",exclude_replies = True).items(5): tweet_text.append(tweet.text) print(tweet_text) for text in tweet_text: print(text) now = datetime.datetime.now() if targets[0] in text or targets[1] in text or targets[2] in text: print("ツイートは「{}」を含んでいます.".format(targets)) isCanonFired = 1 break else: print("{}加納砲発射待機中.ツイートは「{}」を含んでいません".format(now, targets)) if isCanonFired == 1: print("全力ショート") print(flyer_api.sendchildorder(product_code=product_code, child_order_type="MARKET", size=0.01, side="SELL")) message = '加納砲発射!!!!.' payload = {'message': message} headers = {'Authorization': 'Bearer ' + line_notify_token} # 発行したトークン requests.post(line_notify_api, data=payload, headers=headers) break |