2020年10月14日水曜日

bitFlyer API with Python

Source 

KEY = 'kkkkkkkk' SECRET = 'xxxxxxxxxxxx' ENDPOINT = 'https://api.bitflyer.com' MKT = 'ETH_JPY'
import urllib.request
import requests
import json
import pprint
import datetime
import hmac
import hashlib

def getBoard():
    path = '/v1/executions'

    url = ENDPOINT + path +  '?product_code=' + MKT
    print(url)

    req = urllib.request.Request(urlmethod='GET')
 
    req.add_header('Content-Type''application/json')

    try:
        with urllib.request.urlopen(reqas res:
            return pd.read_json(res.read())
    except urllib.error.HTTPError as e:
        print('exception http')
        print(e)
        content = json.loads(e.read())
        pprint.pprint(content)
    except Exception as e:
        print(e)

def makeCancel():
    timestamp = datetime.datetime.now().strftime('%y%m%d%H%M%S')
    method = 'POST'
    path = '/v1/me/cancelallchildorders'

    body = json.JSONEncoder()
    jsonObj = {'product_code'MKT}
    body = json.dumps(jsonObj)

    text = timestamp + method + path + body

    bSecret = SECRET.encode('utf-8')
    bMsg = text.encode('utf-8')
    sign = hmac.new(bSecret,bMsg,hashlib.sha256).hexdigest()
    bBody = body.encode('utf-8')

    url = ENDPOINT + path
    print(url)

    req = urllib.request.Request(url,data=bBodymethod='POST')

    req.add_header('ACCESS-KEY'KEY)
    req.add_header('ACCESS-TIMESTAMP'timestamp)
    req.add_header('ACCESS-SIGN'sign)
    req.add_header('Content-Type''application/json')

    try:
        with urllib.request.urlopen(reqas res:
            print(res.status, res.reason)
            for header in res.getheaders():
                print(header)
            print()
            content = json.loads(res.read())
            pprint.pprint(content)
    except urllib.error.HTTPError as e:
        print('exception http')
        print(e)
        content = json.loads(e.read())
        pprint.pprint(content)
        return json.loads(e.read())
    except Exception as e:
        print(e)

def getCollateral():
    timestamp = datetime.datetime.now().strftime('%y%m%d%H%M%S')
    method = 'GET'
    path = '/v1/me/getcollateral'
    # path = '/v1/me/getbalance'
    body = json.JSONEncoder()

    text = timestamp + method + path

    bSecret = SECRET.encode('utf-8')
    bMsg = text.encode('utf-8')
    sign = hmac.new(bSecret,bMsg,hashlib.sha256).hexdigest()

    url = ENDPOINT + path
    print(url)

    req = urllib.request.Request(urlmethod='GET')

    req.add_header('ACCESS-KEY'KEY)
    req.add_header('ACCESS-TIMESTAMP'timestamp)
    req.add_header('ACCESS-SIGN'sign)
    req.add_header('Content-Type''application/json')

    try:
        with urllib.request.urlopen(reqas res:
            print(res.status, res.reason)
           return pd.read_json(res.read())
    except urllib.error.HTTPError as e:
        print('exception http')
        print(e)
        content = json.loads(e.read())
        pprint.pprint(content)
    except Exception as e:
        print(e)

#execut
df = getBoard()

2020年10月4日日曜日

Synology sMedio DMS

 Synology を乗り換えたら

sMedio にダビングができなくなっていた。

設定の DMSを有効にする をオンにしたらよさそう。

→ 支払いが必要といわれる


☆結局、

一度アンインストールして、

購入ボタンを押す

Synology ID でログインすると、旧のライセンスを移行するか聞かれるので、

ライセンスを移行。

で無事再度利用可能に。

2020年10月1日木曜日

9月の推しは「ダブルマリッジ」

9月の読書
読んだ本の数:9
読んだページ数:2326


お金の流れでわかる世界の歴史 富、経済、権力……はこう「動いた」お金の流れでわかる世界の歴史 富、経済、権力……はこう「動いた」感想
お金と産業という見方に加えて、徴税という観点は興味深かった。共産国がなくなって富の偏在が大きくなるのも確かに。税の乱れは国の乱れか。
読了日:09月29日 著者:大村 大次郎
トランピストはマスクをしない コロナとデモでカオスのアメリカ現地報告トランピストはマスクをしない コロナとデモでカオスのアメリカ現地報告感想
コロナ以前とコロナ後で別物に見える。日付を意識して読み進めた。BLM運動もあり今回はアメリカで起きてる歴史を目の当たりにしている印象。
読了日:09月26日 著者:町山 智浩
呉越春秋 湖底の城 九 (講談社文庫)呉越春秋 湖底の城 九 (講談社文庫)感想
呉越読了。最終巻まで出てきた伍子胥が起点にして終点。孫氏の作った呉も数代で滅びる。感慨深い。
読了日:09月23日 著者:宮城谷昌光
パンデミックの文明論 (文春新書)パンデミックの文明論 (文春新書)感想
コロナ対応の民族性が興味深い。にしても日本の感染数の謎は解けず。
読了日:09月21日 著者:ヤマザキ マリ,中野 信子
2030年ジャック・アタリの未来予測 ―不確実な世の中をサバイブせよ!2030年ジャック・アタリの未来予測 ―不確実な世の中をサバイブせよ!感想
資本=企業活動は国を超える。でも人々の暮らしと税金は国に縛られる。企業は国から有利な条件を引きずり出す。国は貧乏になり福祉も行き渡らなくなる。次なる知恵は何か。
読了日:09月20日 著者:ジャック・アタリ
本当の自由を手に入れるお金の大学本当の自由を手に入れるお金の大学感想
あっさり読めて役に立つ。youtubeより本の方が時間効率はいいですね。
読了日:09月20日 著者:両@リベ大学長
ひよっこ社労士のヒナコ (文春文庫)ひよっこ社労士のヒナコ (文春文庫)感想
お仕事小お説の肝は、二つある。主人公の職種と、物語における主人公のドラマ、だ。 この二つのバランスが取れている作品が、優れたお仕事小説なのである。 読みやすくて興味深い。「少女たちの羅針盤」の作者さんだったのですね。
読了日:09月13日 著者:水生 大海
99%の社長が知らない銀行とお金の話99%の社長が知らない銀行とお金の話感想
現金と金融機関からの信用。無担保にして怖がらずにレバレッジを効かせる。創業社長は現金につよい。
読了日:09月07日 著者:小山 昇
ダブルマリッジ (文春文庫)ダブルマリッジ (文春文庫)感想
法律と運用は事実。フィリピンに嫁探しに行きたくなる本。
読了日:09月05日 著者:橘 玲