Here in the documentation https://lightning.bitflyer.com/docs#%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E6%B3%A8%E6%96%87%E3%82%92%E3%82%AD%E3%83%A3%E3%83%B3%E3%82%BB%E3%83%AB%E3%81%99%E3%82%8B
With pybitflyer
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.
Docs
----
https://lightning.bitflyer.jp/docs?lang=en#cancel-all-orders
"""
if not all([self.api_key, self.api_secret]):
raise AuthException()
endpoint = "/v1/me/cancelallchildorders"
return self.request(endpoint, "POST", params=params)
The following is the result when executed in our environment on 2020/01/18. There is a good chance that it will behave differently if it is executed in a different environment or due to a specification change on the API side. When creating a BOT, etc. using the following results, please make it after thorough verification.
cancel = bfapi.cancelallchildorders(product_code=SYMBOL)
print(cancel)
→ Nothing is displayed.
bfapi.getparentorders(product_code=SYMBOL)
Execution result
[{'id': 263032602,
'parent_order_id': 'JCP20200118-065956-905830',
'product_code': 'FX_BTC_JPY',
'side': 'BUYSELL',
'parent_order_type': 'IFDOCO',
'price': 1006594.0,
'average_price': 0.0,
'size': 0.03,
'parent_order_state': 'CANCELED',
'expire_date': '2020-01-18T08:39:56.61',
'parent_order_date': '2020-01-18T06:59:56.61',
'parent_order_acceptance_id': 'JRF20200118-065956-127674',
'outstanding_size': 0.0,
'cancel_size': 0.03,
'executed_size': 0.0,
'total_commission': 0.0},
.
.
.
Make sure parent_order_state is'CANCELED'
I am executing an IFDOCO order with a for statement. I thought that it should be initialized by canceling all positions and canceling all orders at the beginning of the for loop, and I came up with this result. I hope it will be useful for those who want to achieve the same thing.
Recommended Posts