Skip to content

Commit 6bea15d

Browse files
committed
spot orders support batch cancel; margin orders support auto borrow
1 parent 1a61162 commit 6bea15d

16 files changed

Lines changed: 621 additions & 9 deletions

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ APIv4 provides spot, margin and futures trading operations. There are public API
33

44
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
55

6-
- API version: 4.9.1
7-
- Package version: 4.9.1
6+
- API version: 4.10.0
7+
- Package version: 4.10.0
88
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
99
For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts)
1010

@@ -136,6 +136,7 @@ Class | Method | HTTP request | Description
136136
*MarginApi* | [**repay_loan**](docs/MarginApi.md#repay_loan) | **POST** /margin/loans/{loan_id}/repayment | Repay a loan
137137
*MarginApi* | [**update_loan**](docs/MarginApi.md#update_loan) | **PATCH** /margin/loans/{loan_id} | Modify a loan
138138
*MarginApi* | [**update_loan_record**](docs/MarginApi.md#update_loan_record) | **PATCH** /margin/loan_records/{loan_record_id} | Modify a loan record
139+
*SpotApi* | [**cancel_batch_orders**](docs/SpotApi.md#cancel_batch_orders) | **POST** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list
139140
*SpotApi* | [**cancel_order**](docs/SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order
140141
*SpotApi* | [**cancel_orders**](docs/SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair
141142
*SpotApi* | [**create_batch_orders**](docs/SpotApi.md#create_batch_orders) | **POST** /spot/batch_orders | Create a batch of orders
@@ -156,6 +157,8 @@ Class | Method | HTTP request | Description
156157
## Documentation For Models
157158

158159
- [BatchOrder](docs/BatchOrder.md)
160+
- [CancelOrder](docs/CancelOrder.md)
161+
- [CancelOrderResult](docs/CancelOrderResult.md)
159162
- [Contract](docs/Contract.md)
160163
- [CurrencyPair](docs/CurrencyPair.md)
161164
- [FundingAccount](docs/FundingAccount.md)

docs/BatchOrder.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Name | Type | Description | Notes
1818
**amount** | **str** | Trade amount | [optional]
1919
**price** | **str** | Order price | [optional]
2020
**time_in_force** | **str** | Time in force | [optional] [default to 'gtc']
21+
**auto_borrow** | **bool** | Used in margin trading(e.g. `account` is `margin`) to allow automatic loan of lacked part if balance is not enough. | [optional]
2122
**left** | **str** | Amount left to fill | [optional]
2223
**fill_price** | **str** | Fill price of the order | [optional]
2324
**fee** | **str** | Fee deducted | [optional]

docs/CancelOrder.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# CancelOrder
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**currency_pair** | **str** | Order currency pair |
7+
**id** | **str** | Order ID |
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+

docs/CancelOrderResult.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# CancelOrderResult
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**currency_pair** | **str** | Order currency pair | [optional]
7+
**id** | **str** | Order ID | [optional]
8+
**succeeded** | **bool** | Whether cancellation succeeded | [optional]
9+
**label** | **str** | Error label when failed to cancel the order; emtpy if succeeded | [optional]
10+
**message** | **str** | Error message when failed to cancel the order; empty if succeeded | [optional]
11+
12+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
13+
14+

docs/Order.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Name | Type | Description | Notes
1515
**amount** | **str** | Trade amount |
1616
**price** | **str** | Order price |
1717
**time_in_force** | **str** | Time in force | [optional] [default to 'gtc']
18+
**auto_borrow** | **bool** | Used in margin trading(e.g. `account` is `margin`) to allow automatic loan of lacked part if balance is not enough. | [optional]
1819
**left** | **str** | Amount left to fill | [optional]
1920
**fill_price** | **str** | Total filled in quote currency | [optional]
2021
**fee** | **str** | Fee deducted | [optional]

docs/SpotApi.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All URIs are relative to *https://api.gateio.ws/api/v4*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7+
[**cancel_batch_orders**](SpotApi.md#cancel_batch_orders) | **POST** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list
78
[**cancel_order**](SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order
89
[**cancel_orders**](SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair
910
[**create_batch_orders**](SpotApi.md#create_batch_orders) | **POST** /spot/batch_orders | Create a batch of orders
@@ -20,6 +21,57 @@ Method | HTTP request | Description
2021
[**list_trades**](SpotApi.md#list_trades) | **GET** /spot/trades | Retrieve market trades
2122

2223

24+
# **cancel_batch_orders**
25+
> list[CancelOrderResult] cancel_batch_orders(cancel_order)
26+
27+
Cancel a batch of orders with an ID list
28+
29+
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request
30+
31+
### Example
32+
33+
```python
34+
from __future__ import print_function
35+
import gate_api
36+
from gate_api.rest import ApiException
37+
38+
configuration = gate_api.Configuration()
39+
configuration.key = 'YOUR_API_KEY'
40+
configuration.secret = 'YOUR_API_SECRET'
41+
42+
# create an instance of the API class
43+
api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration))
44+
cancel_order = [gate_api.CancelOrder()] # list[CancelOrder] |
45+
46+
try:
47+
# Cancel a batch of orders with an ID list
48+
api_response = api_instance.cancel_batch_orders(cancel_order)
49+
print(api_response)
50+
except ApiException as e:
51+
print("Exception when calling SpotApi->cancel_batch_orders: %s\n" % e)
52+
```
53+
54+
### Parameters
55+
56+
Name | Type | Description | Notes
57+
------------- | ------------- | ------------- | -------------
58+
**cancel_order** | [**list[CancelOrder]**](CancelOrder.md)| |
59+
60+
### Return type
61+
62+
[**list[CancelOrderResult]**](CancelOrderResult.md)
63+
64+
### Authorization
65+
66+
Authentication with API key and secret is required
67+
68+
### HTTP request headers
69+
70+
- **Content-Type**: application/json
71+
- **Accept**: application/json
72+
73+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
74+
2375
# **cancel_order**
2476
> Order cancel_order(order_id, currency_pair)
2577

gate_api/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import absolute_import
1616

17-
__version__ = "4.9.1"
17+
__version__ = "4.10.0"
1818

1919
# import apis into sdk package
2020
from gate_api.api.futures_api import FuturesApi
@@ -27,6 +27,8 @@
2727
from gate_api.configuration import Configuration
2828
# import models into sdk package
2929
from gate_api.models.batch_order import BatchOrder
30+
from gate_api.models.cancel_order import CancelOrder
31+
from gate_api.models.cancel_order_result import CancelOrderResult
3032
from gate_api.models.contract import Contract
3133
from gate_api.models.currency_pair import CurrencyPair
3234
from gate_api.models.funding_account import FundingAccount

gate_api/api/spot_api.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,106 @@ def __init__(self, api_client=None):
3232
api_client = ApiClient()
3333
self.api_client = api_client
3434

35+
def cancel_batch_orders(self, cancel_order, **kwargs): # noqa: E501
36+
"""Cancel a batch of orders with an ID list # noqa: E501
37+
38+
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501
39+
This method makes a synchronous HTTP request by default. To make an
40+
asynchronous HTTP request, please pass async_req=True
41+
>>> thread = api.cancel_batch_orders(cancel_order, async_req=True)
42+
>>> result = thread.get()
43+
44+
:param async_req bool
45+
:param list[CancelOrder] cancel_order: (required)
46+
:return: list[CancelOrderResult]
47+
If the method is called asynchronously,
48+
returns the request thread.
49+
"""
50+
kwargs['_return_http_data_only'] = True
51+
if kwargs.get('async_req'):
52+
return self.cancel_batch_orders_with_http_info(cancel_order, **kwargs) # noqa: E501
53+
else:
54+
(data) = self.cancel_batch_orders_with_http_info(cancel_order, **kwargs) # noqa: E501
55+
return data
56+
57+
def cancel_batch_orders_with_http_info(self, cancel_order, **kwargs): # noqa: E501
58+
"""Cancel a batch of orders with an ID list # noqa: E501
59+
60+
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501
61+
This method makes a synchronous HTTP request by default. To make an
62+
asynchronous HTTP request, please pass async_req=True
63+
>>> thread = api.cancel_batch_orders_with_http_info(cancel_order, async_req=True)
64+
>>> result = thread.get()
65+
66+
:param async_req bool
67+
:param list[CancelOrder] cancel_order: (required)
68+
:return: list[CancelOrderResult]
69+
If the method is called asynchronously,
70+
returns the request thread.
71+
"""
72+
73+
local_var_params = locals()
74+
75+
all_params = ['cancel_order'] # noqa: E501
76+
all_params.append('async_req')
77+
all_params.append('_return_http_data_only')
78+
all_params.append('_preload_content')
79+
all_params.append('_request_timeout')
80+
81+
for key, val in six.iteritems(local_var_params['kwargs']):
82+
if key not in all_params:
83+
raise TypeError(
84+
"Got an unexpected keyword argument '%s'"
85+
" to method cancel_batch_orders" % key
86+
)
87+
local_var_params[key] = val
88+
del local_var_params['kwargs']
89+
# verify the required parameter 'cancel_order' is set
90+
if ('cancel_order' not in local_var_params or
91+
local_var_params['cancel_order'] is None):
92+
raise ValueError("Missing the required parameter `cancel_order` when calling `cancel_batch_orders`") # noqa: E501
93+
94+
collection_formats = {}
95+
96+
path_params = {}
97+
98+
query_params = []
99+
100+
header_params = {}
101+
102+
form_params = []
103+
local_var_files = {}
104+
105+
body_params = None
106+
if 'cancel_order' in local_var_params:
107+
body_params = local_var_params['cancel_order']
108+
# HTTP header `Accept`
109+
header_params['Accept'] = self.api_client.select_header_accept(
110+
['application/json']) # noqa: E501
111+
112+
# HTTP header `Content-Type`
113+
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
114+
['application/json']) # noqa: E501
115+
116+
# Authentication setting
117+
auth_settings = ['api_key', 'api_sign', 'api_timestamp'] # noqa: E501
118+
119+
return self.api_client.call_api(
120+
'/spot/cancel_batch_orders', 'POST',
121+
path_params,
122+
query_params,
123+
header_params,
124+
body=body_params,
125+
post_params=form_params,
126+
files=local_var_files,
127+
response_type='list[CancelOrderResult]', # noqa: E501
128+
auth_settings=auth_settings,
129+
async_req=local_var_params.get('async_req'),
130+
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
131+
_preload_content=local_var_params.get('_preload_content', True),
132+
_request_timeout=local_var_params.get('_request_timeout'),
133+
collection_formats=collection_formats)
134+
35135
def cancel_order(self, order_id, currency_pair, **kwargs): # noqa: E501
36136
"""Cancel a single order # noqa: E501
37137

gate_api/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7575
self.default_headers[header_name] = header_value
7676
self.cookie = cookie
7777
# Set default User-Agent.
78-
self.user_agent = 'OpenAPI-Generator/4.9.1/python'
78+
self.user_agent = 'OpenAPI-Generator/4.10.0/python'
7979

8080
def __del__(self):
8181
if self._pool:

gate_api/configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,6 @@ def to_debug_report(self):
248248
return "Python SDK Debug Report:\n"\
249249
"OS: {env}\n"\
250250
"Python Version: {pyversion}\n"\
251-
"Version of the API: 4.9.1\n"\
252-
"SDK Package Version: 4.9.1".\
251+
"Version of the API: 4.10.0\n"\
252+
"SDK Package Version: 4.10.0".\
253253
format(env=sys.platform, pyversion=sys.version)

0 commit comments

Comments
 (0)