Quoinex(Liquid)+Python APIメモ

個人的メモメモ。CCXTとrequestsを使った方法は先人が公開してくださっています。APIキーの取得方法なども丁寧に書かれており必見。

自分は敢えて別方面でゆきます。

python-quoine

Quoinexでふつーに使えました。

導入

pip install python-quoine

レバレッジ取引でよく使うあれこれ

from quoine.client import Quoinex

q = Quoinex('YOUR_ID', 'YOUR_SECRET')

balance = q.get_account_balances() #残高
depth = q.get_order_book(product_id=5)  #板の取得。BTC/JPYのIDは5
trades = q.get_trades(funding_currency=None, status=None, limit=None, page=None)
orders = q.get_orders(funding_currency=None, product_id=None, status=None, with_details=False, limit=10, page=1)

def limit_buy(quantity,price):
    callback = q.create_margin_order(order_type=Quoinex.ORDER_TYPE_LIMIT,product_id=5,leverage_level=25,side=Quoinex.SIDE_BUY,quantity=quantity,price=price)
    id = callback.get('id')
    return id

def limit_sell(quantity,price):
    callback = q.create_margin_order(order_type=Quoinex.ORDER_TYPE_LIMIT,product_id=5,leverage_level=25,side=Quoinex.SIDE_SELL,quantity=quantity,price=price)
    id = callback.get('id')
    return id

def cancel(id):
    callback = q.cancel_order(order_id=id)
    print(callback) 

def update(id,quantity,price):    #未約定の注文の変更
    callback = q.update_live_order(order_id=id, quantity=quantity, price=price)
    print(callback)   

def update_t(id,stop_loss,take_profit):    #約定済の注文の変更
    callback = q.update_trade(trade_id=id, stop_loss=stop_loss, take_profit=take_profit)
    print(callback)

def close(id):    #約定済の注文を成り行きでクローズ
    callback = q.close_trade(trade_id=id)    
    print(callback)

for i in range(10):  #ordersのところで新しい方から10件取得しているのでliveなorderを10件の中から探す
    if orders[i].get('status') == 'live':
        id = orders[i].get('id')  #liveなorderがあればIDをgetしてprint
        print('live order(s) available ', str(id))   
    else:
        pass
'''
EXAMPLES
limit_buy(893,893893)  #893893円で893枚ロング
limit_sell(175,894894)  #894894円で175枚ショート
cancel(114514)  #注文ID114514をキャンセル
update(114514,810,931931)  #注文ID114514の枚数を810枚、価格を931931に変更
update_t(114514,555555,1111111)  #注文ID114514のSLを555555、TPを1111111に
close(114514)  #注文ID114514を成り行きでクローズ
'''

まあこんなところっすかね。tradesとordersの違い分かりました。tradesは建玉でordersは注文です。また追記します。


この記事が気に入ったらサポートをしてみませんか?