Skip to content

Commit ecd5a4e

Browse files
committed
add batch order support
1 parent eb7057a commit ecd5a4e

10 files changed

Lines changed: 752 additions & 7 deletions

File tree

README.md

Lines changed: 4 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.8.1
7-
- Package version: 4.8.1
6+
- API version: 4.8.2
7+
- Package version: 4.8.2
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

@@ -138,6 +138,7 @@ Class | Method | HTTP request | Description
138138
*MarginApi* | [**update_loan_record**](docs/MarginApi.md#update_loan_record) | **PATCH** /margin/loan_records/{loan_record_id} | Modify a loan record
139139
*SpotApi* | [**cancel_order**](docs/SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order
140140
*SpotApi* | [**cancel_orders**](docs/SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair
141+
*SpotApi* | [**create_batch_orders**](docs/SpotApi.md#create_batch_orders) | **POST** /spot/batch_orders | Create a batch of orders
141142
*SpotApi* | [**create_order**](docs/SpotApi.md#create_order) | **POST** /spot/orders | Create an order
142143
*SpotApi* | [**get_currency_pair**](docs/SpotApi.md#get_currency_pair) | **GET** /spot/currency_pairs/{currency_pair} | Get detail of one single order
143144
*SpotApi* | [**get_order**](docs/SpotApi.md#get_order) | **GET** /spot/orders/{order_id} | Get a single order
@@ -154,6 +155,7 @@ Class | Method | HTTP request | Description
154155

155156
## Documentation For Models
156157

158+
- [BatchOrder](docs/BatchOrder.md)
157159
- [Contract](docs/Contract.md)
158160
- [CurrencyPair](docs/CurrencyPair.md)
159161
- [FundingAccount](docs/FundingAccount.md)

docs/BatchOrder.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# BatchOrder
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) | [optional]
7+
**succeeded** | **bool** | Whether order succeeds | [optional]
8+
**label** | **str** | Error label, empty string if order succeeds | [optional]
9+
**message** | **str** | Detailed error message, empty string if order succeeds | [optional]
10+
**id** | **str** | Order ID | [optional]
11+
**create_time** | **str** | Order creation time | [optional]
12+
**status** | **str** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional]
13+
**currency_pair** | **str** | Currency pair | [optional]
14+
**type** | **str** | Order type. limit - limit order | [optional] [default to 'limit']
15+
**account** | **str** | Account type. spot - use spot account; margin - use margin account | [optional] [default to 'spot']
16+
**side** | **str** | Order side | [optional]
17+
**amount** | **str** | Trade amount | [optional]
18+
**price** | **str** | Order price | [optional]
19+
**time_in_force** | **str** | Time in force | [optional] [default to 'gtc']
20+
**left** | **str** | Amount left to fill | [optional]
21+
**fill_price** | **str** | Fill price of the order | [optional]
22+
23+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
24+
25+

docs/SpotApi.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Method | HTTP request | Description
66
------------- | ------------- | -------------
77
[**cancel_order**](SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order
88
[**cancel_orders**](SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair
9+
[**create_batch_orders**](SpotApi.md#create_batch_orders) | **POST** /spot/batch_orders | Create a batch of orders
910
[**create_order**](SpotApi.md#create_order) | **POST** /spot/orders | Create an order
1011
[**get_currency_pair**](SpotApi.md#get_currency_pair) | **GET** /spot/currency_pairs/{currency_pair} | Get detail of one single order
1112
[**get_order**](SpotApi.md#get_order) | **GET** /spot/orders/{order_id} | Get a single order
@@ -123,6 +124,57 @@ Authentication with API key and secret is required
123124

124125
[[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)
125126

127+
# **create_batch_orders**
128+
> list[BatchOrder] create_batch_orders(order)
129+
130+
Create a batch of orders
131+
132+
Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, e.g. `account` must be identical for all orders
133+
134+
### Example
135+
136+
```python
137+
from __future__ import print_function
138+
import gate_api
139+
from gate_api.rest import ApiException
140+
141+
configuration = gate_api.Configuration()
142+
configuration.key = 'YOUR_API_KEY'
143+
configuration.secret = 'YOUR_API_SECRET'
144+
145+
# create an instance of the API class
146+
api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration))
147+
order = [] # list[Order] |
148+
149+
try:
150+
# Create a batch of orders
151+
api_response = api_instance.create_batch_orders(order)
152+
print(api_response)
153+
except ApiException as e:
154+
print("Exception when calling SpotApi->create_batch_orders: %s\n" % e)
155+
```
156+
157+
### Parameters
158+
159+
Name | Type | Description | Notes
160+
------------- | ------------- | ------------- | -------------
161+
**order** | [**list[Order]**](list.md)| |
162+
163+
### Return type
164+
165+
[**list[BatchOrder]**](BatchOrder.md)
166+
167+
### Authorization
168+
169+
Authentication with API key and secret is required
170+
171+
### HTTP request headers
172+
173+
- **Content-Type**: application/json
174+
- **Accept**: application/json
175+
176+
[[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)
177+
126178
# **create_order**
127179
> Order create_order(order)
128180

gate_api/__init__.py

Lines changed: 2 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.8.1"
17+
__version__ = "4.8.2"
1818

1919
# import apis into sdk package
2020
from gate_api.api.futures_api import FuturesApi
@@ -26,6 +26,7 @@
2626
from gate_api.api_client import ApiClient
2727
from gate_api.configuration import Configuration
2828
# import models into sdk package
29+
from gate_api.models.batch_order import BatchOrder
2930
from gate_api.models.contract import Contract
3031
from gate_api.models.currency_pair import CurrencyPair
3132
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
@@ -236,6 +236,106 @@ def cancel_orders_with_http_info(self, currency_pair, **kwargs): # noqa: E501
236236
_request_timeout=local_var_params.get('_request_timeout'),
237237
collection_formats=collection_formats)
238238

239+
def create_batch_orders(self, order, **kwargs): # noqa: E501
240+
"""Create a batch of orders # noqa: E501
241+
242+
Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, e.g. `account` must be identical for all orders # noqa: E501
243+
This method makes a synchronous HTTP request by default. To make an
244+
asynchronous HTTP request, please pass async_req=True
245+
>>> thread = api.create_batch_orders(order, async_req=True)
246+
>>> result = thread.get()
247+
248+
:param async_req bool
249+
:param list[Order] order: (required)
250+
:return: list[BatchOrder]
251+
If the method is called asynchronously,
252+
returns the request thread.
253+
"""
254+
kwargs['_return_http_data_only'] = True
255+
if kwargs.get('async_req'):
256+
return self.create_batch_orders_with_http_info(order, **kwargs) # noqa: E501
257+
else:
258+
(data) = self.create_batch_orders_with_http_info(order, **kwargs) # noqa: E501
259+
return data
260+
261+
def create_batch_orders_with_http_info(self, order, **kwargs): # noqa: E501
262+
"""Create a batch of orders # noqa: E501
263+
264+
Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, e.g. `account` must be identical for all orders # noqa: E501
265+
This method makes a synchronous HTTP request by default. To make an
266+
asynchronous HTTP request, please pass async_req=True
267+
>>> thread = api.create_batch_orders_with_http_info(order, async_req=True)
268+
>>> result = thread.get()
269+
270+
:param async_req bool
271+
:param list[Order] order: (required)
272+
:return: list[BatchOrder]
273+
If the method is called asynchronously,
274+
returns the request thread.
275+
"""
276+
277+
local_var_params = locals()
278+
279+
all_params = ['order'] # noqa: E501
280+
all_params.append('async_req')
281+
all_params.append('_return_http_data_only')
282+
all_params.append('_preload_content')
283+
all_params.append('_request_timeout')
284+
285+
for key, val in six.iteritems(local_var_params['kwargs']):
286+
if key not in all_params:
287+
raise TypeError(
288+
"Got an unexpected keyword argument '%s'"
289+
" to method create_batch_orders" % key
290+
)
291+
local_var_params[key] = val
292+
del local_var_params['kwargs']
293+
# verify the required parameter 'order' is set
294+
if ('order' not in local_var_params or
295+
local_var_params['order'] is None):
296+
raise ValueError("Missing the required parameter `order` when calling `create_batch_orders`") # noqa: E501
297+
298+
collection_formats = {}
299+
300+
path_params = {}
301+
302+
query_params = []
303+
304+
header_params = {}
305+
306+
form_params = []
307+
local_var_files = {}
308+
309+
body_params = None
310+
if 'order' in local_var_params:
311+
body_params = local_var_params['order']
312+
# HTTP header `Accept`
313+
header_params['Accept'] = self.api_client.select_header_accept(
314+
['application/json']) # noqa: E501
315+
316+
# HTTP header `Content-Type`
317+
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
318+
['application/json']) # noqa: E501
319+
320+
# Authentication setting
321+
auth_settings = ['api_key', 'api_sign', 'api_timestamp'] # noqa: E501
322+
323+
return self.api_client.call_api(
324+
'/spot/batch_orders', 'POST',
325+
path_params,
326+
query_params,
327+
header_params,
328+
body=body_params,
329+
post_params=form_params,
330+
files=local_var_files,
331+
response_type='list[BatchOrder]', # noqa: E501
332+
auth_settings=auth_settings,
333+
async_req=local_var_params.get('async_req'),
334+
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
335+
_preload_content=local_var_params.get('_preload_content', True),
336+
_request_timeout=local_var_params.get('_request_timeout'),
337+
collection_formats=collection_formats)
338+
239339
def create_order(self, order, **kwargs): # noqa: E501
240340
"""Create an order # noqa: E501
241341

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.8.1/python'
78+
self.user_agent = 'OpenAPI-Generator/4.8.2/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.8.1\n"\
252-
"SDK Package Version: 4.8.1".\
251+
"Version of the API: 4.8.2\n"\
252+
"SDK Package Version: 4.8.2".\
253253
format(env=sys.platform, pyversion=sys.version)

gate_api/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from __future__ import absolute_import
1515

1616
# import models into model package
17+
from gate_api.models.batch_order import BatchOrder
1718
from gate_api.models.contract import Contract
1819
from gate_api.models.currency_pair import CurrencyPair
1920
from gate_api.models.funding_account import FundingAccount

0 commit comments

Comments
 (0)