LoginSignup
5
6

More than 5 years have passed since last update.

Python - bitflyerからBTC/JPY板情報取得

Posted at

bitflyerからBTC/JPY板情報取得

ソース

import pybitflyer
import time
from datetime import datetime
from pytz import timezone
from dateutil import parser

BOARD_KEYS = ["asks",
              "bids",]

API_KEY = "XXXXXXXXXXXXXXXXXXXXXXX" # bitflyerマイページから取得
API_SECRET = "XXXXXXXXXXXXXXXXXXXXXXX" # bitflyerマイページから取得

def to_jst(datestr):
    return parser.parse(datestr).astimezone(timezone('Asia/Tokyo'))

if __name__ == '__main__':
    api = pybitflyer.API(api_key = API_KEY, api_secret = API_SECRET)

    board = api.board(product_code="BTC_JPY")

    for board_key in BOARD_KEYS:
        print(board_key + " : " + str(board[board_key][:5])) # 5つだけ表示

結果

asks : [{'size': 0.11494513, 'price': 444899.0}, {'size': 0.0418758, 'price': 444900.0}, {'size': 0.00975, 'price': 444998.0}, {'size': 0.94526412, 'price': 444999.0}, {'size': 10.1291162, 'price': 445000.0}]
bids : [{'size': 2.51806335, 'price': 444350.0}, {'size': 0.0035, 'price': 444300.0}, {'size': 0.496, 'price': 444274.0}, {'size': 0.01, 'price': 444100.0}, {'size': 0.01193694, 'price': 444000.0}]
5
6
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
5
6