天择加密量化开放框架下载
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3353 lines
178 KiB

1 year ago
  1. # coding: utf-8
  2. """
  3. Gate API v4
  4. Welcome to Gate.io API APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501
  5. Contact: support@mail.gate.io
  6. Generated by: https://openapi-generator.tech
  7. """
  8. from __future__ import absolute_import
  9. import re # noqa: F401
  10. # python 2 and python 3 compatibility library
  11. import six
  12. from gate_api.api_client import ApiClient
  13. from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401
  14. class SpotApi(object):
  15. """NOTE: This class is auto generated by OpenAPI Generator
  16. Ref: https://openapi-generator.tech
  17. Do not edit the class manually.
  18. """
  19. def __init__(self, api_client=None):
  20. if api_client is None:
  21. api_client = ApiClient()
  22. self.api_client = api_client
  23. def list_currencies(self, **kwargs): # noqa: E501
  24. """List all currencies' details # noqa: E501
  25. Currency has two forms: 1. Only currency name, e.g., BTC, USDT 2. `<currency>_<chain>`, e.g., `HT_ETH` The latter one occurs when one currency has multiple chains. Currency detail contains a `chain` field whatever the form is. To retrieve all chains of one currency, you can use use all the details which has the name of the currency or name starting with `<currency>_`. # noqa: E501
  26. This method makes a synchronous HTTP request by default. To make an
  27. asynchronous HTTP request, please pass async_req=True
  28. >>> thread = api.list_currencies(async_req=True)
  29. >>> result = thread.get()
  30. :param bool async_req: execute request asynchronously
  31. :param _preload_content: if False, the urllib3.HTTPResponse object will
  32. be returned without reading/decoding response
  33. data. Default is True.
  34. :param _request_timeout: timeout setting for this request. If one
  35. number provided, it will be total request
  36. timeout. It can also be a pair (tuple) of
  37. (connection, read) timeouts.
  38. :rtype: list[gate_api.Currency]
  39. :return: If the method is called asynchronously,
  40. returns the request thread.
  41. """
  42. kwargs['_return_http_data_only'] = True
  43. return self.list_currencies_with_http_info(**kwargs) # noqa: E501
  44. def list_currencies_with_http_info(self, **kwargs): # noqa: E501
  45. """List all currencies' details # noqa: E501
  46. Currency has two forms: 1. Only currency name, e.g., BTC, USDT 2. `<currency>_<chain>`, e.g., `HT_ETH` The latter one occurs when one currency has multiple chains. Currency detail contains a `chain` field whatever the form is. To retrieve all chains of one currency, you can use use all the details which has the name of the currency or name starting with `<currency>_`. # noqa: E501
  47. This method makes a synchronous HTTP request by default. To make an
  48. asynchronous HTTP request, please pass async_req=True
  49. >>> thread = api.list_currencies_with_http_info(async_req=True)
  50. >>> result = thread.get()
  51. :param bool async_req: execute request asynchronously
  52. :param _return_http_data_only: response data without head status code
  53. and headers
  54. :param _preload_content: if False, the urllib3.HTTPResponse object will
  55. be returned without reading/decoding response
  56. data. Default is True.
  57. :param _request_timeout: timeout setting for this request. If one
  58. number provided, it will be total request
  59. timeout. It can also be a pair (tuple) of
  60. (connection, read) timeouts.
  61. :rtype: tuple(list[gate_api.Currency], status_code(int), headers(HTTPHeaderDict))
  62. :return: If the method is called asynchronously,
  63. returns the request thread.
  64. """
  65. local_var_params = locals()
  66. all_params = []
  67. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  68. for k, v in six.iteritems(local_var_params['kwargs']):
  69. if k not in all_params:
  70. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_currencies" % k)
  71. local_var_params[k] = v
  72. del local_var_params['kwargs']
  73. collection_formats = {}
  74. path_params = {}
  75. query_params = []
  76. header_params = {}
  77. form_params = []
  78. local_var_files = {}
  79. body_params = None
  80. # HTTP header `Accept`
  81. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  82. # Authentication setting
  83. auth_settings = [] # noqa: E501
  84. return self.api_client.call_api(
  85. '/spot/currencies',
  86. 'GET',
  87. path_params,
  88. query_params,
  89. header_params,
  90. body=body_params,
  91. post_params=form_params,
  92. files=local_var_files,
  93. response_type='list[Currency]', # noqa: E501
  94. auth_settings=auth_settings,
  95. async_req=local_var_params.get('async_req'),
  96. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  97. _preload_content=local_var_params.get('_preload_content', True),
  98. _request_timeout=local_var_params.get('_request_timeout'),
  99. collection_formats=collection_formats,
  100. )
  101. def get_currency(self, currency, **kwargs): # noqa: E501
  102. """Get details of a specific currency # noqa: E501
  103. This method makes a synchronous HTTP request by default. To make an
  104. asynchronous HTTP request, please pass async_req=True
  105. >>> thread = api.get_currency(currency, async_req=True)
  106. >>> result = thread.get()
  107. :param bool async_req: execute request asynchronously
  108. :param str currency: Currency name (required)
  109. :param _preload_content: if False, the urllib3.HTTPResponse object will
  110. be returned without reading/decoding response
  111. data. Default is True.
  112. :param _request_timeout: timeout setting for this request. If one
  113. number provided, it will be total request
  114. timeout. It can also be a pair (tuple) of
  115. (connection, read) timeouts.
  116. :rtype: gate_api.Currency
  117. :return: If the method is called asynchronously,
  118. returns the request thread.
  119. """
  120. kwargs['_return_http_data_only'] = True
  121. return self.get_currency_with_http_info(currency, **kwargs) # noqa: E501
  122. def get_currency_with_http_info(self, currency, **kwargs): # noqa: E501
  123. """Get details of a specific currency # noqa: E501
  124. This method makes a synchronous HTTP request by default. To make an
  125. asynchronous HTTP request, please pass async_req=True
  126. >>> thread = api.get_currency_with_http_info(currency, async_req=True)
  127. >>> result = thread.get()
  128. :param bool async_req: execute request asynchronously
  129. :param str currency: Currency name (required)
  130. :param _return_http_data_only: response data without head status code
  131. and headers
  132. :param _preload_content: if False, the urllib3.HTTPResponse object will
  133. be returned without reading/decoding response
  134. data. Default is True.
  135. :param _request_timeout: timeout setting for this request. If one
  136. number provided, it will be total request
  137. timeout. It can also be a pair (tuple) of
  138. (connection, read) timeouts.
  139. :rtype: tuple(gate_api.Currency, status_code(int), headers(HTTPHeaderDict))
  140. :return: If the method is called asynchronously,
  141. returns the request thread.
  142. """
  143. local_var_params = locals()
  144. all_params = ['currency']
  145. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  146. for k, v in six.iteritems(local_var_params['kwargs']):
  147. if k not in all_params:
  148. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_currency" % k)
  149. local_var_params[k] = v
  150. del local_var_params['kwargs']
  151. # verify the required parameter 'currency' is set
  152. if self.api_client.client_side_validation and (
  153. 'currency' not in local_var_params or local_var_params['currency'] is None # noqa: E501
  154. ): # noqa: E501
  155. raise ApiValueError("Missing the required parameter `currency` when calling `get_currency`") # noqa: E501
  156. collection_formats = {}
  157. path_params = {}
  158. if 'currency' in local_var_params:
  159. path_params['currency'] = local_var_params['currency'] # noqa: E501
  160. query_params = []
  161. header_params = {}
  162. form_params = []
  163. local_var_files = {}
  164. body_params = None
  165. # HTTP header `Accept`
  166. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  167. # Authentication setting
  168. auth_settings = [] # noqa: E501
  169. return self.api_client.call_api(
  170. '/spot/currencies/{currency}',
  171. 'GET',
  172. path_params,
  173. query_params,
  174. header_params,
  175. body=body_params,
  176. post_params=form_params,
  177. files=local_var_files,
  178. response_type='Currency', # noqa: E501
  179. auth_settings=auth_settings,
  180. async_req=local_var_params.get('async_req'),
  181. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  182. _preload_content=local_var_params.get('_preload_content', True),
  183. _request_timeout=local_var_params.get('_request_timeout'),
  184. collection_formats=collection_formats,
  185. )
  186. def list_currency_pairs(self, **kwargs): # noqa: E501
  187. """List all currency pairs supported # noqa: E501
  188. This method makes a synchronous HTTP request by default. To make an
  189. asynchronous HTTP request, please pass async_req=True
  190. >>> thread = api.list_currency_pairs(async_req=True)
  191. >>> result = thread.get()
  192. :param bool async_req: execute request asynchronously
  193. :param _preload_content: if False, the urllib3.HTTPResponse object will
  194. be returned without reading/decoding response
  195. data. Default is True.
  196. :param _request_timeout: timeout setting for this request. If one
  197. number provided, it will be total request
  198. timeout. It can also be a pair (tuple) of
  199. (connection, read) timeouts.
  200. :rtype: list[gate_api.CurrencyPair]
  201. :return: If the method is called asynchronously,
  202. returns the request thread.
  203. """
  204. kwargs['_return_http_data_only'] = True
  205. return self.list_currency_pairs_with_http_info(**kwargs) # noqa: E501
  206. def list_currency_pairs_with_http_info(self, **kwargs): # noqa: E501
  207. """List all currency pairs supported # noqa: E501
  208. This method makes a synchronous HTTP request by default. To make an
  209. asynchronous HTTP request, please pass async_req=True
  210. >>> thread = api.list_currency_pairs_with_http_info(async_req=True)
  211. >>> result = thread.get()
  212. :param bool async_req: execute request asynchronously
  213. :param _return_http_data_only: response data without head status code
  214. and headers
  215. :param _preload_content: if False, the urllib3.HTTPResponse object will
  216. be returned without reading/decoding response
  217. data. Default is True.
  218. :param _request_timeout: timeout setting for this request. If one
  219. number provided, it will be total request
  220. timeout. It can also be a pair (tuple) of
  221. (connection, read) timeouts.
  222. :rtype: tuple(list[gate_api.CurrencyPair], status_code(int), headers(HTTPHeaderDict))
  223. :return: If the method is called asynchronously,
  224. returns the request thread.
  225. """
  226. local_var_params = locals()
  227. all_params = []
  228. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  229. for k, v in six.iteritems(local_var_params['kwargs']):
  230. if k not in all_params:
  231. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_currency_pairs" % k)
  232. local_var_params[k] = v
  233. del local_var_params['kwargs']
  234. collection_formats = {}
  235. path_params = {}
  236. query_params = []
  237. header_params = {}
  238. form_params = []
  239. local_var_files = {}
  240. body_params = None
  241. # HTTP header `Accept`
  242. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  243. # Authentication setting
  244. auth_settings = [] # noqa: E501
  245. return self.api_client.call_api(
  246. '/spot/currency_pairs',
  247. 'GET',
  248. path_params,
  249. query_params,
  250. header_params,
  251. body=body_params,
  252. post_params=form_params,
  253. files=local_var_files,
  254. response_type='list[CurrencyPair]', # noqa: E501
  255. auth_settings=auth_settings,
  256. async_req=local_var_params.get('async_req'),
  257. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  258. _preload_content=local_var_params.get('_preload_content', True),
  259. _request_timeout=local_var_params.get('_request_timeout'),
  260. collection_formats=collection_formats,
  261. )
  262. def get_currency_pair(self, currency_pair, **kwargs): # noqa: E501
  263. """Get details of a specifc currency pair # noqa: E501
  264. This method makes a synchronous HTTP request by default. To make an
  265. asynchronous HTTP request, please pass async_req=True
  266. >>> thread = api.get_currency_pair(currency_pair, async_req=True)
  267. >>> result = thread.get()
  268. :param bool async_req: execute request asynchronously
  269. :param str currency_pair: Currency pair (required)
  270. :param _preload_content: if False, the urllib3.HTTPResponse object will
  271. be returned without reading/decoding response
  272. data. Default is True.
  273. :param _request_timeout: timeout setting for this request. If one
  274. number provided, it will be total request
  275. timeout. It can also be a pair (tuple) of
  276. (connection, read) timeouts.
  277. :rtype: gate_api.CurrencyPair
  278. :return: If the method is called asynchronously,
  279. returns the request thread.
  280. """
  281. kwargs['_return_http_data_only'] = True
  282. return self.get_currency_pair_with_http_info(currency_pair, **kwargs) # noqa: E501
  283. def get_currency_pair_with_http_info(self, currency_pair, **kwargs): # noqa: E501
  284. """Get details of a specifc currency pair # noqa: E501
  285. This method makes a synchronous HTTP request by default. To make an
  286. asynchronous HTTP request, please pass async_req=True
  287. >>> thread = api.get_currency_pair_with_http_info(currency_pair, async_req=True)
  288. >>> result = thread.get()
  289. :param bool async_req: execute request asynchronously
  290. :param str currency_pair: Currency pair (required)
  291. :param _return_http_data_only: response data without head status code
  292. and headers
  293. :param _preload_content: if False, the urllib3.HTTPResponse object will
  294. be returned without reading/decoding response
  295. data. Default is True.
  296. :param _request_timeout: timeout setting for this request. If one
  297. number provided, it will be total request
  298. timeout. It can also be a pair (tuple) of
  299. (connection, read) timeouts.
  300. :rtype: tuple(gate_api.CurrencyPair, status_code(int), headers(HTTPHeaderDict))
  301. :return: If the method is called asynchronously,
  302. returns the request thread.
  303. """
  304. local_var_params = locals()
  305. all_params = ['currency_pair']
  306. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  307. for k, v in six.iteritems(local_var_params['kwargs']):
  308. if k not in all_params:
  309. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_currency_pair" % k)
  310. local_var_params[k] = v
  311. del local_var_params['kwargs']
  312. # verify the required parameter 'currency_pair' is set
  313. if self.api_client.client_side_validation and (
  314. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  315. ): # noqa: E501
  316. raise ApiValueError(
  317. "Missing the required parameter `currency_pair` when calling `get_currency_pair`"
  318. ) # noqa: E501
  319. collection_formats = {}
  320. path_params = {}
  321. if 'currency_pair' in local_var_params:
  322. path_params['currency_pair'] = local_var_params['currency_pair'] # noqa: E501
  323. query_params = []
  324. header_params = {}
  325. form_params = []
  326. local_var_files = {}
  327. body_params = None
  328. # HTTP header `Accept`
  329. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  330. # Authentication setting
  331. auth_settings = [] # noqa: E501
  332. return self.api_client.call_api(
  333. '/spot/currency_pairs/{currency_pair}',
  334. 'GET',
  335. path_params,
  336. query_params,
  337. header_params,
  338. body=body_params,
  339. post_params=form_params,
  340. files=local_var_files,
  341. response_type='CurrencyPair', # noqa: E501
  342. auth_settings=auth_settings,
  343. async_req=local_var_params.get('async_req'),
  344. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  345. _preload_content=local_var_params.get('_preload_content', True),
  346. _request_timeout=local_var_params.get('_request_timeout'),
  347. collection_formats=collection_formats,
  348. )
  349. def list_tickers(self, **kwargs): # noqa: E501
  350. """Retrieve ticker information # noqa: E501
  351. Return only related data if `currency_pair` is specified; otherwise return all of them # noqa: E501
  352. This method makes a synchronous HTTP request by default. To make an
  353. asynchronous HTTP request, please pass async_req=True
  354. >>> thread = api.list_tickers(async_req=True)
  355. >>> result = thread.get()
  356. :param bool async_req: execute request asynchronously
  357. :param str currency_pair: Currency pair
  358. :param str timezone: Timezone
  359. :param _preload_content: if False, the urllib3.HTTPResponse object will
  360. be returned without reading/decoding response
  361. data. Default is True.
  362. :param _request_timeout: timeout setting for this request. If one
  363. number provided, it will be total request
  364. timeout. It can also be a pair (tuple) of
  365. (connection, read) timeouts.
  366. :rtype: list[gate_api.Ticker]
  367. :return: If the method is called asynchronously,
  368. returns the request thread.
  369. """
  370. kwargs['_return_http_data_only'] = True
  371. return self.list_tickers_with_http_info(**kwargs) # noqa: E501
  372. def list_tickers_with_http_info(self, **kwargs): # noqa: E501
  373. """Retrieve ticker information # noqa: E501
  374. Return only related data if `currency_pair` is specified; otherwise return all of them # noqa: E501
  375. This method makes a synchronous HTTP request by default. To make an
  376. asynchronous HTTP request, please pass async_req=True
  377. >>> thread = api.list_tickers_with_http_info(async_req=True)
  378. >>> result = thread.get()
  379. :param bool async_req: execute request asynchronously
  380. :param str currency_pair: Currency pair
  381. :param str timezone: Timezone
  382. :param _return_http_data_only: response data without head status code
  383. and headers
  384. :param _preload_content: if False, the urllib3.HTTPResponse object will
  385. be returned without reading/decoding response
  386. data. Default is True.
  387. :param _request_timeout: timeout setting for this request. If one
  388. number provided, it will be total request
  389. timeout. It can also be a pair (tuple) of
  390. (connection, read) timeouts.
  391. :rtype: tuple(list[gate_api.Ticker], status_code(int), headers(HTTPHeaderDict))
  392. :return: If the method is called asynchronously,
  393. returns the request thread.
  394. """
  395. local_var_params = locals()
  396. all_params = ['currency_pair', 'timezone']
  397. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  398. for k, v in six.iteritems(local_var_params['kwargs']):
  399. if k not in all_params:
  400. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_tickers" % k)
  401. local_var_params[k] = v
  402. del local_var_params['kwargs']
  403. collection_formats = {}
  404. path_params = {}
  405. query_params = []
  406. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  407. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  408. if 'timezone' in local_var_params and local_var_params['timezone'] is not None: # noqa: E501
  409. query_params.append(('timezone', local_var_params['timezone'])) # noqa: E501
  410. header_params = {}
  411. form_params = []
  412. local_var_files = {}
  413. body_params = None
  414. # HTTP header `Accept`
  415. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  416. # Authentication setting
  417. auth_settings = [] # noqa: E501
  418. return self.api_client.call_api(
  419. '/spot/tickers',
  420. 'GET',
  421. path_params,
  422. query_params,
  423. header_params,
  424. body=body_params,
  425. post_params=form_params,
  426. files=local_var_files,
  427. response_type='list[Ticker]', # noqa: E501
  428. auth_settings=auth_settings,
  429. async_req=local_var_params.get('async_req'),
  430. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  431. _preload_content=local_var_params.get('_preload_content', True),
  432. _request_timeout=local_var_params.get('_request_timeout'),
  433. collection_formats=collection_formats,
  434. )
  435. def list_order_book(self, currency_pair, **kwargs): # noqa: E501
  436. """Retrieve order book # noqa: E501
  437. Order book will be sorted by price from high to low on bids; low to high on asks # noqa: E501
  438. This method makes a synchronous HTTP request by default. To make an
  439. asynchronous HTTP request, please pass async_req=True
  440. >>> thread = api.list_order_book(currency_pair, async_req=True)
  441. >>> result = thread.get()
  442. :param bool async_req: execute request asynchronously
  443. :param str currency_pair: Currency pair (required)
  444. :param str interval: Order depth. 0 means no aggregation is applied. default to 0
  445. :param int limit: Maximum number of order depth data in asks or bids
  446. :param bool with_id: Return order book ID
  447. :param _preload_content: if False, the urllib3.HTTPResponse object will
  448. be returned without reading/decoding response
  449. data. Default is True.
  450. :param _request_timeout: timeout setting for this request. If one
  451. number provided, it will be total request
  452. timeout. It can also be a pair (tuple) of
  453. (connection, read) timeouts.
  454. :rtype: gate_api.OrderBook
  455. :return: If the method is called asynchronously,
  456. returns the request thread.
  457. """
  458. kwargs['_return_http_data_only'] = True
  459. return self.list_order_book_with_http_info(currency_pair, **kwargs) # noqa: E501
  460. def list_order_book_with_http_info(self, currency_pair, **kwargs): # noqa: E501
  461. """Retrieve order book # noqa: E501
  462. Order book will be sorted by price from high to low on bids; low to high on asks # noqa: E501
  463. This method makes a synchronous HTTP request by default. To make an
  464. asynchronous HTTP request, please pass async_req=True
  465. >>> thread = api.list_order_book_with_http_info(currency_pair, async_req=True)
  466. >>> result = thread.get()
  467. :param bool async_req: execute request asynchronously
  468. :param str currency_pair: Currency pair (required)
  469. :param str interval: Order depth. 0 means no aggregation is applied. default to 0
  470. :param int limit: Maximum number of order depth data in asks or bids
  471. :param bool with_id: Return order book ID
  472. :param _return_http_data_only: response data without head status code
  473. and headers
  474. :param _preload_content: if False, the urllib3.HTTPResponse object will
  475. be returned without reading/decoding response
  476. data. Default is True.
  477. :param _request_timeout: timeout setting for this request. If one
  478. number provided, it will be total request
  479. timeout. It can also be a pair (tuple) of
  480. (connection, read) timeouts.
  481. :rtype: tuple(gate_api.OrderBook, status_code(int), headers(HTTPHeaderDict))
  482. :return: If the method is called asynchronously,
  483. returns the request thread.
  484. """
  485. local_var_params = locals()
  486. all_params = ['currency_pair', 'interval', 'limit', 'with_id']
  487. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  488. for k, v in six.iteritems(local_var_params['kwargs']):
  489. if k not in all_params:
  490. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_order_book" % k)
  491. local_var_params[k] = v
  492. del local_var_params['kwargs']
  493. # verify the required parameter 'currency_pair' is set
  494. if self.api_client.client_side_validation and (
  495. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  496. ): # noqa: E501
  497. raise ApiValueError(
  498. "Missing the required parameter `currency_pair` when calling `list_order_book`"
  499. ) # noqa: E501
  500. if (
  501. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  502. ): # noqa: E501
  503. raise ApiValueError(
  504. "Invalid value for parameter `limit` when calling `list_order_book`, must be a value greater than or equal to `1`"
  505. ) # noqa: E501
  506. collection_formats = {}
  507. path_params = {}
  508. query_params = []
  509. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  510. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  511. if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501
  512. query_params.append(('interval', local_var_params['interval'])) # noqa: E501
  513. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  514. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  515. if 'with_id' in local_var_params and local_var_params['with_id'] is not None: # noqa: E501
  516. query_params.append(('with_id', local_var_params['with_id'])) # noqa: E501
  517. header_params = {}
  518. form_params = []
  519. local_var_files = {}
  520. body_params = None
  521. # HTTP header `Accept`
  522. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  523. # Authentication setting
  524. auth_settings = [] # noqa: E501
  525. return self.api_client.call_api(
  526. '/spot/order_book',
  527. 'GET',
  528. path_params,
  529. query_params,
  530. header_params,
  531. body=body_params,
  532. post_params=form_params,
  533. files=local_var_files,
  534. response_type='OrderBook', # noqa: E501
  535. auth_settings=auth_settings,
  536. async_req=local_var_params.get('async_req'),
  537. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  538. _preload_content=local_var_params.get('_preload_content', True),
  539. _request_timeout=local_var_params.get('_request_timeout'),
  540. collection_formats=collection_formats,
  541. )
  542. def list_trades(self, currency_pair, **kwargs): # noqa: E501
  543. """Retrieve market trades # noqa: E501
  544. You can use `from` and `to` to query by time range, or use `last_id` by scrolling page. The default behavior is by time range. Scrolling query using `last_id` is not recommended any more. If `last_id` is specified, time range query parameters will be ignored. # noqa: E501
  545. This method makes a synchronous HTTP request by default. To make an
  546. asynchronous HTTP request, please pass async_req=True
  547. >>> thread = api.list_trades(currency_pair, async_req=True)
  548. >>> result = thread.get()
  549. :param bool async_req: execute request asynchronously
  550. :param str currency_pair: Currency pair (required)
  551. :param int limit: Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000
  552. :param str last_id: Specify list staring point using the `id` of last record in previous list-query results
  553. :param bool reverse: Whether the id of records to be retrieved should be less than the last_id specified. Default to false. When `last_id` is specified. Set `reverse` to `true` to trace back trading history; `false` to retrieve latest tradings. No effect if `last_id` is not specified.
  554. :param int _from: Start timestamp of the query
  555. :param int to: Time range ending, default to current time
  556. :param int page: Page number
  557. :param _preload_content: if False, the urllib3.HTTPResponse object will
  558. be returned without reading/decoding response
  559. data. Default is True.
  560. :param _request_timeout: timeout setting for this request. If one
  561. number provided, it will be total request
  562. timeout. It can also be a pair (tuple) of
  563. (connection, read) timeouts.
  564. :rtype: list[gate_api.Trade]
  565. :return: If the method is called asynchronously,
  566. returns the request thread.
  567. """
  568. kwargs['_return_http_data_only'] = True
  569. return self.list_trades_with_http_info(currency_pair, **kwargs) # noqa: E501
  570. def list_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501
  571. """Retrieve market trades # noqa: E501
  572. You can use `from` and `to` to query by time range, or use `last_id` by scrolling page. The default behavior is by time range. Scrolling query using `last_id` is not recommended any more. If `last_id` is specified, time range query parameters will be ignored. # noqa: E501
  573. This method makes a synchronous HTTP request by default. To make an
  574. asynchronous HTTP request, please pass async_req=True
  575. >>> thread = api.list_trades_with_http_info(currency_pair, async_req=True)
  576. >>> result = thread.get()
  577. :param bool async_req: execute request asynchronously
  578. :param str currency_pair: Currency pair (required)
  579. :param int limit: Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000
  580. :param str last_id: Specify list staring point using the `id` of last record in previous list-query results
  581. :param bool reverse: Whether the id of records to be retrieved should be less than the last_id specified. Default to false. When `last_id` is specified. Set `reverse` to `true` to trace back trading history; `false` to retrieve latest tradings. No effect if `last_id` is not specified.
  582. :param int _from: Start timestamp of the query
  583. :param int to: Time range ending, default to current time
  584. :param int page: Page number
  585. :param _return_http_data_only: response data without head status code
  586. and headers
  587. :param _preload_content: if False, the urllib3.HTTPResponse object will
  588. be returned without reading/decoding response
  589. data. Default is True.
  590. :param _request_timeout: timeout setting for this request. If one
  591. number provided, it will be total request
  592. timeout. It can also be a pair (tuple) of
  593. (connection, read) timeouts.
  594. :rtype: tuple(list[gate_api.Trade], status_code(int), headers(HTTPHeaderDict))
  595. :return: If the method is called asynchronously,
  596. returns the request thread.
  597. """
  598. local_var_params = locals()
  599. all_params = ['currency_pair', 'limit', 'last_id', 'reverse', '_from', 'to', 'page']
  600. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  601. for k, v in six.iteritems(local_var_params['kwargs']):
  602. if k not in all_params:
  603. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_trades" % k)
  604. local_var_params[k] = v
  605. del local_var_params['kwargs']
  606. # verify the required parameter 'currency_pair' is set
  607. if self.api_client.client_side_validation and (
  608. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  609. ): # noqa: E501
  610. raise ApiValueError(
  611. "Missing the required parameter `currency_pair` when calling `list_trades`"
  612. ) # noqa: E501
  613. if (
  614. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  615. ): # noqa: E501
  616. raise ApiValueError(
  617. "Invalid value for parameter `limit` when calling `list_trades`, must be a value less than or equal to `1000`"
  618. ) # noqa: E501
  619. if (
  620. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  621. ): # noqa: E501
  622. raise ApiValueError(
  623. "Invalid value for parameter `limit` when calling `list_trades`, must be a value greater than or equal to `1`"
  624. ) # noqa: E501
  625. if (
  626. self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1
  627. ): # noqa: E501
  628. raise ApiValueError(
  629. "Invalid value for parameter `page` when calling `list_trades`, must be a value greater than or equal to `1`"
  630. ) # noqa: E501
  631. collection_formats = {}
  632. path_params = {}
  633. query_params = []
  634. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  635. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  636. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  637. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  638. if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501
  639. query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501
  640. if 'reverse' in local_var_params and local_var_params['reverse'] is not None: # noqa: E501
  641. query_params.append(('reverse', local_var_params['reverse'])) # noqa: E501
  642. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  643. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  644. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  645. query_params.append(('to', local_var_params['to'])) # noqa: E501
  646. if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501
  647. query_params.append(('page', local_var_params['page'])) # noqa: E501
  648. header_params = {}
  649. form_params = []
  650. local_var_files = {}
  651. body_params = None
  652. # HTTP header `Accept`
  653. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  654. # Authentication setting
  655. auth_settings = [] # noqa: E501
  656. return self.api_client.call_api(
  657. '/spot/trades',
  658. 'GET',
  659. path_params,
  660. query_params,
  661. header_params,
  662. body=body_params,
  663. post_params=form_params,
  664. files=local_var_files,
  665. response_type='list[Trade]', # noqa: E501
  666. auth_settings=auth_settings,
  667. async_req=local_var_params.get('async_req'),
  668. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  669. _preload_content=local_var_params.get('_preload_content', True),
  670. _request_timeout=local_var_params.get('_request_timeout'),
  671. collection_formats=collection_formats,
  672. )
  673. def list_candlesticks(self, currency_pair, **kwargs): # noqa: E501
  674. """Market candlesticks # noqa: E501
  675. Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval # noqa: E501
  676. This method makes a synchronous HTTP request by default. To make an
  677. asynchronous HTTP request, please pass async_req=True
  678. >>> thread = api.list_candlesticks(currency_pair, async_req=True)
  679. >>> result = thread.get()
  680. :param bool async_req: execute request asynchronously
  681. :param str currency_pair: Currency pair (required)
  682. :param int limit: Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  683. :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  684. :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  685. :param str interval: Interval time between data points. Note that `30d` means 1 natual month, not 30 days
  686. :param _preload_content: if False, the urllib3.HTTPResponse object will
  687. be returned without reading/decoding response
  688. data. Default is True.
  689. :param _request_timeout: timeout setting for this request. If one
  690. number provided, it will be total request
  691. timeout. It can also be a pair (tuple) of
  692. (connection, read) timeouts.
  693. :rtype: list[list[str]]
  694. :return: If the method is called asynchronously,
  695. returns the request thread.
  696. """
  697. kwargs['_return_http_data_only'] = True
  698. return self.list_candlesticks_with_http_info(currency_pair, **kwargs) # noqa: E501
  699. def list_candlesticks_with_http_info(self, currency_pair, **kwargs): # noqa: E501
  700. """Market candlesticks # noqa: E501
  701. Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval # noqa: E501
  702. This method makes a synchronous HTTP request by default. To make an
  703. asynchronous HTTP request, please pass async_req=True
  704. >>> thread = api.list_candlesticks_with_http_info(currency_pair, async_req=True)
  705. >>> result = thread.get()
  706. :param bool async_req: execute request asynchronously
  707. :param str currency_pair: Currency pair (required)
  708. :param int limit: Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  709. :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  710. :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  711. :param str interval: Interval time between data points. Note that `30d` means 1 natual month, not 30 days
  712. :param _return_http_data_only: response data without head status code
  713. and headers
  714. :param _preload_content: if False, the urllib3.HTTPResponse object will
  715. be returned without reading/decoding response
  716. data. Default is True.
  717. :param _request_timeout: timeout setting for this request. If one
  718. number provided, it will be total request
  719. timeout. It can also be a pair (tuple) of
  720. (connection, read) timeouts.
  721. :rtype: tuple(list[list[str]], status_code(int), headers(HTTPHeaderDict))
  722. :return: If the method is called asynchronously,
  723. returns the request thread.
  724. """
  725. local_var_params = locals()
  726. all_params = ['currency_pair', 'limit', '_from', 'to', 'interval']
  727. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  728. for k, v in six.iteritems(local_var_params['kwargs']):
  729. if k not in all_params:
  730. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_candlesticks" % k)
  731. local_var_params[k] = v
  732. del local_var_params['kwargs']
  733. # verify the required parameter 'currency_pair' is set
  734. if self.api_client.client_side_validation and (
  735. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  736. ): # noqa: E501
  737. raise ApiValueError(
  738. "Missing the required parameter `currency_pair` when calling `list_candlesticks`"
  739. ) # noqa: E501
  740. if (
  741. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  742. ): # noqa: E501
  743. raise ApiValueError(
  744. "Invalid value for parameter `limit` when calling `list_candlesticks`, must be a value less than or equal to `1000`"
  745. ) # noqa: E501
  746. collection_formats = {}
  747. path_params = {}
  748. query_params = []
  749. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  750. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  751. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  752. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  753. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  754. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  755. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  756. query_params.append(('to', local_var_params['to'])) # noqa: E501
  757. if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501
  758. query_params.append(('interval', local_var_params['interval'])) # noqa: E501
  759. header_params = {}
  760. form_params = []
  761. local_var_files = {}
  762. body_params = None
  763. # HTTP header `Accept`
  764. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  765. # Authentication setting
  766. auth_settings = [] # noqa: E501
  767. return self.api_client.call_api(
  768. '/spot/candlesticks',
  769. 'GET',
  770. path_params,
  771. query_params,
  772. header_params,
  773. body=body_params,
  774. post_params=form_params,
  775. files=local_var_files,
  776. response_type='list[list[str]]', # noqa: E501
  777. auth_settings=auth_settings,
  778. async_req=local_var_params.get('async_req'),
  779. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  780. _preload_content=local_var_params.get('_preload_content', True),
  781. _request_timeout=local_var_params.get('_request_timeout'),
  782. collection_formats=collection_formats,
  783. )
  784. def get_fee(self, **kwargs): # noqa: E501
  785. """Query user trading fee rates # noqa: E501
  786. This API is deprecated in favour of new fee retrieving API `/wallet/fee`. # noqa: E501
  787. This method makes a synchronous HTTP request by default. To make an
  788. asynchronous HTTP request, please pass async_req=True
  789. >>> thread = api.get_fee(async_req=True)
  790. >>> result = thread.get()
  791. :param bool async_req: execute request asynchronously
  792. :param str currency_pair: Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs
  793. :param _preload_content: if False, the urllib3.HTTPResponse object will
  794. be returned without reading/decoding response
  795. data. Default is True.
  796. :param _request_timeout: timeout setting for this request. If one
  797. number provided, it will be total request
  798. timeout. It can also be a pair (tuple) of
  799. (connection, read) timeouts.
  800. :rtype: gate_api.TradeFee
  801. :return: If the method is called asynchronously,
  802. returns the request thread.
  803. """
  804. kwargs['_return_http_data_only'] = True
  805. return self.get_fee_with_http_info(**kwargs) # noqa: E501
  806. def get_fee_with_http_info(self, **kwargs): # noqa: E501
  807. """Query user trading fee rates # noqa: E501
  808. This API is deprecated in favour of new fee retrieving API `/wallet/fee`. # noqa: E501
  809. This method makes a synchronous HTTP request by default. To make an
  810. asynchronous HTTP request, please pass async_req=True
  811. >>> thread = api.get_fee_with_http_info(async_req=True)
  812. >>> result = thread.get()
  813. :param bool async_req: execute request asynchronously
  814. :param str currency_pair: Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs
  815. :param _return_http_data_only: response data without head status code
  816. and headers
  817. :param _preload_content: if False, the urllib3.HTTPResponse object will
  818. be returned without reading/decoding response
  819. data. Default is True.
  820. :param _request_timeout: timeout setting for this request. If one
  821. number provided, it will be total request
  822. timeout. It can also be a pair (tuple) of
  823. (connection, read) timeouts.
  824. :rtype: tuple(gate_api.TradeFee, status_code(int), headers(HTTPHeaderDict))
  825. :return: If the method is called asynchronously,
  826. returns the request thread.
  827. """
  828. local_var_params = locals()
  829. all_params = ['currency_pair']
  830. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  831. for k, v in six.iteritems(local_var_params['kwargs']):
  832. if k not in all_params:
  833. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_fee" % k)
  834. local_var_params[k] = v
  835. del local_var_params['kwargs']
  836. collection_formats = {}
  837. path_params = {}
  838. query_params = []
  839. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  840. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  841. header_params = {}
  842. form_params = []
  843. local_var_files = {}
  844. body_params = None
  845. # HTTP header `Accept`
  846. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  847. # Authentication setting
  848. auth_settings = ['apiv4'] # noqa: E501
  849. return self.api_client.call_api(
  850. '/spot/fee',
  851. 'GET',
  852. path_params,
  853. query_params,
  854. header_params,
  855. body=body_params,
  856. post_params=form_params,
  857. files=local_var_files,
  858. response_type='TradeFee', # noqa: E501
  859. auth_settings=auth_settings,
  860. async_req=local_var_params.get('async_req'),
  861. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  862. _preload_content=local_var_params.get('_preload_content', True),
  863. _request_timeout=local_var_params.get('_request_timeout'),
  864. collection_formats=collection_formats,
  865. )
  866. def get_batch_spot_fee(self, currency_pairs, **kwargs): # noqa: E501
  867. """Query a batch of user trading fee rates # noqa: E501
  868. This method makes a synchronous HTTP request by default. To make an
  869. asynchronous HTTP request, please pass async_req=True
  870. >>> thread = api.get_batch_spot_fee(currency_pairs, async_req=True)
  871. >>> result = thread.get()
  872. :param bool async_req: execute request asynchronously
  873. :param str currency_pairs: A request can only query up to 50 currency pairs (required)
  874. :param _preload_content: if False, the urllib3.HTTPResponse object will
  875. be returned without reading/decoding response
  876. data. Default is True.
  877. :param _request_timeout: timeout setting for this request. If one
  878. number provided, it will be total request
  879. timeout. It can also be a pair (tuple) of
  880. (connection, read) timeouts.
  881. :rtype: dict(str, gate_api.SpotFee)
  882. :return: If the method is called asynchronously,
  883. returns the request thread.
  884. """
  885. kwargs['_return_http_data_only'] = True
  886. return self.get_batch_spot_fee_with_http_info(currency_pairs, **kwargs) # noqa: E501
  887. def get_batch_spot_fee_with_http_info(self, currency_pairs, **kwargs): # noqa: E501
  888. """Query a batch of user trading fee rates # noqa: E501
  889. This method makes a synchronous HTTP request by default. To make an
  890. asynchronous HTTP request, please pass async_req=True
  891. >>> thread = api.get_batch_spot_fee_with_http_info(currency_pairs, async_req=True)
  892. >>> result = thread.get()
  893. :param bool async_req: execute request asynchronously
  894. :param str currency_pairs: A request can only query up to 50 currency pairs (required)
  895. :param _return_http_data_only: response data without head status code
  896. and headers
  897. :param _preload_content: if False, the urllib3.HTTPResponse object will
  898. be returned without reading/decoding response
  899. data. Default is True.
  900. :param _request_timeout: timeout setting for this request. If one
  901. number provided, it will be total request
  902. timeout. It can also be a pair (tuple) of
  903. (connection, read) timeouts.
  904. :rtype: tuple(dict(str, gate_api.SpotFee), status_code(int), headers(HTTPHeaderDict))
  905. :return: If the method is called asynchronously,
  906. returns the request thread.
  907. """
  908. local_var_params = locals()
  909. all_params = ['currency_pairs']
  910. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  911. for k, v in six.iteritems(local_var_params['kwargs']):
  912. if k not in all_params:
  913. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_batch_spot_fee" % k)
  914. local_var_params[k] = v
  915. del local_var_params['kwargs']
  916. # verify the required parameter 'currency_pairs' is set
  917. if self.api_client.client_side_validation and (
  918. 'currency_pairs' not in local_var_params or local_var_params['currency_pairs'] is None # noqa: E501
  919. ): # noqa: E501
  920. raise ApiValueError(
  921. "Missing the required parameter `currency_pairs` when calling `get_batch_spot_fee`"
  922. ) # noqa: E501
  923. collection_formats = {}
  924. path_params = {}
  925. query_params = []
  926. if 'currency_pairs' in local_var_params and local_var_params['currency_pairs'] is not None: # noqa: E501
  927. query_params.append(('currency_pairs', local_var_params['currency_pairs'])) # noqa: E501
  928. header_params = {}
  929. form_params = []
  930. local_var_files = {}
  931. body_params = None
  932. # HTTP header `Accept`
  933. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  934. # Authentication setting
  935. auth_settings = ['apiv4'] # noqa: E501
  936. return self.api_client.call_api(
  937. '/spot/batch_fee',
  938. 'GET',
  939. path_params,
  940. query_params,
  941. header_params,
  942. body=body_params,
  943. post_params=form_params,
  944. files=local_var_files,
  945. response_type='dict(str, SpotFee)', # noqa: E501
  946. auth_settings=auth_settings,
  947. async_req=local_var_params.get('async_req'),
  948. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  949. _preload_content=local_var_params.get('_preload_content', True),
  950. _request_timeout=local_var_params.get('_request_timeout'),
  951. collection_formats=collection_formats,
  952. )
  953. def list_spot_accounts(self, **kwargs): # noqa: E501
  954. """List spot accounts # noqa: E501
  955. This method makes a synchronous HTTP request by default. To make an
  956. asynchronous HTTP request, please pass async_req=True
  957. >>> thread = api.list_spot_accounts(async_req=True)
  958. >>> result = thread.get()
  959. :param bool async_req: execute request asynchronously
  960. :param str currency: Retrieve data of the specified currency
  961. :param _preload_content: if False, the urllib3.HTTPResponse object will
  962. be returned without reading/decoding response
  963. data. Default is True.
  964. :param _request_timeout: timeout setting for this request. If one
  965. number provided, it will be total request
  966. timeout. It can also be a pair (tuple) of
  967. (connection, read) timeouts.
  968. :rtype: list[gate_api.SpotAccount]
  969. :return: If the method is called asynchronously,
  970. returns the request thread.
  971. """
  972. kwargs['_return_http_data_only'] = True
  973. return self.list_spot_accounts_with_http_info(**kwargs) # noqa: E501
  974. def list_spot_accounts_with_http_info(self, **kwargs): # noqa: E501
  975. """List spot accounts # noqa: E501
  976. This method makes a synchronous HTTP request by default. To make an
  977. asynchronous HTTP request, please pass async_req=True
  978. >>> thread = api.list_spot_accounts_with_http_info(async_req=True)
  979. >>> result = thread.get()
  980. :param bool async_req: execute request asynchronously
  981. :param str currency: Retrieve data of the specified currency
  982. :param _return_http_data_only: response data without head status code
  983. and headers
  984. :param _preload_content: if False, the urllib3.HTTPResponse object will
  985. be returned without reading/decoding response
  986. data. Default is True.
  987. :param _request_timeout: timeout setting for this request. If one
  988. number provided, it will be total request
  989. timeout. It can also be a pair (tuple) of
  990. (connection, read) timeouts.
  991. :rtype: tuple(list[gate_api.SpotAccount], status_code(int), headers(HTTPHeaderDict))
  992. :return: If the method is called asynchronously,
  993. returns the request thread.
  994. """
  995. local_var_params = locals()
  996. all_params = ['currency']
  997. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  998. for k, v in six.iteritems(local_var_params['kwargs']):
  999. if k not in all_params:
  1000. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_spot_accounts" % k)
  1001. local_var_params[k] = v
  1002. del local_var_params['kwargs']
  1003. collection_formats = {}
  1004. path_params = {}
  1005. query_params = []
  1006. if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501
  1007. query_params.append(('currency', local_var_params['currency'])) # noqa: E501
  1008. header_params = {}
  1009. form_params = []
  1010. local_var_files = {}
  1011. body_params = None
  1012. # HTTP header `Accept`
  1013. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1014. # Authentication setting
  1015. auth_settings = ['apiv4'] # noqa: E501
  1016. return self.api_client.call_api(
  1017. '/spot/accounts',
  1018. 'GET',
  1019. path_params,
  1020. query_params,
  1021. header_params,
  1022. body=body_params,
  1023. post_params=form_params,
  1024. files=local_var_files,
  1025. response_type='list[SpotAccount]', # noqa: E501
  1026. auth_settings=auth_settings,
  1027. async_req=local_var_params.get('async_req'),
  1028. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1029. _preload_content=local_var_params.get('_preload_content', True),
  1030. _request_timeout=local_var_params.get('_request_timeout'),
  1031. collection_formats=collection_formats,
  1032. )
  1033. def create_batch_orders(self, order, **kwargs): # noqa: E501
  1034. """Create a batch of orders # noqa: E501
  1035. Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 10 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders # noqa: E501
  1036. This method makes a synchronous HTTP request by default. To make an
  1037. asynchronous HTTP request, please pass async_req=True
  1038. >>> thread = api.create_batch_orders(order, async_req=True)
  1039. >>> result = thread.get()
  1040. :param bool async_req: execute request asynchronously
  1041. :param list[Order] order: (required)
  1042. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1043. be returned without reading/decoding response
  1044. data. Default is True.
  1045. :param _request_timeout: timeout setting for this request. If one
  1046. number provided, it will be total request
  1047. timeout. It can also be a pair (tuple) of
  1048. (connection, read) timeouts.
  1049. :rtype: list[gate_api.BatchOrder]
  1050. :return: If the method is called asynchronously,
  1051. returns the request thread.
  1052. """
  1053. kwargs['_return_http_data_only'] = True
  1054. return self.create_batch_orders_with_http_info(order, **kwargs) # noqa: E501
  1055. def create_batch_orders_with_http_info(self, order, **kwargs): # noqa: E501
  1056. """Create a batch of orders # noqa: E501
  1057. Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 10 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders # noqa: E501
  1058. This method makes a synchronous HTTP request by default. To make an
  1059. asynchronous HTTP request, please pass async_req=True
  1060. >>> thread = api.create_batch_orders_with_http_info(order, async_req=True)
  1061. >>> result = thread.get()
  1062. :param bool async_req: execute request asynchronously
  1063. :param list[Order] order: (required)
  1064. :param _return_http_data_only: response data without head status code
  1065. and headers
  1066. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1067. be returned without reading/decoding response
  1068. data. Default is True.
  1069. :param _request_timeout: timeout setting for this request. If one
  1070. number provided, it will be total request
  1071. timeout. It can also be a pair (tuple) of
  1072. (connection, read) timeouts.
  1073. :rtype: tuple(list[gate_api.BatchOrder], status_code(int), headers(HTTPHeaderDict))
  1074. :return: If the method is called asynchronously,
  1075. returns the request thread.
  1076. """
  1077. local_var_params = locals()
  1078. all_params = ['order']
  1079. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1080. for k, v in six.iteritems(local_var_params['kwargs']):
  1081. if k not in all_params:
  1082. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_batch_orders" % k)
  1083. local_var_params[k] = v
  1084. del local_var_params['kwargs']
  1085. # verify the required parameter 'order' is set
  1086. if self.api_client.client_side_validation and (
  1087. 'order' not in local_var_params or local_var_params['order'] is None # noqa: E501
  1088. ): # noqa: E501
  1089. raise ApiValueError(
  1090. "Missing the required parameter `order` when calling `create_batch_orders`"
  1091. ) # noqa: E501
  1092. collection_formats = {}
  1093. path_params = {}
  1094. query_params = []
  1095. header_params = {}
  1096. form_params = []
  1097. local_var_files = {}
  1098. body_params = None
  1099. if 'order' in local_var_params:
  1100. body_params = local_var_params['order']
  1101. # HTTP header `Accept`
  1102. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1103. # HTTP header `Content-Type`
  1104. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  1105. ['application/json']
  1106. ) # noqa: E501
  1107. # Authentication setting
  1108. auth_settings = ['apiv4'] # noqa: E501
  1109. return self.api_client.call_api(
  1110. '/spot/batch_orders',
  1111. 'POST',
  1112. path_params,
  1113. query_params,
  1114. header_params,
  1115. body=body_params,
  1116. post_params=form_params,
  1117. files=local_var_files,
  1118. response_type='list[BatchOrder]', # noqa: E501
  1119. auth_settings=auth_settings,
  1120. async_req=local_var_params.get('async_req'),
  1121. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1122. _preload_content=local_var_params.get('_preload_content', True),
  1123. _request_timeout=local_var_params.get('_request_timeout'),
  1124. collection_formats=collection_formats,
  1125. )
  1126. def list_all_open_orders(self, **kwargs): # noqa: E501
  1127. """List all open orders # noqa: E501
  1128. List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned. Spot and margin orders are returned by default. To list cross margin orders, `account` must be set to `cross_margin` # noqa: E501
  1129. This method makes a synchronous HTTP request by default. To make an
  1130. asynchronous HTTP request, please pass async_req=True
  1131. >>> thread = api.list_all_open_orders(async_req=True)
  1132. >>> result = thread.get()
  1133. :param bool async_req: execute request asynchronously
  1134. :param int page: Page number
  1135. :param int limit: Maximum number of records returned in one page in each currency pair
  1136. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1137. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1138. be returned without reading/decoding response
  1139. data. Default is True.
  1140. :param _request_timeout: timeout setting for this request. If one
  1141. number provided, it will be total request
  1142. timeout. It can also be a pair (tuple) of
  1143. (connection, read) timeouts.
  1144. :rtype: list[gate_api.OpenOrders]
  1145. :return: If the method is called asynchronously,
  1146. returns the request thread.
  1147. """
  1148. kwargs['_return_http_data_only'] = True
  1149. return self.list_all_open_orders_with_http_info(**kwargs) # noqa: E501
  1150. def list_all_open_orders_with_http_info(self, **kwargs): # noqa: E501
  1151. """List all open orders # noqa: E501
  1152. List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned. Spot and margin orders are returned by default. To list cross margin orders, `account` must be set to `cross_margin` # noqa: E501
  1153. This method makes a synchronous HTTP request by default. To make an
  1154. asynchronous HTTP request, please pass async_req=True
  1155. >>> thread = api.list_all_open_orders_with_http_info(async_req=True)
  1156. >>> result = thread.get()
  1157. :param bool async_req: execute request asynchronously
  1158. :param int page: Page number
  1159. :param int limit: Maximum number of records returned in one page in each currency pair
  1160. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1161. :param _return_http_data_only: response data without head status code
  1162. and headers
  1163. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1164. be returned without reading/decoding response
  1165. data. Default is True.
  1166. :param _request_timeout: timeout setting for this request. If one
  1167. number provided, it will be total request
  1168. timeout. It can also be a pair (tuple) of
  1169. (connection, read) timeouts.
  1170. :rtype: tuple(list[gate_api.OpenOrders], status_code(int), headers(HTTPHeaderDict))
  1171. :return: If the method is called asynchronously,
  1172. returns the request thread.
  1173. """
  1174. local_var_params = locals()
  1175. all_params = ['page', 'limit', 'account']
  1176. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1177. for k, v in six.iteritems(local_var_params['kwargs']):
  1178. if k not in all_params:
  1179. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_all_open_orders" % k)
  1180. local_var_params[k] = v
  1181. del local_var_params['kwargs']
  1182. if (
  1183. self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1
  1184. ): # noqa: E501
  1185. raise ApiValueError(
  1186. "Invalid value for parameter `page` when calling `list_all_open_orders`, must be a value greater than or equal to `1`"
  1187. ) # noqa: E501
  1188. if (
  1189. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 100
  1190. ): # noqa: E501
  1191. raise ApiValueError(
  1192. "Invalid value for parameter `limit` when calling `list_all_open_orders`, must be a value less than or equal to `100`"
  1193. ) # noqa: E501
  1194. if (
  1195. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  1196. ): # noqa: E501
  1197. raise ApiValueError(
  1198. "Invalid value for parameter `limit` when calling `list_all_open_orders`, must be a value greater than or equal to `1`"
  1199. ) # noqa: E501
  1200. collection_formats = {}
  1201. path_params = {}
  1202. query_params = []
  1203. if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501
  1204. query_params.append(('page', local_var_params['page'])) # noqa: E501
  1205. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  1206. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  1207. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  1208. query_params.append(('account', local_var_params['account'])) # noqa: E501
  1209. header_params = {}
  1210. form_params = []
  1211. local_var_files = {}
  1212. body_params = None
  1213. # HTTP header `Accept`
  1214. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1215. # Authentication setting
  1216. auth_settings = ['apiv4'] # noqa: E501
  1217. return self.api_client.call_api(
  1218. '/spot/open_orders',
  1219. 'GET',
  1220. path_params,
  1221. query_params,
  1222. header_params,
  1223. body=body_params,
  1224. post_params=form_params,
  1225. files=local_var_files,
  1226. response_type='list[OpenOrders]', # noqa: E501
  1227. auth_settings=auth_settings,
  1228. async_req=local_var_params.get('async_req'),
  1229. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1230. _preload_content=local_var_params.get('_preload_content', True),
  1231. _request_timeout=local_var_params.get('_request_timeout'),
  1232. collection_formats=collection_formats,
  1233. )
  1234. def create_cross_liquidate_order(self, liquidate_order, **kwargs): # noqa: E501
  1235. """close position when cross-currency is disabled # noqa: E501
  1236. Currently, only cross-margin accounts are supported to close position when cross currencies are disabled. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in the order book) / 0.998 # noqa: E501
  1237. This method makes a synchronous HTTP request by default. To make an
  1238. asynchronous HTTP request, please pass async_req=True
  1239. >>> thread = api.create_cross_liquidate_order(liquidate_order, async_req=True)
  1240. >>> result = thread.get()
  1241. :param bool async_req: execute request asynchronously
  1242. :param LiquidateOrder liquidate_order: (required)
  1243. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1244. be returned without reading/decoding response
  1245. data. Default is True.
  1246. :param _request_timeout: timeout setting for this request. If one
  1247. number provided, it will be total request
  1248. timeout. It can also be a pair (tuple) of
  1249. (connection, read) timeouts.
  1250. :rtype: gate_api.Order
  1251. :return: If the method is called asynchronously,
  1252. returns the request thread.
  1253. """
  1254. kwargs['_return_http_data_only'] = True
  1255. return self.create_cross_liquidate_order_with_http_info(liquidate_order, **kwargs) # noqa: E501
  1256. def create_cross_liquidate_order_with_http_info(self, liquidate_order, **kwargs): # noqa: E501
  1257. """close position when cross-currency is disabled # noqa: E501
  1258. Currently, only cross-margin accounts are supported to close position when cross currencies are disabled. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in the order book) / 0.998 # noqa: E501
  1259. This method makes a synchronous HTTP request by default. To make an
  1260. asynchronous HTTP request, please pass async_req=True
  1261. >>> thread = api.create_cross_liquidate_order_with_http_info(liquidate_order, async_req=True)
  1262. >>> result = thread.get()
  1263. :param bool async_req: execute request asynchronously
  1264. :param LiquidateOrder liquidate_order: (required)
  1265. :param _return_http_data_only: response data without head status code
  1266. and headers
  1267. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1268. be returned without reading/decoding response
  1269. data. Default is True.
  1270. :param _request_timeout: timeout setting for this request. If one
  1271. number provided, it will be total request
  1272. timeout. It can also be a pair (tuple) of
  1273. (connection, read) timeouts.
  1274. :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict))
  1275. :return: If the method is called asynchronously,
  1276. returns the request thread.
  1277. """
  1278. local_var_params = locals()
  1279. all_params = ['liquidate_order']
  1280. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1281. for k, v in six.iteritems(local_var_params['kwargs']):
  1282. if k not in all_params:
  1283. raise ApiTypeError(
  1284. "Got an unexpected keyword argument '%s'" " to method create_cross_liquidate_order" % k
  1285. )
  1286. local_var_params[k] = v
  1287. del local_var_params['kwargs']
  1288. # verify the required parameter 'liquidate_order' is set
  1289. if self.api_client.client_side_validation and (
  1290. 'liquidate_order' not in local_var_params or local_var_params['liquidate_order'] is None # noqa: E501
  1291. ): # noqa: E501
  1292. raise ApiValueError(
  1293. "Missing the required parameter `liquidate_order` when calling `create_cross_liquidate_order`"
  1294. ) # noqa: E501
  1295. collection_formats = {}
  1296. path_params = {}
  1297. query_params = []
  1298. header_params = {}
  1299. form_params = []
  1300. local_var_files = {}
  1301. body_params = None
  1302. if 'liquidate_order' in local_var_params:
  1303. body_params = local_var_params['liquidate_order']
  1304. # HTTP header `Accept`
  1305. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1306. # HTTP header `Content-Type`
  1307. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  1308. ['application/json']
  1309. ) # noqa: E501
  1310. # Authentication setting
  1311. auth_settings = ['apiv4'] # noqa: E501
  1312. return self.api_client.call_api(
  1313. '/spot/cross_liquidate_orders',
  1314. 'POST',
  1315. path_params,
  1316. query_params,
  1317. header_params,
  1318. body=body_params,
  1319. post_params=form_params,
  1320. files=local_var_files,
  1321. response_type='Order', # noqa: E501
  1322. auth_settings=auth_settings,
  1323. async_req=local_var_params.get('async_req'),
  1324. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1325. _preload_content=local_var_params.get('_preload_content', True),
  1326. _request_timeout=local_var_params.get('_request_timeout'),
  1327. collection_formats=collection_formats,
  1328. )
  1329. def list_orders(self, currency_pair, status, **kwargs): # noqa: E501
  1330. """List orders # noqa: E501
  1331. Spot and margin orders are returned by default. If cross margin orders are needed, `account` must be set to `cross_margin` When `status` is `open`, i.e., listing open orders, only pagination parameters `page` and `limit` are supported and `limit` cannot be larger than 100. Query by `side` and time range parameters `from` and `to` are not supported. When `status` is `finished`, i.e., listing finished orders, pagination parameters, time range parameters `from` and `to`, and `side` parameters are all supported. Time range parameters are handled as order finish time. # noqa: E501
  1332. This method makes a synchronous HTTP request by default. To make an
  1333. asynchronous HTTP request, please pass async_req=True
  1334. >>> thread = api.list_orders(currency_pair, status, async_req=True)
  1335. >>> result = thread.get()
  1336. :param bool async_req: execute request asynchronously
  1337. :param str currency_pair: Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones. (required)
  1338. :param str status: List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled (required)
  1339. :param int page: Page number
  1340. :param int limit: Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100
  1341. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1342. :param int _from: Start timestamp of the query
  1343. :param int to: Time range ending, default to current time
  1344. :param str side: All bids or asks. Both included if not specified
  1345. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1346. be returned without reading/decoding response
  1347. data. Default is True.
  1348. :param _request_timeout: timeout setting for this request. If one
  1349. number provided, it will be total request
  1350. timeout. It can also be a pair (tuple) of
  1351. (connection, read) timeouts.
  1352. :rtype: list[gate_api.Order]
  1353. :return: If the method is called asynchronously,
  1354. returns the request thread.
  1355. """
  1356. kwargs['_return_http_data_only'] = True
  1357. return self.list_orders_with_http_info(currency_pair, status, **kwargs) # noqa: E501
  1358. def list_orders_with_http_info(self, currency_pair, status, **kwargs): # noqa: E501
  1359. """List orders # noqa: E501
  1360. Spot and margin orders are returned by default. If cross margin orders are needed, `account` must be set to `cross_margin` When `status` is `open`, i.e., listing open orders, only pagination parameters `page` and `limit` are supported and `limit` cannot be larger than 100. Query by `side` and time range parameters `from` and `to` are not supported. When `status` is `finished`, i.e., listing finished orders, pagination parameters, time range parameters `from` and `to`, and `side` parameters are all supported. Time range parameters are handled as order finish time. # noqa: E501
  1361. This method makes a synchronous HTTP request by default. To make an
  1362. asynchronous HTTP request, please pass async_req=True
  1363. >>> thread = api.list_orders_with_http_info(currency_pair, status, async_req=True)
  1364. >>> result = thread.get()
  1365. :param bool async_req: execute request asynchronously
  1366. :param str currency_pair: Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones. (required)
  1367. :param str status: List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled (required)
  1368. :param int page: Page number
  1369. :param int limit: Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100
  1370. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1371. :param int _from: Start timestamp of the query
  1372. :param int to: Time range ending, default to current time
  1373. :param str side: All bids or asks. Both included if not specified
  1374. :param _return_http_data_only: response data without head status code
  1375. and headers
  1376. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1377. be returned without reading/decoding response
  1378. data. Default is True.
  1379. :param _request_timeout: timeout setting for this request. If one
  1380. number provided, it will be total request
  1381. timeout. It can also be a pair (tuple) of
  1382. (connection, read) timeouts.
  1383. :rtype: tuple(list[gate_api.Order], status_code(int), headers(HTTPHeaderDict))
  1384. :return: If the method is called asynchronously,
  1385. returns the request thread.
  1386. """
  1387. local_var_params = locals()
  1388. all_params = ['currency_pair', 'status', 'page', 'limit', 'account', '_from', 'to', 'side']
  1389. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1390. for k, v in six.iteritems(local_var_params['kwargs']):
  1391. if k not in all_params:
  1392. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_orders" % k)
  1393. local_var_params[k] = v
  1394. del local_var_params['kwargs']
  1395. # verify the required parameter 'currency_pair' is set
  1396. if self.api_client.client_side_validation and (
  1397. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  1398. ): # noqa: E501
  1399. raise ApiValueError(
  1400. "Missing the required parameter `currency_pair` when calling `list_orders`"
  1401. ) # noqa: E501
  1402. # verify the required parameter 'status' is set
  1403. if self.api_client.client_side_validation and (
  1404. 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501
  1405. ): # noqa: E501
  1406. raise ApiValueError("Missing the required parameter `status` when calling `list_orders`") # noqa: E501
  1407. if (
  1408. self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1
  1409. ): # noqa: E501
  1410. raise ApiValueError(
  1411. "Invalid value for parameter `page` when calling `list_orders`, must be a value greater than or equal to `1`"
  1412. ) # noqa: E501
  1413. if (
  1414. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  1415. ): # noqa: E501
  1416. raise ApiValueError(
  1417. "Invalid value for parameter `limit` when calling `list_orders`, must be a value less than or equal to `1000`"
  1418. ) # noqa: E501
  1419. if (
  1420. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  1421. ): # noqa: E501
  1422. raise ApiValueError(
  1423. "Invalid value for parameter `limit` when calling `list_orders`, must be a value greater than or equal to `1`"
  1424. ) # noqa: E501
  1425. collection_formats = {}
  1426. path_params = {}
  1427. query_params = []
  1428. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  1429. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  1430. if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501
  1431. query_params.append(('status', local_var_params['status'])) # noqa: E501
  1432. if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501
  1433. query_params.append(('page', local_var_params['page'])) # noqa: E501
  1434. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  1435. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  1436. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  1437. query_params.append(('account', local_var_params['account'])) # noqa: E501
  1438. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  1439. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  1440. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  1441. query_params.append(('to', local_var_params['to'])) # noqa: E501
  1442. if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501
  1443. query_params.append(('side', local_var_params['side'])) # noqa: E501
  1444. header_params = {}
  1445. form_params = []
  1446. local_var_files = {}
  1447. body_params = None
  1448. # HTTP header `Accept`
  1449. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1450. # Authentication setting
  1451. auth_settings = ['apiv4'] # noqa: E501
  1452. return self.api_client.call_api(
  1453. '/spot/orders',
  1454. 'GET',
  1455. path_params,
  1456. query_params,
  1457. header_params,
  1458. body=body_params,
  1459. post_params=form_params,
  1460. files=local_var_files,
  1461. response_type='list[Order]', # noqa: E501
  1462. auth_settings=auth_settings,
  1463. async_req=local_var_params.get('async_req'),
  1464. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1465. _preload_content=local_var_params.get('_preload_content', True),
  1466. _request_timeout=local_var_params.get('_request_timeout'),
  1467. collection_formats=collection_formats,
  1468. )
  1469. def create_order(self, order, **kwargs): # noqa: E501
  1470. """Create an order # noqa: E501
  1471. You can place orders with spot, margin or cross margin account through setting the `account `field. It defaults to `spot`, which means spot account is used to place orders. When margin account is used, i.e., `account` is `margin`, `auto_borrow` field can be set to `true` to enable the server to borrow the amount lacked using `POST /margin/loans` when your account's balance is not enough. Whether margin orders' fill will be used to repay margin loans automatically is determined by the auto repayment setting in your **margin account**, which can be updated or queried using `/margin/auto_repay` API. When cross margin account is used, i.e., `account` is `cross_margin`, `auto_borrow` can also be enabled to achieve borrowing the insufficient amount automatically if cross account's balance is not enough. But it differs from margin account that automatic repayment is determined by order's `auto_repay` field and only current order's fill will be used to repay cross margin loans. Automatic repayment will be triggered when the order is finished, i.e., its status is either `cancelled` or `closed`. **Order status** An order waiting to be filled is `open`, and it stays `open` until it is filled totally. If fully filled, order is finished and its status turns to `closed`.If the order is cancelled before it is totally filled, whether or not partially filled, its status is `cancelled`. **Iceberg order** `iceberg` field can be used to set the amount shown. Set to `-1` to hide the order completely. Note that the hidden part's fee will be charged using taker's fee rate. # noqa: E501
  1472. This method makes a synchronous HTTP request by default. To make an
  1473. asynchronous HTTP request, please pass async_req=True
  1474. >>> thread = api.create_order(order, async_req=True)
  1475. >>> result = thread.get()
  1476. :param bool async_req: execute request asynchronously
  1477. :param Order order: (required)
  1478. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1479. be returned without reading/decoding response
  1480. data. Default is True.
  1481. :param _request_timeout: timeout setting for this request. If one
  1482. number provided, it will be total request
  1483. timeout. It can also be a pair (tuple) of
  1484. (connection, read) timeouts.
  1485. :rtype: gate_api.Order
  1486. :return: If the method is called asynchronously,
  1487. returns the request thread.
  1488. """
  1489. kwargs['_return_http_data_only'] = True
  1490. return self.create_order_with_http_info(order, **kwargs) # noqa: E501
  1491. def create_order_with_http_info(self, order, **kwargs): # noqa: E501
  1492. """Create an order # noqa: E501
  1493. You can place orders with spot, margin or cross margin account through setting the `account `field. It defaults to `spot`, which means spot account is used to place orders. When margin account is used, i.e., `account` is `margin`, `auto_borrow` field can be set to `true` to enable the server to borrow the amount lacked using `POST /margin/loans` when your account's balance is not enough. Whether margin orders' fill will be used to repay margin loans automatically is determined by the auto repayment setting in your **margin account**, which can be updated or queried using `/margin/auto_repay` API. When cross margin account is used, i.e., `account` is `cross_margin`, `auto_borrow` can also be enabled to achieve borrowing the insufficient amount automatically if cross account's balance is not enough. But it differs from margin account that automatic repayment is determined by order's `auto_repay` field and only current order's fill will be used to repay cross margin loans. Automatic repayment will be triggered when the order is finished, i.e., its status is either `cancelled` or `closed`. **Order status** An order waiting to be filled is `open`, and it stays `open` until it is filled totally. If fully filled, order is finished and its status turns to `closed`.If the order is cancelled before it is totally filled, whether or not partially filled, its status is `cancelled`. **Iceberg order** `iceberg` field can be used to set the amount shown. Set to `-1` to hide the order completely. Note that the hidden part's fee will be charged using taker's fee rate. # noqa: E501
  1494. This method makes a synchronous HTTP request by default. To make an
  1495. asynchronous HTTP request, please pass async_req=True
  1496. >>> thread = api.create_order_with_http_info(order, async_req=True)
  1497. >>> result = thread.get()
  1498. :param bool async_req: execute request asynchronously
  1499. :param Order order: (required)
  1500. :param _return_http_data_only: response data without head status code
  1501. and headers
  1502. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1503. be returned without reading/decoding response
  1504. data. Default is True.
  1505. :param _request_timeout: timeout setting for this request. If one
  1506. number provided, it will be total request
  1507. timeout. It can also be a pair (tuple) of
  1508. (connection, read) timeouts.
  1509. :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict))
  1510. :return: If the method is called asynchronously,
  1511. returns the request thread.
  1512. """
  1513. local_var_params = locals()
  1514. all_params = ['order']
  1515. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1516. for k, v in six.iteritems(local_var_params['kwargs']):
  1517. if k not in all_params:
  1518. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_order" % k)
  1519. local_var_params[k] = v
  1520. del local_var_params['kwargs']
  1521. # verify the required parameter 'order' is set
  1522. if self.api_client.client_side_validation and (
  1523. 'order' not in local_var_params or local_var_params['order'] is None # noqa: E501
  1524. ): # noqa: E501
  1525. raise ApiValueError("Missing the required parameter `order` when calling `create_order`") # noqa: E501
  1526. collection_formats = {}
  1527. path_params = {}
  1528. query_params = []
  1529. header_params = {}
  1530. form_params = []
  1531. local_var_files = {}
  1532. body_params = None
  1533. if 'order' in local_var_params:
  1534. body_params = local_var_params['order']
  1535. # HTTP header `Accept`
  1536. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1537. # HTTP header `Content-Type`
  1538. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  1539. ['application/json']
  1540. ) # noqa: E501
  1541. # Authentication setting
  1542. auth_settings = ['apiv4'] # noqa: E501
  1543. return self.api_client.call_api(
  1544. '/spot/orders',
  1545. 'POST',
  1546. path_params,
  1547. query_params,
  1548. header_params,
  1549. body=body_params,
  1550. post_params=form_params,
  1551. files=local_var_files,
  1552. response_type='Order', # noqa: E501
  1553. auth_settings=auth_settings,
  1554. async_req=local_var_params.get('async_req'),
  1555. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1556. _preload_content=local_var_params.get('_preload_content', True),
  1557. _request_timeout=local_var_params.get('_request_timeout'),
  1558. collection_formats=collection_formats,
  1559. )
  1560. def cancel_orders(self, currency_pair, **kwargs): # noqa: E501
  1561. """Cancel all `open` orders in specified currency pair # noqa: E501
  1562. If `account` is not set, all open orders, including spot, margin and cross margin ones, will be cancelled. You can set `account` to cancel only orders within the specified account # noqa: E501
  1563. This method makes a synchronous HTTP request by default. To make an
  1564. asynchronous HTTP request, please pass async_req=True
  1565. >>> thread = api.cancel_orders(currency_pair, async_req=True)
  1566. >>> result = thread.get()
  1567. :param bool async_req: execute request asynchronously
  1568. :param str currency_pair: Currency pair (required)
  1569. :param str side: All bids or asks. Both included if not specified
  1570. :param str account: Specify account type - classic accountDefault to all account types being included - portfolio margin account`cross_margin` only
  1571. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1572. be returned without reading/decoding response
  1573. data. Default is True.
  1574. :param _request_timeout: timeout setting for this request. If one
  1575. number provided, it will be total request
  1576. timeout. It can also be a pair (tuple) of
  1577. (connection, read) timeouts.
  1578. :rtype: list[gate_api.Order]
  1579. :return: If the method is called asynchronously,
  1580. returns the request thread.
  1581. """
  1582. kwargs['_return_http_data_only'] = True
  1583. return self.cancel_orders_with_http_info(currency_pair, **kwargs) # noqa: E501
  1584. def cancel_orders_with_http_info(self, currency_pair, **kwargs): # noqa: E501
  1585. """Cancel all `open` orders in specified currency pair # noqa: E501
  1586. If `account` is not set, all open orders, including spot, margin and cross margin ones, will be cancelled. You can set `account` to cancel only orders within the specified account # noqa: E501
  1587. This method makes a synchronous HTTP request by default. To make an
  1588. asynchronous HTTP request, please pass async_req=True
  1589. >>> thread = api.cancel_orders_with_http_info(currency_pair, async_req=True)
  1590. >>> result = thread.get()
  1591. :param bool async_req: execute request asynchronously
  1592. :param str currency_pair: Currency pair (required)
  1593. :param str side: All bids or asks. Both included if not specified
  1594. :param str account: Specify account type - classic accountDefault to all account types being included - portfolio margin account`cross_margin` only
  1595. :param _return_http_data_only: response data without head status code
  1596. and headers
  1597. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1598. be returned without reading/decoding response
  1599. data. Default is True.
  1600. :param _request_timeout: timeout setting for this request. If one
  1601. number provided, it will be total request
  1602. timeout. It can also be a pair (tuple) of
  1603. (connection, read) timeouts.
  1604. :rtype: tuple(list[gate_api.Order], status_code(int), headers(HTTPHeaderDict))
  1605. :return: If the method is called asynchronously,
  1606. returns the request thread.
  1607. """
  1608. local_var_params = locals()
  1609. all_params = ['currency_pair', 'side', 'account']
  1610. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1611. for k, v in six.iteritems(local_var_params['kwargs']):
  1612. if k not in all_params:
  1613. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_orders" % k)
  1614. local_var_params[k] = v
  1615. del local_var_params['kwargs']
  1616. # verify the required parameter 'currency_pair' is set
  1617. if self.api_client.client_side_validation and (
  1618. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  1619. ): # noqa: E501
  1620. raise ApiValueError(
  1621. "Missing the required parameter `currency_pair` when calling `cancel_orders`"
  1622. ) # noqa: E501
  1623. collection_formats = {}
  1624. path_params = {}
  1625. query_params = []
  1626. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  1627. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  1628. if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501
  1629. query_params.append(('side', local_var_params['side'])) # noqa: E501
  1630. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  1631. query_params.append(('account', local_var_params['account'])) # noqa: E501
  1632. header_params = {}
  1633. form_params = []
  1634. local_var_files = {}
  1635. body_params = None
  1636. # HTTP header `Accept`
  1637. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1638. # Authentication setting
  1639. auth_settings = ['apiv4'] # noqa: E501
  1640. return self.api_client.call_api(
  1641. '/spot/orders',
  1642. 'DELETE',
  1643. path_params,
  1644. query_params,
  1645. header_params,
  1646. body=body_params,
  1647. post_params=form_params,
  1648. files=local_var_files,
  1649. response_type='list[Order]', # noqa: E501
  1650. auth_settings=auth_settings,
  1651. async_req=local_var_params.get('async_req'),
  1652. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1653. _preload_content=local_var_params.get('_preload_content', True),
  1654. _request_timeout=local_var_params.get('_request_timeout'),
  1655. collection_formats=collection_formats,
  1656. )
  1657. def cancel_batch_orders(self, cancel_order, **kwargs): # noqa: E501
  1658. """Cancel a batch of orders with an ID list # noqa: E501
  1659. Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501
  1660. This method makes a synchronous HTTP request by default. To make an
  1661. asynchronous HTTP request, please pass async_req=True
  1662. >>> thread = api.cancel_batch_orders(cancel_order, async_req=True)
  1663. >>> result = thread.get()
  1664. :param bool async_req: execute request asynchronously
  1665. :param list[CancelOrder] cancel_order: (required)
  1666. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1667. be returned without reading/decoding response
  1668. data. Default is True.
  1669. :param _request_timeout: timeout setting for this request. If one
  1670. number provided, it will be total request
  1671. timeout. It can also be a pair (tuple) of
  1672. (connection, read) timeouts.
  1673. :rtype: list[gate_api.CancelOrderResult]
  1674. :return: If the method is called asynchronously,
  1675. returns the request thread.
  1676. """
  1677. kwargs['_return_http_data_only'] = True
  1678. return self.cancel_batch_orders_with_http_info(cancel_order, **kwargs) # noqa: E501
  1679. def cancel_batch_orders_with_http_info(self, cancel_order, **kwargs): # noqa: E501
  1680. """Cancel a batch of orders with an ID list # noqa: E501
  1681. Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501
  1682. This method makes a synchronous HTTP request by default. To make an
  1683. asynchronous HTTP request, please pass async_req=True
  1684. >>> thread = api.cancel_batch_orders_with_http_info(cancel_order, async_req=True)
  1685. >>> result = thread.get()
  1686. :param bool async_req: execute request asynchronously
  1687. :param list[CancelOrder] cancel_order: (required)
  1688. :param _return_http_data_only: response data without head status code
  1689. and headers
  1690. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1691. be returned without reading/decoding response
  1692. data. Default is True.
  1693. :param _request_timeout: timeout setting for this request. If one
  1694. number provided, it will be total request
  1695. timeout. It can also be a pair (tuple) of
  1696. (connection, read) timeouts.
  1697. :rtype: tuple(list[gate_api.CancelOrderResult], status_code(int), headers(HTTPHeaderDict))
  1698. :return: If the method is called asynchronously,
  1699. returns the request thread.
  1700. """
  1701. local_var_params = locals()
  1702. all_params = ['cancel_order']
  1703. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1704. for k, v in six.iteritems(local_var_params['kwargs']):
  1705. if k not in all_params:
  1706. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_batch_orders" % k)
  1707. local_var_params[k] = v
  1708. del local_var_params['kwargs']
  1709. # verify the required parameter 'cancel_order' is set
  1710. if self.api_client.client_side_validation and (
  1711. 'cancel_order' not in local_var_params or local_var_params['cancel_order'] is None # noqa: E501
  1712. ): # noqa: E501
  1713. raise ApiValueError(
  1714. "Missing the required parameter `cancel_order` when calling `cancel_batch_orders`"
  1715. ) # noqa: E501
  1716. collection_formats = {}
  1717. path_params = {}
  1718. query_params = []
  1719. header_params = {}
  1720. form_params = []
  1721. local_var_files = {}
  1722. body_params = None
  1723. if 'cancel_order' in local_var_params:
  1724. body_params = local_var_params['cancel_order']
  1725. # HTTP header `Accept`
  1726. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1727. # HTTP header `Content-Type`
  1728. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  1729. ['application/json']
  1730. ) # noqa: E501
  1731. # Authentication setting
  1732. auth_settings = ['apiv4'] # noqa: E501
  1733. return self.api_client.call_api(
  1734. '/spot/cancel_batch_orders',
  1735. 'POST',
  1736. path_params,
  1737. query_params,
  1738. header_params,
  1739. body=body_params,
  1740. post_params=form_params,
  1741. files=local_var_files,
  1742. response_type='list[CancelOrderResult]', # noqa: E501
  1743. auth_settings=auth_settings,
  1744. async_req=local_var_params.get('async_req'),
  1745. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1746. _preload_content=local_var_params.get('_preload_content', True),
  1747. _request_timeout=local_var_params.get('_request_timeout'),
  1748. collection_formats=collection_formats,
  1749. )
  1750. def get_order(self, order_id, currency_pair, **kwargs): # noqa: E501
  1751. """Get a single order # noqa: E501
  1752. Spot and margin orders are queried by default. If cross margin orders are needed or portfolio margin account are used, account must be set to cross_margin. # noqa: E501
  1753. This method makes a synchronous HTTP request by default. To make an
  1754. asynchronous HTTP request, please pass async_req=True
  1755. >>> thread = api.get_order(order_id, currency_pair, async_req=True)
  1756. >>> result = thread.get()
  1757. :param bool async_req: execute request asynchronously
  1758. :param str order_id: Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. (required)
  1759. :param str currency_pair: Currency pair (required)
  1760. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1761. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1762. be returned without reading/decoding response
  1763. data. Default is True.
  1764. :param _request_timeout: timeout setting for this request. If one
  1765. number provided, it will be total request
  1766. timeout. It can also be a pair (tuple) of
  1767. (connection, read) timeouts.
  1768. :rtype: gate_api.Order
  1769. :return: If the method is called asynchronously,
  1770. returns the request thread.
  1771. """
  1772. kwargs['_return_http_data_only'] = True
  1773. return self.get_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501
  1774. def get_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: E501
  1775. """Get a single order # noqa: E501
  1776. Spot and margin orders are queried by default. If cross margin orders are needed or portfolio margin account are used, account must be set to cross_margin. # noqa: E501
  1777. This method makes a synchronous HTTP request by default. To make an
  1778. asynchronous HTTP request, please pass async_req=True
  1779. >>> thread = api.get_order_with_http_info(order_id, currency_pair, async_req=True)
  1780. >>> result = thread.get()
  1781. :param bool async_req: execute request asynchronously
  1782. :param str order_id: Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. (required)
  1783. :param str currency_pair: Currency pair (required)
  1784. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1785. :param _return_http_data_only: response data without head status code
  1786. and headers
  1787. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1788. be returned without reading/decoding response
  1789. data. Default is True.
  1790. :param _request_timeout: timeout setting for this request. If one
  1791. number provided, it will be total request
  1792. timeout. It can also be a pair (tuple) of
  1793. (connection, read) timeouts.
  1794. :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict))
  1795. :return: If the method is called asynchronously,
  1796. returns the request thread.
  1797. """
  1798. local_var_params = locals()
  1799. all_params = ['order_id', 'currency_pair', 'account']
  1800. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1801. for k, v in six.iteritems(local_var_params['kwargs']):
  1802. if k not in all_params:
  1803. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_order" % k)
  1804. local_var_params[k] = v
  1805. del local_var_params['kwargs']
  1806. # verify the required parameter 'order_id' is set
  1807. if self.api_client.client_side_validation and (
  1808. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  1809. ): # noqa: E501
  1810. raise ApiValueError("Missing the required parameter `order_id` when calling `get_order`") # noqa: E501
  1811. # verify the required parameter 'currency_pair' is set
  1812. if self.api_client.client_side_validation and (
  1813. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  1814. ): # noqa: E501
  1815. raise ApiValueError("Missing the required parameter `currency_pair` when calling `get_order`") # noqa: E501
  1816. collection_formats = {}
  1817. path_params = {}
  1818. if 'order_id' in local_var_params:
  1819. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  1820. query_params = []
  1821. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  1822. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  1823. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  1824. query_params.append(('account', local_var_params['account'])) # noqa: E501
  1825. header_params = {}
  1826. form_params = []
  1827. local_var_files = {}
  1828. body_params = None
  1829. # HTTP header `Accept`
  1830. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1831. # Authentication setting
  1832. auth_settings = ['apiv4'] # noqa: E501
  1833. return self.api_client.call_api(
  1834. '/spot/orders/{order_id}',
  1835. 'GET',
  1836. path_params,
  1837. query_params,
  1838. header_params,
  1839. body=body_params,
  1840. post_params=form_params,
  1841. files=local_var_files,
  1842. response_type='Order', # noqa: E501
  1843. auth_settings=auth_settings,
  1844. async_req=local_var_params.get('async_req'),
  1845. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1846. _preload_content=local_var_params.get('_preload_content', True),
  1847. _request_timeout=local_var_params.get('_request_timeout'),
  1848. collection_formats=collection_formats,
  1849. )
  1850. def cancel_order(self, order_id, currency_pair, **kwargs): # noqa: E501
  1851. """Cancel a single order # noqa: E501
  1852. Spot and margin orders are cancelled by default. If trying to cancel cross margin orders or portfolio margin account are used, account must be set to cross_margin # noqa: E501
  1853. This method makes a synchronous HTTP request by default. To make an
  1854. asynchronous HTTP request, please pass async_req=True
  1855. >>> thread = api.cancel_order(order_id, currency_pair, async_req=True)
  1856. >>> result = thread.get()
  1857. :param bool async_req: execute request asynchronously
  1858. :param str order_id: Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. (required)
  1859. :param str currency_pair: Currency pair (required)
  1860. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1861. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1862. be returned without reading/decoding response
  1863. data. Default is True.
  1864. :param _request_timeout: timeout setting for this request. If one
  1865. number provided, it will be total request
  1866. timeout. It can also be a pair (tuple) of
  1867. (connection, read) timeouts.
  1868. :rtype: gate_api.Order
  1869. :return: If the method is called asynchronously,
  1870. returns the request thread.
  1871. """
  1872. kwargs['_return_http_data_only'] = True
  1873. return self.cancel_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501
  1874. def cancel_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: E501
  1875. """Cancel a single order # noqa: E501
  1876. Spot and margin orders are cancelled by default. If trying to cancel cross margin orders or portfolio margin account are used, account must be set to cross_margin # noqa: E501
  1877. This method makes a synchronous HTTP request by default. To make an
  1878. asynchronous HTTP request, please pass async_req=True
  1879. >>> thread = api.cancel_order_with_http_info(order_id, currency_pair, async_req=True)
  1880. >>> result = thread.get()
  1881. :param bool async_req: execute request asynchronously
  1882. :param str order_id: Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. (required)
  1883. :param str currency_pair: Currency pair (required)
  1884. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1885. :param _return_http_data_only: response data without head status code
  1886. and headers
  1887. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1888. be returned without reading/decoding response
  1889. data. Default is True.
  1890. :param _request_timeout: timeout setting for this request. If one
  1891. number provided, it will be total request
  1892. timeout. It can also be a pair (tuple) of
  1893. (connection, read) timeouts.
  1894. :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict))
  1895. :return: If the method is called asynchronously,
  1896. returns the request thread.
  1897. """
  1898. local_var_params = locals()
  1899. all_params = ['order_id', 'currency_pair', 'account']
  1900. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1901. for k, v in six.iteritems(local_var_params['kwargs']):
  1902. if k not in all_params:
  1903. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_order" % k)
  1904. local_var_params[k] = v
  1905. del local_var_params['kwargs']
  1906. # verify the required parameter 'order_id' is set
  1907. if self.api_client.client_side_validation and (
  1908. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  1909. ): # noqa: E501
  1910. raise ApiValueError("Missing the required parameter `order_id` when calling `cancel_order`") # noqa: E501
  1911. # verify the required parameter 'currency_pair' is set
  1912. if self.api_client.client_side_validation and (
  1913. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  1914. ): # noqa: E501
  1915. raise ApiValueError(
  1916. "Missing the required parameter `currency_pair` when calling `cancel_order`"
  1917. ) # noqa: E501
  1918. collection_formats = {}
  1919. path_params = {}
  1920. if 'order_id' in local_var_params:
  1921. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  1922. query_params = []
  1923. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  1924. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  1925. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  1926. query_params.append(('account', local_var_params['account'])) # noqa: E501
  1927. header_params = {}
  1928. form_params = []
  1929. local_var_files = {}
  1930. body_params = None
  1931. # HTTP header `Accept`
  1932. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1933. # Authentication setting
  1934. auth_settings = ['apiv4'] # noqa: E501
  1935. return self.api_client.call_api(
  1936. '/spot/orders/{order_id}',
  1937. 'DELETE',
  1938. path_params,
  1939. query_params,
  1940. header_params,
  1941. body=body_params,
  1942. post_params=form_params,
  1943. files=local_var_files,
  1944. response_type='Order', # noqa: E501
  1945. auth_settings=auth_settings,
  1946. async_req=local_var_params.get('async_req'),
  1947. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1948. _preload_content=local_var_params.get('_preload_content', True),
  1949. _request_timeout=local_var_params.get('_request_timeout'),
  1950. collection_formats=collection_formats,
  1951. )
  1952. def amend_order(self, order_id, currency_pair, order_patch, **kwargs): # noqa: E501
  1953. """Amend an order # noqa: E501
  1954. By default, the orders of spot and margin account are updated. If you need to modify orders of the `cross-margin` account, you must specify account as `cross_margin`. For portfolio margin account, only `cross_margin` account is supported. Currently, only supports modification of `price` or `amount` fields. Regarding rate limiting: modify order and create order sharing rate limiting rules. Regarding matching priority: only modifying the amount does not affect the priority. If the price is modified, the priority will be adjusted to the last of the new price. Note: If the modified amount is less than the fill amount, the order will be cancelled. # noqa: E501
  1955. This method makes a synchronous HTTP request by default. To make an
  1956. asynchronous HTTP request, please pass async_req=True
  1957. >>> thread = api.amend_order(order_id, currency_pair, order_patch, async_req=True)
  1958. >>> result = thread.get()
  1959. :param bool async_req: execute request asynchronously
  1960. :param str order_id: Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. (required)
  1961. :param str currency_pair: Currency pair (required)
  1962. :param OrderPatch order_patch: (required)
  1963. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1964. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1965. be returned without reading/decoding response
  1966. data. Default is True.
  1967. :param _request_timeout: timeout setting for this request. If one
  1968. number provided, it will be total request
  1969. timeout. It can also be a pair (tuple) of
  1970. (connection, read) timeouts.
  1971. :rtype: gate_api.Order
  1972. :return: If the method is called asynchronously,
  1973. returns the request thread.
  1974. """
  1975. kwargs['_return_http_data_only'] = True
  1976. return self.amend_order_with_http_info(order_id, currency_pair, order_patch, **kwargs) # noqa: E501
  1977. def amend_order_with_http_info(self, order_id, currency_pair, order_patch, **kwargs): # noqa: E501
  1978. """Amend an order # noqa: E501
  1979. By default, the orders of spot and margin account are updated. If you need to modify orders of the `cross-margin` account, you must specify account as `cross_margin`. For portfolio margin account, only `cross_margin` account is supported. Currently, only supports modification of `price` or `amount` fields. Regarding rate limiting: modify order and create order sharing rate limiting rules. Regarding matching priority: only modifying the amount does not affect the priority. If the price is modified, the priority will be adjusted to the last of the new price. Note: If the modified amount is less than the fill amount, the order will be cancelled. # noqa: E501
  1980. This method makes a synchronous HTTP request by default. To make an
  1981. asynchronous HTTP request, please pass async_req=True
  1982. >>> thread = api.amend_order_with_http_info(order_id, currency_pair, order_patch, async_req=True)
  1983. >>> result = thread.get()
  1984. :param bool async_req: execute request asynchronously
  1985. :param str order_id: Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. (required)
  1986. :param str currency_pair: Currency pair (required)
  1987. :param OrderPatch order_patch: (required)
  1988. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  1989. :param _return_http_data_only: response data without head status code
  1990. and headers
  1991. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1992. be returned without reading/decoding response
  1993. data. Default is True.
  1994. :param _request_timeout: timeout setting for this request. If one
  1995. number provided, it will be total request
  1996. timeout. It can also be a pair (tuple) of
  1997. (connection, read) timeouts.
  1998. :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict))
  1999. :return: If the method is called asynchronously,
  2000. returns the request thread.
  2001. """
  2002. local_var_params = locals()
  2003. all_params = ['order_id', 'currency_pair', 'order_patch', 'account']
  2004. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2005. for k, v in six.iteritems(local_var_params['kwargs']):
  2006. if k not in all_params:
  2007. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method amend_order" % k)
  2008. local_var_params[k] = v
  2009. del local_var_params['kwargs']
  2010. # verify the required parameter 'order_id' is set
  2011. if self.api_client.client_side_validation and (
  2012. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  2013. ): # noqa: E501
  2014. raise ApiValueError("Missing the required parameter `order_id` when calling `amend_order`") # noqa: E501
  2015. # verify the required parameter 'currency_pair' is set
  2016. if self.api_client.client_side_validation and (
  2017. 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501
  2018. ): # noqa: E501
  2019. raise ApiValueError(
  2020. "Missing the required parameter `currency_pair` when calling `amend_order`"
  2021. ) # noqa: E501
  2022. # verify the required parameter 'order_patch' is set
  2023. if self.api_client.client_side_validation and (
  2024. 'order_patch' not in local_var_params or local_var_params['order_patch'] is None # noqa: E501
  2025. ): # noqa: E501
  2026. raise ApiValueError("Missing the required parameter `order_patch` when calling `amend_order`") # noqa: E501
  2027. collection_formats = {}
  2028. path_params = {}
  2029. if 'order_id' in local_var_params:
  2030. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  2031. query_params = []
  2032. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  2033. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  2034. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  2035. query_params.append(('account', local_var_params['account'])) # noqa: E501
  2036. header_params = {}
  2037. form_params = []
  2038. local_var_files = {}
  2039. body_params = None
  2040. if 'order_patch' in local_var_params:
  2041. body_params = local_var_params['order_patch']
  2042. # HTTP header `Accept`
  2043. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2044. # HTTP header `Content-Type`
  2045. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  2046. ['application/json']
  2047. ) # noqa: E501
  2048. # Authentication setting
  2049. auth_settings = ['apiv4'] # noqa: E501
  2050. return self.api_client.call_api(
  2051. '/spot/orders/{order_id}',
  2052. 'PATCH',
  2053. path_params,
  2054. query_params,
  2055. header_params,
  2056. body=body_params,
  2057. post_params=form_params,
  2058. files=local_var_files,
  2059. response_type='Order', # noqa: E501
  2060. auth_settings=auth_settings,
  2061. async_req=local_var_params.get('async_req'),
  2062. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2063. _preload_content=local_var_params.get('_preload_content', True),
  2064. _request_timeout=local_var_params.get('_request_timeout'),
  2065. collection_formats=collection_formats,
  2066. )
  2067. def list_my_trades(self, **kwargs): # noqa: E501
  2068. """List personal trading history # noqa: E501
  2069. Spot and margin trades are queried by default. If cross margin trades are needed, `account` must be set to `cross_margin` You can also set `from` and(or) `to` to query by time range. If you don't specify `from` and/or `to` parameters, only the last 7 days of data will be retured. The range of `from` and `to` is not alloed to exceed 30 days. Time range parameters are handled as order finish time. # noqa: E501
  2070. This method makes a synchronous HTTP request by default. To make an
  2071. asynchronous HTTP request, please pass async_req=True
  2072. >>> thread = api.list_my_trades(async_req=True)
  2073. >>> result = thread.get()
  2074. :param bool async_req: execute request asynchronously
  2075. :param str currency_pair: Retrieve results with specified currency pair
  2076. :param int limit: Maximum number of records to be returned in a single list
  2077. :param int page: Page number
  2078. :param str order_id: Filter trades with specified order ID. `currency_pair` is also required if this field is present
  2079. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  2080. :param int _from: Start timestamp of the query
  2081. :param int to: Time range ending, default to current time
  2082. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2083. be returned without reading/decoding response
  2084. data. Default is True.
  2085. :param _request_timeout: timeout setting for this request. If one
  2086. number provided, it will be total request
  2087. timeout. It can also be a pair (tuple) of
  2088. (connection, read) timeouts.
  2089. :rtype: list[gate_api.Trade]
  2090. :return: If the method is called asynchronously,
  2091. returns the request thread.
  2092. """
  2093. kwargs['_return_http_data_only'] = True
  2094. return self.list_my_trades_with_http_info(**kwargs) # noqa: E501
  2095. def list_my_trades_with_http_info(self, **kwargs): # noqa: E501
  2096. """List personal trading history # noqa: E501
  2097. Spot and margin trades are queried by default. If cross margin trades are needed, `account` must be set to `cross_margin` You can also set `from` and(or) `to` to query by time range. If you don't specify `from` and/or `to` parameters, only the last 7 days of data will be retured. The range of `from` and `to` is not alloed to exceed 30 days. Time range parameters are handled as order finish time. # noqa: E501
  2098. This method makes a synchronous HTTP request by default. To make an
  2099. asynchronous HTTP request, please pass async_req=True
  2100. >>> thread = api.list_my_trades_with_http_info(async_req=True)
  2101. >>> result = thread.get()
  2102. :param bool async_req: execute request asynchronously
  2103. :param str currency_pair: Retrieve results with specified currency pair
  2104. :param int limit: Maximum number of records to be returned in a single list
  2105. :param int page: Page number
  2106. :param str order_id: Filter trades with specified order ID. `currency_pair` is also required if this field is present
  2107. :param str account: Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
  2108. :param int _from: Start timestamp of the query
  2109. :param int to: Time range ending, default to current time
  2110. :param _return_http_data_only: response data without head status code
  2111. and headers
  2112. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2113. be returned without reading/decoding response
  2114. data. Default is True.
  2115. :param _request_timeout: timeout setting for this request. If one
  2116. number provided, it will be total request
  2117. timeout. It can also be a pair (tuple) of
  2118. (connection, read) timeouts.
  2119. :rtype: tuple(list[gate_api.Trade], status_code(int), headers(HTTPHeaderDict))
  2120. :return: If the method is called asynchronously,
  2121. returns the request thread.
  2122. """
  2123. local_var_params = locals()
  2124. all_params = ['currency_pair', 'limit', 'page', 'order_id', 'account', '_from', 'to']
  2125. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2126. for k, v in six.iteritems(local_var_params['kwargs']):
  2127. if k not in all_params:
  2128. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_my_trades" % k)
  2129. local_var_params[k] = v
  2130. del local_var_params['kwargs']
  2131. if (
  2132. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  2133. ): # noqa: E501
  2134. raise ApiValueError(
  2135. "Invalid value for parameter `limit` when calling `list_my_trades`, must be a value less than or equal to `1000`"
  2136. ) # noqa: E501
  2137. if (
  2138. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  2139. ): # noqa: E501
  2140. raise ApiValueError(
  2141. "Invalid value for parameter `limit` when calling `list_my_trades`, must be a value greater than or equal to `1`"
  2142. ) # noqa: E501
  2143. if (
  2144. self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1
  2145. ): # noqa: E501
  2146. raise ApiValueError(
  2147. "Invalid value for parameter `page` when calling `list_my_trades`, must be a value greater than or equal to `1`"
  2148. ) # noqa: E501
  2149. collection_formats = {}
  2150. path_params = {}
  2151. query_params = []
  2152. if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501
  2153. query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501
  2154. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  2155. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  2156. if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501
  2157. query_params.append(('page', local_var_params['page'])) # noqa: E501
  2158. if 'order_id' in local_var_params and local_var_params['order_id'] is not None: # noqa: E501
  2159. query_params.append(('order_id', local_var_params['order_id'])) # noqa: E501
  2160. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  2161. query_params.append(('account', local_var_params['account'])) # noqa: E501
  2162. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  2163. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  2164. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  2165. query_params.append(('to', local_var_params['to'])) # noqa: E501
  2166. header_params = {}
  2167. form_params = []
  2168. local_var_files = {}
  2169. body_params = None
  2170. # HTTP header `Accept`
  2171. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2172. # Authentication setting
  2173. auth_settings = ['apiv4'] # noqa: E501
  2174. return self.api_client.call_api(
  2175. '/spot/my_trades',
  2176. 'GET',
  2177. path_params,
  2178. query_params,
  2179. header_params,
  2180. body=body_params,
  2181. post_params=form_params,
  2182. files=local_var_files,
  2183. response_type='list[Trade]', # noqa: E501
  2184. auth_settings=auth_settings,
  2185. async_req=local_var_params.get('async_req'),
  2186. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2187. _preload_content=local_var_params.get('_preload_content', True),
  2188. _request_timeout=local_var_params.get('_request_timeout'),
  2189. collection_formats=collection_formats,
  2190. )
  2191. def get_system_time(self, **kwargs): # noqa: E501
  2192. """Get server current time # noqa: E501
  2193. This method makes a synchronous HTTP request by default. To make an
  2194. asynchronous HTTP request, please pass async_req=True
  2195. >>> thread = api.get_system_time(async_req=True)
  2196. >>> result = thread.get()
  2197. :param bool async_req: execute request asynchronously
  2198. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2199. be returned without reading/decoding response
  2200. data. Default is True.
  2201. :param _request_timeout: timeout setting for this request. If one
  2202. number provided, it will be total request
  2203. timeout. It can also be a pair (tuple) of
  2204. (connection, read) timeouts.
  2205. :rtype: gate_api.SystemTime
  2206. :return: If the method is called asynchronously,
  2207. returns the request thread.
  2208. """
  2209. kwargs['_return_http_data_only'] = True
  2210. return self.get_system_time_with_http_info(**kwargs) # noqa: E501
  2211. def get_system_time_with_http_info(self, **kwargs): # noqa: E501
  2212. """Get server current time # noqa: E501
  2213. This method makes a synchronous HTTP request by default. To make an
  2214. asynchronous HTTP request, please pass async_req=True
  2215. >>> thread = api.get_system_time_with_http_info(async_req=True)
  2216. >>> result = thread.get()
  2217. :param bool async_req: execute request asynchronously
  2218. :param _return_http_data_only: response data without head status code
  2219. and headers
  2220. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2221. be returned without reading/decoding response
  2222. data. Default is True.
  2223. :param _request_timeout: timeout setting for this request. If one
  2224. number provided, it will be total request
  2225. timeout. It can also be a pair (tuple) of
  2226. (connection, read) timeouts.
  2227. :rtype: tuple(gate_api.SystemTime, status_code(int), headers(HTTPHeaderDict))
  2228. :return: If the method is called asynchronously,
  2229. returns the request thread.
  2230. """
  2231. local_var_params = locals()
  2232. all_params = []
  2233. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2234. for k, v in six.iteritems(local_var_params['kwargs']):
  2235. if k not in all_params:
  2236. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_system_time" % k)
  2237. local_var_params[k] = v
  2238. del local_var_params['kwargs']
  2239. collection_formats = {}
  2240. path_params = {}
  2241. query_params = []
  2242. header_params = {}
  2243. form_params = []
  2244. local_var_files = {}
  2245. body_params = None
  2246. # HTTP header `Accept`
  2247. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2248. # Authentication setting
  2249. auth_settings = [] # noqa: E501
  2250. return self.api_client.call_api(
  2251. '/spot/time',
  2252. 'GET',
  2253. path_params,
  2254. query_params,
  2255. header_params,
  2256. body=body_params,
  2257. post_params=form_params,
  2258. files=local_var_files,
  2259. response_type='SystemTime', # noqa: E501
  2260. auth_settings=auth_settings,
  2261. async_req=local_var_params.get('async_req'),
  2262. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2263. _preload_content=local_var_params.get('_preload_content', True),
  2264. _request_timeout=local_var_params.get('_request_timeout'),
  2265. collection_formats=collection_formats,
  2266. )
  2267. def countdown_cancel_all_spot(self, countdown_cancel_all_spot_task, **kwargs): # noqa: E501
  2268. """Countdown cancel orders # noqa: E501
  2269. When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown. For example, call this endpoint at 30s intervals, each countdown`timeout` is set to 30s. If this endpoint is not called again within 30 seconds, all pending orders on the specified `market` will be automatically cancelled, if no `market` is specified, all market pending orders will be cancelled. If the `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the cacnel function will be cancelled. # noqa: E501
  2270. This method makes a synchronous HTTP request by default. To make an
  2271. asynchronous HTTP request, please pass async_req=True
  2272. >>> thread = api.countdown_cancel_all_spot(countdown_cancel_all_spot_task, async_req=True)
  2273. >>> result = thread.get()
  2274. :param bool async_req: execute request asynchronously
  2275. :param CountdownCancelAllSpotTask countdown_cancel_all_spot_task: (required)
  2276. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2277. be returned without reading/decoding response
  2278. data. Default is True.
  2279. :param _request_timeout: timeout setting for this request. If one
  2280. number provided, it will be total request
  2281. timeout. It can also be a pair (tuple) of
  2282. (connection, read) timeouts.
  2283. :rtype: gate_api.TriggerTime
  2284. :return: If the method is called asynchronously,
  2285. returns the request thread.
  2286. """
  2287. kwargs['_return_http_data_only'] = True
  2288. return self.countdown_cancel_all_spot_with_http_info(countdown_cancel_all_spot_task, **kwargs) # noqa: E501
  2289. def countdown_cancel_all_spot_with_http_info(self, countdown_cancel_all_spot_task, **kwargs): # noqa: E501
  2290. """Countdown cancel orders # noqa: E501
  2291. When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown. For example, call this endpoint at 30s intervals, each countdown`timeout` is set to 30s. If this endpoint is not called again within 30 seconds, all pending orders on the specified `market` will be automatically cancelled, if no `market` is specified, all market pending orders will be cancelled. If the `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the cacnel function will be cancelled. # noqa: E501
  2292. This method makes a synchronous HTTP request by default. To make an
  2293. asynchronous HTTP request, please pass async_req=True
  2294. >>> thread = api.countdown_cancel_all_spot_with_http_info(countdown_cancel_all_spot_task, async_req=True)
  2295. >>> result = thread.get()
  2296. :param bool async_req: execute request asynchronously
  2297. :param CountdownCancelAllSpotTask countdown_cancel_all_spot_task: (required)
  2298. :param _return_http_data_only: response data without head status code
  2299. and headers
  2300. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2301. be returned without reading/decoding response
  2302. data. Default is True.
  2303. :param _request_timeout: timeout setting for this request. If one
  2304. number provided, it will be total request
  2305. timeout. It can also be a pair (tuple) of
  2306. (connection, read) timeouts.
  2307. :rtype: tuple(gate_api.TriggerTime, status_code(int), headers(HTTPHeaderDict))
  2308. :return: If the method is called asynchronously,
  2309. returns the request thread.
  2310. """
  2311. local_var_params = locals()
  2312. all_params = ['countdown_cancel_all_spot_task']
  2313. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2314. for k, v in six.iteritems(local_var_params['kwargs']):
  2315. if k not in all_params:
  2316. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method countdown_cancel_all_spot" % k)
  2317. local_var_params[k] = v
  2318. del local_var_params['kwargs']
  2319. # verify the required parameter 'countdown_cancel_all_spot_task' is set
  2320. if self.api_client.client_side_validation and (
  2321. 'countdown_cancel_all_spot_task' not in local_var_params
  2322. or local_var_params['countdown_cancel_all_spot_task'] is None # noqa: E501
  2323. ): # noqa: E501
  2324. raise ApiValueError(
  2325. "Missing the required parameter `countdown_cancel_all_spot_task` when calling `countdown_cancel_all_spot`"
  2326. ) # noqa: E501
  2327. collection_formats = {}
  2328. path_params = {}
  2329. query_params = []
  2330. header_params = {}
  2331. form_params = []
  2332. local_var_files = {}
  2333. body_params = None
  2334. if 'countdown_cancel_all_spot_task' in local_var_params:
  2335. body_params = local_var_params['countdown_cancel_all_spot_task']
  2336. # HTTP header `Accept`
  2337. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2338. # HTTP header `Content-Type`
  2339. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  2340. ['application/json']
  2341. ) # noqa: E501
  2342. # Authentication setting
  2343. auth_settings = ['apiv4'] # noqa: E501
  2344. return self.api_client.call_api(
  2345. '/spot/countdown_cancel_all',
  2346. 'POST',
  2347. path_params,
  2348. query_params,
  2349. header_params,
  2350. body=body_params,
  2351. post_params=form_params,
  2352. files=local_var_files,
  2353. response_type='TriggerTime', # noqa: E501
  2354. auth_settings=auth_settings,
  2355. async_req=local_var_params.get('async_req'),
  2356. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2357. _preload_content=local_var_params.get('_preload_content', True),
  2358. _request_timeout=local_var_params.get('_request_timeout'),
  2359. collection_formats=collection_formats,
  2360. )
  2361. def list_spot_price_triggered_orders(self, status, **kwargs): # noqa: E501
  2362. """Retrieve running auto order list # noqa: E501
  2363. This method makes a synchronous HTTP request by default. To make an
  2364. asynchronous HTTP request, please pass async_req=True
  2365. >>> thread = api.list_spot_price_triggered_orders(status, async_req=True)
  2366. >>> result = thread.get()
  2367. :param bool async_req: execute request asynchronously
  2368. :param str status: Only list the orders with this status (required)
  2369. :param str market: Currency pair
  2370. :param str account: Trading account type. Portfolio margin account must set to `cross_margin`
  2371. :param int limit: Maximum number of records to be returned in a single list
  2372. :param int offset: List offset, starting from 0
  2373. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2374. be returned without reading/decoding response
  2375. data. Default is True.
  2376. :param _request_timeout: timeout setting for this request. If one
  2377. number provided, it will be total request
  2378. timeout. It can also be a pair (tuple) of
  2379. (connection, read) timeouts.
  2380. :rtype: list[gate_api.SpotPriceTriggeredOrder]
  2381. :return: If the method is called asynchronously,
  2382. returns the request thread.
  2383. """
  2384. kwargs['_return_http_data_only'] = True
  2385. return self.list_spot_price_triggered_orders_with_http_info(status, **kwargs) # noqa: E501
  2386. def list_spot_price_triggered_orders_with_http_info(self, status, **kwargs): # noqa: E501
  2387. """Retrieve running auto order list # noqa: E501
  2388. This method makes a synchronous HTTP request by default. To make an
  2389. asynchronous HTTP request, please pass async_req=True
  2390. >>> thread = api.list_spot_price_triggered_orders_with_http_info(status, async_req=True)
  2391. >>> result = thread.get()
  2392. :param bool async_req: execute request asynchronously
  2393. :param str status: Only list the orders with this status (required)
  2394. :param str market: Currency pair
  2395. :param str account: Trading account type. Portfolio margin account must set to `cross_margin`
  2396. :param int limit: Maximum number of records to be returned in a single list
  2397. :param int offset: List offset, starting from 0
  2398. :param _return_http_data_only: response data without head status code
  2399. and headers
  2400. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2401. be returned without reading/decoding response
  2402. data. Default is True.
  2403. :param _request_timeout: timeout setting for this request. If one
  2404. number provided, it will be total request
  2405. timeout. It can also be a pair (tuple) of
  2406. (connection, read) timeouts.
  2407. :rtype: tuple(list[gate_api.SpotPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict))
  2408. :return: If the method is called asynchronously,
  2409. returns the request thread.
  2410. """
  2411. local_var_params = locals()
  2412. all_params = ['status', 'market', 'account', 'limit', 'offset']
  2413. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2414. for k, v in six.iteritems(local_var_params['kwargs']):
  2415. if k not in all_params:
  2416. raise ApiTypeError(
  2417. "Got an unexpected keyword argument '%s'" " to method list_spot_price_triggered_orders" % k
  2418. )
  2419. local_var_params[k] = v
  2420. del local_var_params['kwargs']
  2421. # verify the required parameter 'status' is set
  2422. if self.api_client.client_side_validation and (
  2423. 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501
  2424. ): # noqa: E501
  2425. raise ApiValueError(
  2426. "Missing the required parameter `status` when calling `list_spot_price_triggered_orders`"
  2427. ) # noqa: E501
  2428. if (
  2429. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  2430. ): # noqa: E501
  2431. raise ApiValueError(
  2432. "Invalid value for parameter `limit` when calling `list_spot_price_triggered_orders`, must be a value less than or equal to `1000`"
  2433. ) # noqa: E501
  2434. if (
  2435. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  2436. ): # noqa: E501
  2437. raise ApiValueError(
  2438. "Invalid value for parameter `limit` when calling `list_spot_price_triggered_orders`, must be a value greater than or equal to `1`"
  2439. ) # noqa: E501
  2440. if (
  2441. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  2442. ): # noqa: E501
  2443. raise ApiValueError(
  2444. "Invalid value for parameter `offset` when calling `list_spot_price_triggered_orders`, must be a value greater than or equal to `0`"
  2445. ) # noqa: E501
  2446. collection_formats = {}
  2447. path_params = {}
  2448. query_params = []
  2449. if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501
  2450. query_params.append(('status', local_var_params['status'])) # noqa: E501
  2451. if 'market' in local_var_params and local_var_params['market'] is not None: # noqa: E501
  2452. query_params.append(('market', local_var_params['market'])) # noqa: E501
  2453. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  2454. query_params.append(('account', local_var_params['account'])) # noqa: E501
  2455. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  2456. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  2457. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  2458. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  2459. header_params = {}
  2460. form_params = []
  2461. local_var_files = {}
  2462. body_params = None
  2463. # HTTP header `Accept`
  2464. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2465. # Authentication setting
  2466. auth_settings = ['apiv4'] # noqa: E501
  2467. return self.api_client.call_api(
  2468. '/spot/price_orders',
  2469. 'GET',
  2470. path_params,
  2471. query_params,
  2472. header_params,
  2473. body=body_params,
  2474. post_params=form_params,
  2475. files=local_var_files,
  2476. response_type='list[SpotPriceTriggeredOrder]', # noqa: E501
  2477. auth_settings=auth_settings,
  2478. async_req=local_var_params.get('async_req'),
  2479. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2480. _preload_content=local_var_params.get('_preload_content', True),
  2481. _request_timeout=local_var_params.get('_request_timeout'),
  2482. collection_formats=collection_formats,
  2483. )
  2484. def create_spot_price_triggered_order(self, spot_price_triggered_order, **kwargs): # noqa: E501
  2485. """Create a price-triggered order # noqa: E501
  2486. This method makes a synchronous HTTP request by default. To make an
  2487. asynchronous HTTP request, please pass async_req=True
  2488. >>> thread = api.create_spot_price_triggered_order(spot_price_triggered_order, async_req=True)
  2489. >>> result = thread.get()
  2490. :param bool async_req: execute request asynchronously
  2491. :param SpotPriceTriggeredOrder spot_price_triggered_order: (required)
  2492. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2493. be returned without reading/decoding response
  2494. data. Default is True.
  2495. :param _request_timeout: timeout setting for this request. If one
  2496. number provided, it will be total request
  2497. timeout. It can also be a pair (tuple) of
  2498. (connection, read) timeouts.
  2499. :rtype: gate_api.TriggerOrderResponse
  2500. :return: If the method is called asynchronously,
  2501. returns the request thread.
  2502. """
  2503. kwargs['_return_http_data_only'] = True
  2504. return self.create_spot_price_triggered_order_with_http_info(spot_price_triggered_order, **kwargs) # noqa: E501
  2505. def create_spot_price_triggered_order_with_http_info(self, spot_price_triggered_order, **kwargs): # noqa: E501
  2506. """Create a price-triggered order # noqa: E501
  2507. This method makes a synchronous HTTP request by default. To make an
  2508. asynchronous HTTP request, please pass async_req=True
  2509. >>> thread = api.create_spot_price_triggered_order_with_http_info(spot_price_triggered_order, async_req=True)
  2510. >>> result = thread.get()
  2511. :param bool async_req: execute request asynchronously
  2512. :param SpotPriceTriggeredOrder spot_price_triggered_order: (required)
  2513. :param _return_http_data_only: response data without head status code
  2514. and headers
  2515. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2516. be returned without reading/decoding response
  2517. data. Default is True.
  2518. :param _request_timeout: timeout setting for this request. If one
  2519. number provided, it will be total request
  2520. timeout. It can also be a pair (tuple) of
  2521. (connection, read) timeouts.
  2522. :rtype: tuple(gate_api.TriggerOrderResponse, status_code(int), headers(HTTPHeaderDict))
  2523. :return: If the method is called asynchronously,
  2524. returns the request thread.
  2525. """
  2526. local_var_params = locals()
  2527. all_params = ['spot_price_triggered_order']
  2528. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2529. for k, v in six.iteritems(local_var_params['kwargs']):
  2530. if k not in all_params:
  2531. raise ApiTypeError(
  2532. "Got an unexpected keyword argument '%s'" " to method create_spot_price_triggered_order" % k
  2533. )
  2534. local_var_params[k] = v
  2535. del local_var_params['kwargs']
  2536. # verify the required parameter 'spot_price_triggered_order' is set
  2537. if self.api_client.client_side_validation and (
  2538. 'spot_price_triggered_order' not in local_var_params
  2539. or local_var_params['spot_price_triggered_order'] is None # noqa: E501
  2540. ): # noqa: E501
  2541. raise ApiValueError(
  2542. "Missing the required parameter `spot_price_triggered_order` when calling `create_spot_price_triggered_order`"
  2543. ) # noqa: E501
  2544. collection_formats = {}
  2545. path_params = {}
  2546. query_params = []
  2547. header_params = {}
  2548. form_params = []
  2549. local_var_files = {}
  2550. body_params = None
  2551. if 'spot_price_triggered_order' in local_var_params:
  2552. body_params = local_var_params['spot_price_triggered_order']
  2553. # HTTP header `Accept`
  2554. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2555. # HTTP header `Content-Type`
  2556. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  2557. ['application/json']
  2558. ) # noqa: E501
  2559. # Authentication setting
  2560. auth_settings = ['apiv4'] # noqa: E501
  2561. return self.api_client.call_api(
  2562. '/spot/price_orders',
  2563. 'POST',
  2564. path_params,
  2565. query_params,
  2566. header_params,
  2567. body=body_params,
  2568. post_params=form_params,
  2569. files=local_var_files,
  2570. response_type='TriggerOrderResponse', # noqa: E501
  2571. auth_settings=auth_settings,
  2572. async_req=local_var_params.get('async_req'),
  2573. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2574. _preload_content=local_var_params.get('_preload_content', True),
  2575. _request_timeout=local_var_params.get('_request_timeout'),
  2576. collection_formats=collection_formats,
  2577. )
  2578. def cancel_spot_price_triggered_order_list(self, **kwargs): # noqa: E501
  2579. """Cancel all open orders # noqa: E501
  2580. This method makes a synchronous HTTP request by default. To make an
  2581. asynchronous HTTP request, please pass async_req=True
  2582. >>> thread = api.cancel_spot_price_triggered_order_list(async_req=True)
  2583. >>> result = thread.get()
  2584. :param bool async_req: execute request asynchronously
  2585. :param str market: Currency pair
  2586. :param str account: Trading account type. Portfolio margin account must set to `cross_margin`
  2587. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2588. be returned without reading/decoding response
  2589. data. Default is True.
  2590. :param _request_timeout: timeout setting for this request. If one
  2591. number provided, it will be total request
  2592. timeout. It can also be a pair (tuple) of
  2593. (connection, read) timeouts.
  2594. :rtype: list[gate_api.SpotPriceTriggeredOrder]
  2595. :return: If the method is called asynchronously,
  2596. returns the request thread.
  2597. """
  2598. kwargs['_return_http_data_only'] = True
  2599. return self.cancel_spot_price_triggered_order_list_with_http_info(**kwargs) # noqa: E501
  2600. def cancel_spot_price_triggered_order_list_with_http_info(self, **kwargs): # noqa: E501
  2601. """Cancel all open orders # noqa: E501
  2602. This method makes a synchronous HTTP request by default. To make an
  2603. asynchronous HTTP request, please pass async_req=True
  2604. >>> thread = api.cancel_spot_price_triggered_order_list_with_http_info(async_req=True)
  2605. >>> result = thread.get()
  2606. :param bool async_req: execute request asynchronously
  2607. :param str market: Currency pair
  2608. :param str account: Trading account type. Portfolio margin account must set to `cross_margin`
  2609. :param _return_http_data_only: response data without head status code
  2610. and headers
  2611. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2612. be returned without reading/decoding response
  2613. data. Default is True.
  2614. :param _request_timeout: timeout setting for this request. If one
  2615. number provided, it will be total request
  2616. timeout. It can also be a pair (tuple) of
  2617. (connection, read) timeouts.
  2618. :rtype: tuple(list[gate_api.SpotPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict))
  2619. :return: If the method is called asynchronously,
  2620. returns the request thread.
  2621. """
  2622. local_var_params = locals()
  2623. all_params = ['market', 'account']
  2624. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2625. for k, v in six.iteritems(local_var_params['kwargs']):
  2626. if k not in all_params:
  2627. raise ApiTypeError(
  2628. "Got an unexpected keyword argument '%s'" " to method cancel_spot_price_triggered_order_list" % k
  2629. )
  2630. local_var_params[k] = v
  2631. del local_var_params['kwargs']
  2632. collection_formats = {}
  2633. path_params = {}
  2634. query_params = []
  2635. if 'market' in local_var_params and local_var_params['market'] is not None: # noqa: E501
  2636. query_params.append(('market', local_var_params['market'])) # noqa: E501
  2637. if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501
  2638. query_params.append(('account', local_var_params['account'])) # noqa: E501
  2639. header_params = {}
  2640. form_params = []
  2641. local_var_files = {}
  2642. body_params = None
  2643. # HTTP header `Accept`
  2644. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2645. # Authentication setting
  2646. auth_settings = ['apiv4'] # noqa: E501
  2647. return self.api_client.call_api(
  2648. '/spot/price_orders',
  2649. 'DELETE',
  2650. path_params,
  2651. query_params,
  2652. header_params,
  2653. body=body_params,
  2654. post_params=form_params,
  2655. files=local_var_files,
  2656. response_type='list[SpotPriceTriggeredOrder]', # noqa: E501
  2657. auth_settings=auth_settings,
  2658. async_req=local_var_params.get('async_req'),
  2659. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2660. _preload_content=local_var_params.get('_preload_content', True),
  2661. _request_timeout=local_var_params.get('_request_timeout'),
  2662. collection_formats=collection_formats,
  2663. )
  2664. def get_spot_price_triggered_order(self, order_id, **kwargs): # noqa: E501
  2665. """Get a price-triggered order # noqa: E501
  2666. This method makes a synchronous HTTP request by default. To make an
  2667. asynchronous HTTP request, please pass async_req=True
  2668. >>> thread = api.get_spot_price_triggered_order(order_id, async_req=True)
  2669. >>> result = thread.get()
  2670. :param bool async_req: execute request asynchronously
  2671. :param str order_id: Retrieve the data of the order with the specified ID (required)
  2672. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2673. be returned without reading/decoding response
  2674. data. Default is True.
  2675. :param _request_timeout: timeout setting for this request. If one
  2676. number provided, it will be total request
  2677. timeout. It can also be a pair (tuple) of
  2678. (connection, read) timeouts.
  2679. :rtype: gate_api.SpotPriceTriggeredOrder
  2680. :return: If the method is called asynchronously,
  2681. returns the request thread.
  2682. """
  2683. kwargs['_return_http_data_only'] = True
  2684. return self.get_spot_price_triggered_order_with_http_info(order_id, **kwargs) # noqa: E501
  2685. def get_spot_price_triggered_order_with_http_info(self, order_id, **kwargs): # noqa: E501
  2686. """Get a price-triggered order # noqa: E501
  2687. This method makes a synchronous HTTP request by default. To make an
  2688. asynchronous HTTP request, please pass async_req=True
  2689. >>> thread = api.get_spot_price_triggered_order_with_http_info(order_id, async_req=True)
  2690. >>> result = thread.get()
  2691. :param bool async_req: execute request asynchronously
  2692. :param str order_id: Retrieve the data of the order with the specified ID (required)
  2693. :param _return_http_data_only: response data without head status code
  2694. and headers
  2695. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2696. be returned without reading/decoding response
  2697. data. Default is True.
  2698. :param _request_timeout: timeout setting for this request. If one
  2699. number provided, it will be total request
  2700. timeout. It can also be a pair (tuple) of
  2701. (connection, read) timeouts.
  2702. :rtype: tuple(gate_api.SpotPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict))
  2703. :return: If the method is called asynchronously,
  2704. returns the request thread.
  2705. """
  2706. local_var_params = locals()
  2707. all_params = ['order_id']
  2708. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2709. for k, v in six.iteritems(local_var_params['kwargs']):
  2710. if k not in all_params:
  2711. raise ApiTypeError(
  2712. "Got an unexpected keyword argument '%s'" " to method get_spot_price_triggered_order" % k
  2713. )
  2714. local_var_params[k] = v
  2715. del local_var_params['kwargs']
  2716. # verify the required parameter 'order_id' is set
  2717. if self.api_client.client_side_validation and (
  2718. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  2719. ): # noqa: E501
  2720. raise ApiValueError(
  2721. "Missing the required parameter `order_id` when calling `get_spot_price_triggered_order`"
  2722. ) # noqa: E501
  2723. collection_formats = {}
  2724. path_params = {}
  2725. if 'order_id' in local_var_params:
  2726. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  2727. query_params = []
  2728. header_params = {}
  2729. form_params = []
  2730. local_var_files = {}
  2731. body_params = None
  2732. # HTTP header `Accept`
  2733. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2734. # Authentication setting
  2735. auth_settings = ['apiv4'] # noqa: E501
  2736. return self.api_client.call_api(
  2737. '/spot/price_orders/{order_id}',
  2738. 'GET',
  2739. path_params,
  2740. query_params,
  2741. header_params,
  2742. body=body_params,
  2743. post_params=form_params,
  2744. files=local_var_files,
  2745. response_type='SpotPriceTriggeredOrder', # noqa: E501
  2746. auth_settings=auth_settings,
  2747. async_req=local_var_params.get('async_req'),
  2748. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2749. _preload_content=local_var_params.get('_preload_content', True),
  2750. _request_timeout=local_var_params.get('_request_timeout'),
  2751. collection_formats=collection_formats,
  2752. )
  2753. def cancel_spot_price_triggered_order(self, order_id, **kwargs): # noqa: E501
  2754. """cancel a price-triggered order # noqa: E501
  2755. This method makes a synchronous HTTP request by default. To make an
  2756. asynchronous HTTP request, please pass async_req=True
  2757. >>> thread = api.cancel_spot_price_triggered_order(order_id, async_req=True)
  2758. >>> result = thread.get()
  2759. :param bool async_req: execute request asynchronously
  2760. :param str order_id: Retrieve the data of the order with the specified ID (required)
  2761. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2762. be returned without reading/decoding response
  2763. data. Default is True.
  2764. :param _request_timeout: timeout setting for this request. If one
  2765. number provided, it will be total request
  2766. timeout. It can also be a pair (tuple) of
  2767. (connection, read) timeouts.
  2768. :rtype: gate_api.SpotPriceTriggeredOrder
  2769. :return: If the method is called asynchronously,
  2770. returns the request thread.
  2771. """
  2772. kwargs['_return_http_data_only'] = True
  2773. return self.cancel_spot_price_triggered_order_with_http_info(order_id, **kwargs) # noqa: E501
  2774. def cancel_spot_price_triggered_order_with_http_info(self, order_id, **kwargs): # noqa: E501
  2775. """cancel a price-triggered order # noqa: E501
  2776. This method makes a synchronous HTTP request by default. To make an
  2777. asynchronous HTTP request, please pass async_req=True
  2778. >>> thread = api.cancel_spot_price_triggered_order_with_http_info(order_id, async_req=True)
  2779. >>> result = thread.get()
  2780. :param bool async_req: execute request asynchronously
  2781. :param str order_id: Retrieve the data of the order with the specified ID (required)
  2782. :param _return_http_data_only: response data without head status code
  2783. and headers
  2784. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2785. be returned without reading/decoding response
  2786. data. Default is True.
  2787. :param _request_timeout: timeout setting for this request. If one
  2788. number provided, it will be total request
  2789. timeout. It can also be a pair (tuple) of
  2790. (connection, read) timeouts.
  2791. :rtype: tuple(gate_api.SpotPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict))
  2792. :return: If the method is called asynchronously,
  2793. returns the request thread.
  2794. """
  2795. local_var_params = locals()
  2796. all_params = ['order_id']
  2797. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2798. for k, v in six.iteritems(local_var_params['kwargs']):
  2799. if k not in all_params:
  2800. raise ApiTypeError(
  2801. "Got an unexpected keyword argument '%s'" " to method cancel_spot_price_triggered_order" % k
  2802. )
  2803. local_var_params[k] = v
  2804. del local_var_params['kwargs']
  2805. # verify the required parameter 'order_id' is set
  2806. if self.api_client.client_side_validation and (
  2807. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  2808. ): # noqa: E501
  2809. raise ApiValueError(
  2810. "Missing the required parameter `order_id` when calling `cancel_spot_price_triggered_order`"
  2811. ) # noqa: E501
  2812. collection_formats = {}
  2813. path_params = {}
  2814. if 'order_id' in local_var_params:
  2815. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  2816. query_params = []
  2817. header_params = {}
  2818. form_params = []
  2819. local_var_files = {}
  2820. body_params = None
  2821. # HTTP header `Accept`
  2822. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2823. # Authentication setting
  2824. auth_settings = ['apiv4'] # noqa: E501
  2825. return self.api_client.call_api(
  2826. '/spot/price_orders/{order_id}',
  2827. 'DELETE',
  2828. path_params,
  2829. query_params,
  2830. header_params,
  2831. body=body_params,
  2832. post_params=form_params,
  2833. files=local_var_files,
  2834. response_type='SpotPriceTriggeredOrder', # noqa: E501
  2835. auth_settings=auth_settings,
  2836. async_req=local_var_params.get('async_req'),
  2837. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2838. _preload_content=local_var_params.get('_preload_content', True),
  2839. _request_timeout=local_var_params.get('_request_timeout'),
  2840. collection_formats=collection_formats,
  2841. )