pybitflyer

BitcoinBot「招き猫」目次に戻る

pybitflyerとは

 

難しいprivateAPIアクセスルール

bitflyerのapiにアクセスする時に、以下の決まりがある。

以下の情報を HTTP リクエストヘッダに含めます。

    • ACCESS-KEY: 開発者ページで発行した API key
    • ACCESS-TIMESTAMP: リクエスト時の Unix Timestamp
    • ACCESS-SIGN: 以下の方法でリクエストごとに生成した署名

ACCESS-SIGN は、ACCESS-TIMESTAMP, HTTP メソッド, リクエストのパス, リクエストボディ を文字列として連結したものを、 API secret で HMAC-SHA256 署名を行った結果です

以下のように暗号化やアドレスの連結など自分でやります。
面倒臭そうです。

    message = timestamp + method + path_url
    signature = hmac.new(bytearray(cfg.api_secret.encode('utf-8')), message.encode('utf-8') , digestmod = hashlib.sha256 ).hexdigest()

    headers = {
        'ACCESS-KEY' : cfg.api_key,
        'ACCESS-TIMESTAMP' : timestamp,
        'ACCESS-SIGN' : signature,
        'Content-Type' : 'application/json'
    }
       response = requests.get( base_url + path_url , headers = headers)
        result=response.json()

 

こういったものを代行してやってくれるのが、ラッパーモジュール、「pybitflyer」

作者の「おおかみ山」さん自身の紹介ブログが有ります。

https://github.com/yagays
MIT License Copyright (c) 2016 yag_ays
おおかみ山
便利なパッケージの開発者様に感謝の意を表明させていただきます 。

これを踏まえて、コードを書くとこんなに簡単になります。

api = pybitflyer.API(api_key=cfg.api_key, api_secret=cfg.api_secret)

response = api.getpositions(product_code=cfg.product_code)

pybitflyer仕様詳細

 

レスポンスは2019/12月の実際のデータです。

データ例で、[{・・・・} と右括弧]が無いものは、それより後を省略していまして、本来はデータが延々と続きます。

class API(object):

def __init__ (self, api_key=None, api_secret=None, timeout=None):

コードは作者様のオリジナルでご覧ください

def request (self, endpoint, method=”GET”, params=None):

コードは作者様のオリジナルでご覧ください


*product_codeの種類が少ないが、今は以下(先物は名前が変わる)

[{‘product_code’: ‘BTC_JPY’},
{‘product_code’: ‘FX_BTC_JPY’},
{‘product_code’: ‘ETH_BTC’},
{‘product_code’: ‘BCH_BTC’},
{‘alias’: ‘BTCJPY_MAT1WK’, ‘product_code’: ‘BTCJPY27DEC2019’},
{‘product_code’: ‘ETH_JPY’},
{‘alias’: ‘BTCJPY_MAT3M’, ‘product_code’: ‘BTCJPY27MAR2020’},
{‘alias’: ‘BTCJPY_MAT2WK’, ‘product_code’: ‘BTCJPY03JAN2020’}]

 

 

HTTP Public API

 

def board (self, **params):板情報

“””Order Book
API Type:HTTP Public API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.

“””

endpoint = “/v1/board”

return self.request (endpoint, params=params)

return 辞書

例:FX_BTC_JPY midprice = 791740.0
asks 件数 2121(実際はデータがこの件数帰ってくる)
bids 件数 2130(同上)

def ticker (self, **params):Ticker

“””Ticker
API Type:HTTP Public API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.

endpoint = “/v1/ticker”

return self.request (endpoint, params=params)

レスポンス

{‘best_ask’: 792811.0,
‘best_ask_size’: 0.10268973,
‘best_bid’: 792761.0,
‘best_bid_size’: 0.01,
‘ltp’: 792684.0,
‘product_code’: ‘FX_BTC_JPY’,
‘tick_id’: 72267326,
‘timestamp’: ‘2019-12-22T07:51:31.207’,
‘total_ask_depth’: 6490.98433523,
‘total_bid_depth’: 6814.28615198,
‘volume’: 41112.04104966,
‘volume_by_product’: 41109.47804966}

def executions (self, **params):約定履歴

“””Execution History 
API Type:HTTP Public API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
count, before, after: See Pagination.

endpoint = “/v1/executions”

return self.request (endpoint, params=params)

レスポンス

[
{‘buy_child_order_acceptance_id’: ‘JRF20191222-075353-029518’,
‘exec_date’: ‘2019-12-22T07:53:54.253’,
‘id’: 1474431451,
‘price’: 792575.0,
‘sell_child_order_acceptance_id’: ‘JRF20191222-075354-553160’,
‘side’: ‘SELL’,
‘size’: 0.1}
]

これを100件返すようだ

def getboardstate (self, **params):板の状態

“””Order book status 
API Type:HTTP Public API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETC_BTC”.

endpoint = “/v1/getboardstate”

return self.request (endpoint, params=params)

レスポンス

{‘health’: ‘NORMAL’, ‘state’: ‘RUNNING’}

def gethealth (self, **params):取引所の状態>

“””Exchange status 
This will allow you to determine the current status of the exchange.
API Type:HTTP Public API

Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
count, before, after: See Pagination.

Response
——–
status: one of the following levels will be displayed
NORMAL: The exchange is operating.
BUSY: The exchange is experiencing heavy traffic.
VERY BUSY: The exchange is experiencing extremely heavy traffic. There is a possibility that orders will fail or be processed after a delay.
STOP: The exchange has been stopped. Orders will not be accepted.

endpoint = “/v1/gethealth”

return self.request (endpoint, params=params)

レスポンス

NORMAL

def getchats (self, **params):チャット

“”” Chat 
Get an instrument list
API Type:HTTP Public API
Parameters:
from_date: This accesses a list of any new messages after this date.

endpoint = “/v1/getchats”

return self.request(endpoint, params=params)

レスポンス

無指定の場合5日分のデータ

PCが何十分も固まるくらいすごいデータ量なのでこれはやらないほうがいい。

 


HTTP Private API

 

def getbalance (self, **params):資産残高を取得

“””Get Account Asset Balance 
API Type:HTTP Private API

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getbalance”

return self.request (endpoint, params=params)

レスポンス

[{‘amount’: 1000000.0, ‘available’: 1000000.0, ‘currency_code’: ‘JPY’},
{‘amount’: 3.5e-05, ‘available’: 3.5e-05, ‘currency_code’: ‘BTC’},
{‘amount’: 0.0, ‘available’: 0.0, ‘currency_code’: ‘BCH’},
{‘amount’: 3.28e-06, ‘available’: 3.28e-06, ‘currency_code’: ‘ETH’},
{‘amount’: 0.0, ‘available’: 0.0, ‘currency_code’: ‘ETC’},
{‘amount’: 0.0, ‘available’: 0.0, ‘currency_code’: ‘LTC’},
{‘amount’: 0.0, ‘available’: 0.0, ‘currency_code’: ‘MONA’},
{‘amount’: 0.0, ‘available’: 0.0, ‘currency_code’: ‘LSK’},
{‘amount’: 0.0, ‘available’: 0.0, ‘currency_code’: ‘XRP’}]

def getcollateral (self, **params):証拠金の状態を取得

“””Get Margin Status
API Type:HTTP Private API
Parameters:
collateral: This is the amount of deposited in Japanese Yen.
open_position_pnl: This is the profit or loss from valuation.
require_collateral: This is the current required margin.
keep_rate: This is the current maintenance margin.

if not all ([self.api_key, self.api_secret]):

raise AuthException ()

endpoint = “/v1/me/getcollateral”

return self.request (endpoint, params=params)

レスポンス

{‘collateral’: 2172.802566944, ‘open_position_pnl’: -183.6819084, ‘require_collateral’: 549.99225, ‘keep_rate’: 3.616633977195133}

def getcollateralhistory (self, **params):証拠金の変動履歴を取得

“””Get Margin Change History 
API Type:HTTP Private API
Parameters:
collateral: This is the amount of deposited in Japanese Yen.
open_position_pnl: This is the profit or loss from valuation.
require_collateral: This is the current required margin.
keep_rate: This is the current maintenance margin.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getcollateralhistory”

return self.request (endpoint, params=params)

レスポンス

[{‘id’: 7926, ‘currency_code’: ‘JPY’, ‘change’: -613.0, ‘amount’: -403.0, ‘reason_code’: ‘CLEARING_COLL’, ‘date’: ‘2019-12-18T21:19:57.98’},・・・続く

def getaddresses (self, **params):預入用アドレス取得

“””Get Bitcoin/Ethereum Deposit Addresses 
API Type:HTTP Private API
Parameters:
type: “NORMAL” for general deposit addresses.
currency_code: “BTC” for Bitcoin addresses and “ETH” for Ethereum addresses.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getaddresses”

return self.request (endpoint, params=params)

レスポンス

[{‘type’: ‘NORMAL’, ‘currency_code’: ‘BTC’, ‘address’: ‘3DyiMuCSXczDkBirqC1cJeg16Ktie3G8Ag’}, {‘type’: ‘NORMAL’, ‘currency_code’: ‘BCH’, ‘address’: ‘3DyiMuCSXczDkBirqC1cJeg16Ktie3G8Ag’}, {‘type’: ‘NORMAL’, ‘currency_code’: ‘ETH’, ‘address’: ‘0x0ad6ef514ab3013cffccc0dae4d2da7661f7a1f4’}, {‘type’: ‘NORMAL’, ‘currency_code’: ‘ETC’, ‘address’: ‘0x0ad6ef514ab3013cffccc0dae4d2da7661f7a1f4’}]

*これらのアドレスに通貨を送信すると死んだあと天国に行けます。

def getcoinins (self, **params):仮想通貨預入履歴

“””Get Bitcoin/Ether Deposit History 
API Type:HTTP Private API
Parameters:
count, before, after: See Pagination.

Response:
status: If the Bitcoin deposit is being processed, it will be listed as “PENDING”. If the deposit has been completed, it will be listed as “COMPLETED”.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getcoinins”

return self.request (endpoint, params=params)

レスポンス

[{‘id’: 6775983, ‘order_id’: ‘CDP20190615-232503-619314’, ‘currency_code’: ‘ETH’, ‘amount’: 0.8091934, ‘address’: ‘0x0ad6ef514ab3013cffccc0dae4d2da7661f7a1f4’, ‘tx_hash’: ‘0xe2bd3d0cc270196727646437f6113223c555f5642df37fd5d29b0c7447c50152’, ‘status’: ‘COMPLETED’, ‘event_date’: ‘2019-06-15T23:25:03.597’},・・・続く

def sendcoin (self, **params):

“””Bitcoin/Ethereum External Delivery 
API Type:HTTP Private API
Parameters:
currency_code: Required. Type of currency to be sent. Please use “BTC” for Bitcoin and “ETH” for Ethereum.
amount: Amount to be sent, specified as a number.
If the currency_code is “BTC”, then the units are in BTC.
If the currency_code is `”ETC”, then the units are in Ether.
amount_text: Specifies the amount to be sent as a string. You are required to choose either amount or amount_text.
address: Required. Specifies the address to which it will be sent.
When currency_code is specified as “ETH”, funds cannot be sent to a contract address.
The address designated here will automatically be labeled as an external address.
additional_fee: You may specify an additional fee to be paid to Bitcoin miners to prioritize their transaction. Standard fees based on transaction data size are paid by bitFlyer; however, the customer is responsible for any additional fees.
Omitted values will be entered as “0”.
The upper limit is 0.0005 BTC .
This can not be used if currency_code is specified as “ETH”.

Response:
message_id: Transaction Message Receipt ID

If an error with a negative status value is returned, the transaction has not been broadcast.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/sendcoin”

return self.request (endpoint, “POST”, params=params)

レスポンス

??

def getcoinouts (self, **params):仮想通貨送付履歴

“””Get Bitcoin/Ether Transaction History 
API Type:HTTP Private API
Parameters:
count, before, after: See Pagination.
message_id: You can confirm delivery status by checking a transaction receipt ID with the Bitcoin/Ethereum External Delivery API.

Response:
status: If the remittance is being processed, it will be listed as “PENDING”. If the remittance has been completed, it will be listed as “COMPLETED”.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getcoinouts”

return self.request (endpoint, params=params)

レスポンス

[{‘id’: 6811988, ‘order_id’: ‘CWD20190622-220040-612243’, ‘currency_code’: ‘BTC’, ‘amount’: 0.012093, ‘address’: ‘3NrXbiow8LFnfcikikh5h6Cnhq6Kgu9nqc’, ‘tx_hash’: ‘c3816a7cdf700d559a5b541b466f830213d787a97ad1d7aaab0523c813464f40’, ‘fee’: 0.0004, ‘additional_fee’: 0.0, ‘status’: ‘COMPLETED’, ‘event_date’: ‘2019-06-22T22:00:40.857’},・・・続く

 

def getbankaccounts (self, **params):銀行口座一覧取得

“””Get Summary of Bank Accounts 
Returns a summary of bank accounts registered to your account.
API Type:HTTP Private API

Response:
id: ID for the account designated for withdrawals.
is_verified: Will be return true if the account is verified and capable of sending money.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getbankaccounts”

return self.request (endpoint, params=params)

レスポンス

{‘status’: -500, ‘error_message’: ‘Permission denied’, ‘data’: None}

設定画面の取得許可のチェックを入れてないのでエラーになった

def getdeposits (self, **params):入金履歴

“””Get Cash Deposits 
API Type:HTTP Private API
Parameters:
count, before, after: See Pagination.

Response:
status: If the cash deposit is being processed, it will be listed as “PENDING”. If the deposit has been completed, it will be listed as “COMPLETED”.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getdeposits”

return self.request (endpoint, params=params)

レスポンス

[{‘id’: 1105002, ‘order_id’: ‘MDP20170821-001549-481182’, ‘currency_code’: ‘JPY’, ‘amount’: 1000000.0, ‘status’: ‘COMPLETED’, ‘event_date’: ‘2019-08-21T00:15:49.83’},・・・続く

def withdraw (self, **params):出金

“””Cancelling deposits 
API Type:HTTP Private API
Parameters:
currency_code: Required. Currently only compatible with “JPY”.
bank_account_id: Required. Specify id of the bank account.
amount: Required. This is the amount that you are canceling.

Additional fees apply for withdrawals. Please see the Fees and Taxes page for reference.

Response:
message_id: Transaction Message Receipt ID

If an error with a negative status value is returned, the cancellation has not been committed.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/withdraw”

return self.request (endpoint, “POST”, params=params)

 

def getwithdrawals (self, **params):出金履歴

“””Get Deposit Cancellation History 
API Type:HTTP Private API
Parameters:
count, before, after: See Pagination.

Response:
status: If the cancellation is being processed, it will be listed as “PENDING”. If the cancellation has been completed, it will be listed as “COMPLETED”.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getwithdrawals”

return self.request (endpoint, params=params)

レスポンス

[{‘id’: 2308839, ‘order_id’: ‘MWD20171227-045949-177924’, ‘currency_code’: ‘JPY’, ‘amount’: 200000.0, ‘status’: ‘COMPLETED’, ‘event_date’: ‘2018-12-27T04:59:49.497’},・・・続く

def sendchildorder (self, **params):新規注文を出す

“””Send a New Order 
API Type:HTTP Private API
Parameters:
product_code: Required. The product being ordered. Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
child_order_type: Required. For limit orders, it will be “LIMIT”. For market orders, “MARKET”.
side: Required. For buy orders, “BUY”. For sell orders, “SELL”.
price: Specify the price. This is a required value if child_order_type has been set to “LIMIT”.
size: Required. Specify the order quantity.
minute_to_expire: Specify the time in minutes until the expiration time. If omitted, the value will be 525600 (365 days).
time_in_force: Specify any of the following execution conditions – “GTC”, “IOC”, or “FOK”. If omitted, the value defaults to “GTC”.

Response:
If the parameters are correct, the status code will show 200 OK.

child_order_acceptance_id: This is the ID for the API. To specify the order to return, please use this instead of child_order_id. Please confirm the item is either Cancel Order or Obtain Execution List.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/sendchildorder”

return self.request (endpoint, “POST”, params=params)

def cancelchildorder (self, **params):注文をキャンセルする

“””Cancel Order 
API Type:HTTP Private API
Parameters:
product_code: Required. The product for the corresponding order. Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
Please specify only one between child_order_id and child_order_acceptance_id

child_order_id: ID for the canceling order.
child_order_acceptance_id: Expects an ID from Send a New Order. When specified, the corresponding order will be cancelled.

Response:
If the parameters are correct, the status code will show 200 OK.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/cancelchildorder”

return self.request (endpoint, “POST”, params=params)

def sendparentorder (self, **params):新規の親注文を出す(特殊注文)

“””Submit New Parent Order  (Special order) 
It is possible to place orders including logic other than simple limit orders (LIMIT) and market orders (MARKET). Such orders are handled as parent orders. By using a special order, it is possible to place orders in response to market conditions or place multiple associated orders.

Please read about the types of special orders and their methods in the bitFlyer Lightning documentation on special orders.

API Type:HTTP Private API

Parameters:
order_method: The order method. Please set it to one of the following values. If omitted, the value defaults to “SIMPLE”.
“SIMPLE”: A special order whereby one order is placed.
“IFD”: Conducts an IFD order. In this method, you place two orders at once, and when the first order is completed, the second order is automatically placed.
“OCO”: Conducts an OCO order. In this method, you place two orders at one, and when one of the orders is completed, the other order is automatically canceled.
“IFDOCO”: Conducts an IFD-OCO order. In this method, once the first order is completed, an OCO order is automatically placed.
minute_to_expire: Specifies the time until the order expires in minutes. If omitted, the value defaults to 525600 (365 days).
time_in_force: Specify any of the following execution conditions – “GTC”, “IOC”, or “FOK”. If omitted, the value defaults to “GTC”.
parameters: Required value. This is an array that specifies the parameters of the order to be placed. The required length of the array varies depending upon the specified order_method.
If “SIMPLE” has been specified, specify one parameter.
If “IFD” has been specified, specify two parameters. The first parameter is the parameter for the first order placed. The second parameter is the parameter for the order to be placed after the first order is completed.
If “OCO” has been specified, specify two parameters. Two orders are placed simultaneously based on these parameters.
If “IFDOCO” has been specified, specify three parameters. The first parameter is the parameter for the first order placed. After the order is complete, an OCO order is placed with the second and third parameters.

In the parameters, specify an array of objects with the following keys and values.

product_code: Required value. This is the product to be ordered. Currently, only “BTC_JPY” is supported.
condition_type: Required value. This is the execution condition for the order. Please set it to one of the following values.
“LIMIT”: Limit order.
“MARKET”: Market order.
“STOP”: Stop order.
“STOP_LIMIT”: Stop-limit order.
“TRAIL”: Trailing stop order.
side: Required value. For buying orders, specify “BUY”, for selling orders, specify “SELL”.
size: Required value. Specify the order quantity.
price: Specify the price. This is a required value if condition_type has been set to “LIMIT” or “STOP_LIMIT”.
trigger_price: Specify the trigger price for a stop order. This is a required value if condition_type has been set to “STOP” or “STOP_LIMIT”.
offset: Specify the trail width of a trailing stop order as a positive integer. This is a required value if condition_type has been set to “TRAIL”.

Response:
If the parameters are correct, the status code will show 200 OK.

parent_order_acceptance_id: This is the ID for the API. To specify the order to return, please use this instead of parent_order_id.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/sendparentorder”

return self.request (endpoint, “POST”, params=params)

def cancelparentorder (self, **params):<親注文をキャンセルする

“””Cancel parent order 

Parent orders can be canceled in the same manner as regular orders. If a parent order is canceled, the placed orders associated with that order will all be canceled.

API Type:HTTP Private API

Parameters:
product_code: Required. The product for the corresponding order. Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
Please specify only one between parent_order_id and parent_order_acceptance_id

parent_order_id: ID for the canceling order.
parent_order_acceptance_id: Expects an ID from Submit New Parent Order. When specified, the corresponding order will be cancelled.

Response:
If the parameters are correct, the status code will show 200 OK.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/cancelparentorder”

return self.request (endpoint, “POST”, params=params)

def cancelallchildorders (self, **params):すべての注文をキャンセルする

“””Cancel All Orders 
API Type:HTTP Private API
Parameters:
product_code: The product for the corresponding order. Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.

Response
——–
If the parameters are correct, the status code will show 200 OK.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/cancelallchildorders”

return self.request (endpoint, “POST”, params=params)

def getchildorders (self, **params):<注文の一覧を取得

“””List Orders  
API Type:HTTP Private API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
count, before, after: See Pagination.
child_order_state: When specified, return only orders that match the specified value. You must specify one of the following:
ACTIVE: Return open orders
COMPLETED: Return fully completed orders
CANCELED: Return orders that have been cancelled by the customer
EXPIRED: Return order that have been cancelled due to expiry
REJECTED: Return failed orders
parent_order_id: If specified, a list of all orders associated with the parent order is obtained.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getchildorders”

return self.request (endpoint, params=params)

def getparentorders (self, **params):親注文の一覧を取得

“””List Parent Orders 
API Type:HTTP Private API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
count, before, after: See Pagination.
child_order_state: When specified, return only orders that match the specified value. You must specify one of the following:
ACTIVE: Return open orders
COMPLETED: Return fully completed orders
CANCELED: Return orders that have been cancelled by the customer
EXPIRED: Return order that have been cancelled due to expiry
REJECTED: Return failed orders

Response
——–
price and size values for parent orders with multiple associated orders are both reference values only.

To obtain the detailed parameters for individual orders, use the API to obtain the details of the parent order. To obtain a list of associated orders, use the API to obtain the order list.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getparentorders”

return self.request (endpoint, params=params)

def getparentorder (self, **params):親注文の詳細を取得

“””Get Parent Order Details 
API Type:HTTP Private API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.

Please specify only parent_order_id or parent_order_acceptance_id.

parent_order_id: The ID of the parent order in question.
parent_order_acceptance_id: The acceptance ID for the API to place a new parent order. If specified, it returns the details of the parent order in question.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getparentorder”

return self.request (endpoint, params=params)

レスポンス

{‘status’: -111, ‘error_message’: ‘Order not found’, ‘data’: None}

def getexecutions (self, **params):約定の一覧を取得

“””List Executions 
API Type:HTTP Private API
Parameters:
product_code: Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.
count, before, after: See Pagination.
child_order_id: Optional. When specified, a list of stipulations related to the order will be displayed.
child_order_acceptance_id: Optional. Expects an ID from Send a New Order. When specified, a list of stipulations related to the corresponding order will be displayed.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getexecutions”

return self.request (endpoint, params=params)

レスポンス

[{‘id’: 1469406646, ‘side’: ‘BUY’, ‘price’: 794343.0, ‘size’: 0.01, ‘exec_date’: ‘2019-12-18T21:19:57.98’, ‘child_order_id’: ‘JFX20191218-211957-945582F’, ‘commission’: 0.0, ‘child_order_acceptance_id’: ‘JRF20191218-211957-192057’},・・・続く

 

def getpositions (self, **params):建玉の一覧を取得

“”” API Type:HTTP Private API
Parameters:
product_code: Currently supports only “FX_BTC_JPY”.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/getpositions”

return self.request (endpoint, params=params)

レスポンス

{‘commission’: 0.0,
‘leverage’: 4.0,
‘open_date’: ‘2020-01-03T18:05:38.257’,
‘pnl’: -7.64,
‘price’: 808339.0,
‘product_code’: ‘FX_BTC_JPY’,
‘require_collateral’: 2020.8475,
‘sfd’: 0.0,
‘side’: ‘BUY’,
‘size’: 0.01,
‘swap_point_accumulate’: 0.0}

 

def gettradingcommission (self, **params):取引手数料を取得

“”” 
API Type:HTTP Private API
Parameters:
product_code: Required. Designate “BTC_JPY”, “FX_BTC_JPY” or “ETH_BTC”.

if not all ([self.api_key, self.api_secret]):
raise AuthException ()

endpoint = “/v1/me/gettradingcommission”

return self.request (endpoint, params=params)

レスポンス

{‘Message’: “No HTTP resource was found that matches the request URI ‘https://api.bitflyer.jp/v1/me/gettradingcommission’.”}

なんか間違ったか?

 

 

 

 

 

 

 

 

BitcoinBot「招き猫」目次に戻る

タイトルとURLをコピーしました