天择加密量化开放框架下载
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.

590 lines
28 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 FlashSwapApi(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_flash_swap_currencies(self, **kwargs): # noqa: E501
  24. """List all supported currencies in flash swap # noqa: E501
  25. This method makes a synchronous HTTP request by default. To make an
  26. asynchronous HTTP request, please pass async_req=True
  27. >>> thread = api.list_flash_swap_currencies(async_req=True)
  28. >>> result = thread.get()
  29. :param bool async_req: execute request asynchronously
  30. :param _preload_content: if False, the urllib3.HTTPResponse object will
  31. be returned without reading/decoding response
  32. data. Default is True.
  33. :param _request_timeout: timeout setting for this request. If one
  34. number provided, it will be total request
  35. timeout. It can also be a pair (tuple) of
  36. (connection, read) timeouts.
  37. :rtype: list[gate_api.FlashSwapCurrency]
  38. :return: If the method is called asynchronously,
  39. returns the request thread.
  40. """
  41. kwargs['_return_http_data_only'] = True
  42. return self.list_flash_swap_currencies_with_http_info(**kwargs) # noqa: E501
  43. def list_flash_swap_currencies_with_http_info(self, **kwargs): # noqa: E501
  44. """List all supported currencies in flash swap # noqa: E501
  45. This method makes a synchronous HTTP request by default. To make an
  46. asynchronous HTTP request, please pass async_req=True
  47. >>> thread = api.list_flash_swap_currencies_with_http_info(async_req=True)
  48. >>> result = thread.get()
  49. :param bool async_req: execute request asynchronously
  50. :param _return_http_data_only: response data without head status code
  51. and headers
  52. :param _preload_content: if False, the urllib3.HTTPResponse object will
  53. be returned without reading/decoding response
  54. data. Default is True.
  55. :param _request_timeout: timeout setting for this request. If one
  56. number provided, it will be total request
  57. timeout. It can also be a pair (tuple) of
  58. (connection, read) timeouts.
  59. :rtype: tuple(list[gate_api.FlashSwapCurrency], status_code(int), headers(HTTPHeaderDict))
  60. :return: If the method is called asynchronously,
  61. returns the request thread.
  62. """
  63. local_var_params = locals()
  64. all_params = []
  65. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  66. for k, v in six.iteritems(local_var_params['kwargs']):
  67. if k not in all_params:
  68. raise ApiTypeError(
  69. "Got an unexpected keyword argument '%s'" " to method list_flash_swap_currencies" % k
  70. )
  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. '/flash_swap/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[FlashSwapCurrency]', # 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 list_flash_swap_orders(self, **kwargs): # noqa: E501
  102. """List all flash swap orders # 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.list_flash_swap_orders(async_req=True)
  106. >>> result = thread.get()
  107. :param bool async_req: execute request asynchronously
  108. :param int status: Flash swap order status `1` - success `2` - failure
  109. :param str sell_currency: Currency to sell which can be retrieved from supported currency list API `GET /flash_swap/currencies`
  110. :param str buy_currency: Currency to buy which can be retrieved from supported currency list API `GET /flash_swap/currencies`
  111. :param bool reverse: If results are sorted by id in reverse order. Default to `true` - `true`: sort by id in descending order(recent first) - `false`: sort by id in ascending order(oldest first)
  112. :param int limit: Maximum number of records to be returned in a single list
  113. :param int page: Page number
  114. :param _preload_content: if False, the urllib3.HTTPResponse object will
  115. be returned without reading/decoding response
  116. data. Default is True.
  117. :param _request_timeout: timeout setting for this request. If one
  118. number provided, it will be total request
  119. timeout. It can also be a pair (tuple) of
  120. (connection, read) timeouts.
  121. :rtype: list[gate_api.FlashSwapOrder]
  122. :return: If the method is called asynchronously,
  123. returns the request thread.
  124. """
  125. kwargs['_return_http_data_only'] = True
  126. return self.list_flash_swap_orders_with_http_info(**kwargs) # noqa: E501
  127. def list_flash_swap_orders_with_http_info(self, **kwargs): # noqa: E501
  128. """List all flash swap orders # noqa: E501
  129. This method makes a synchronous HTTP request by default. To make an
  130. asynchronous HTTP request, please pass async_req=True
  131. >>> thread = api.list_flash_swap_orders_with_http_info(async_req=True)
  132. >>> result = thread.get()
  133. :param bool async_req: execute request asynchronously
  134. :param int status: Flash swap order status `1` - success `2` - failure
  135. :param str sell_currency: Currency to sell which can be retrieved from supported currency list API `GET /flash_swap/currencies`
  136. :param str buy_currency: Currency to buy which can be retrieved from supported currency list API `GET /flash_swap/currencies`
  137. :param bool reverse: If results are sorted by id in reverse order. Default to `true` - `true`: sort by id in descending order(recent first) - `false`: sort by id in ascending order(oldest first)
  138. :param int limit: Maximum number of records to be returned in a single list
  139. :param int page: Page number
  140. :param _return_http_data_only: response data without head status code
  141. and headers
  142. :param _preload_content: if False, the urllib3.HTTPResponse object will
  143. be returned without reading/decoding response
  144. data. Default is True.
  145. :param _request_timeout: timeout setting for this request. If one
  146. number provided, it will be total request
  147. timeout. It can also be a pair (tuple) of
  148. (connection, read) timeouts.
  149. :rtype: tuple(list[gate_api.FlashSwapOrder], status_code(int), headers(HTTPHeaderDict))
  150. :return: If the method is called asynchronously,
  151. returns the request thread.
  152. """
  153. local_var_params = locals()
  154. all_params = ['status', 'sell_currency', 'buy_currency', 'reverse', 'limit', 'page']
  155. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  156. for k, v in six.iteritems(local_var_params['kwargs']):
  157. if k not in all_params:
  158. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_flash_swap_orders" % k)
  159. local_var_params[k] = v
  160. del local_var_params['kwargs']
  161. if (
  162. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  163. ): # noqa: E501
  164. raise ApiValueError(
  165. "Invalid value for parameter `limit` when calling `list_flash_swap_orders`, must be a value less than or equal to `1000`"
  166. ) # noqa: E501
  167. if (
  168. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  169. ): # noqa: E501
  170. raise ApiValueError(
  171. "Invalid value for parameter `limit` when calling `list_flash_swap_orders`, must be a value greater than or equal to `1`"
  172. ) # noqa: E501
  173. if (
  174. self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1
  175. ): # noqa: E501
  176. raise ApiValueError(
  177. "Invalid value for parameter `page` when calling `list_flash_swap_orders`, must be a value greater than or equal to `1`"
  178. ) # noqa: E501
  179. collection_formats = {}
  180. path_params = {}
  181. query_params = []
  182. if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501
  183. query_params.append(('status', local_var_params['status'])) # noqa: E501
  184. if 'sell_currency' in local_var_params and local_var_params['sell_currency'] is not None: # noqa: E501
  185. query_params.append(('sell_currency', local_var_params['sell_currency'])) # noqa: E501
  186. if 'buy_currency' in local_var_params and local_var_params['buy_currency'] is not None: # noqa: E501
  187. query_params.append(('buy_currency', local_var_params['buy_currency'])) # noqa: E501
  188. if 'reverse' in local_var_params and local_var_params['reverse'] is not None: # noqa: E501
  189. query_params.append(('reverse', local_var_params['reverse'])) # noqa: E501
  190. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  191. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  192. if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501
  193. query_params.append(('page', local_var_params['page'])) # noqa: E501
  194. header_params = {}
  195. form_params = []
  196. local_var_files = {}
  197. body_params = None
  198. # HTTP header `Accept`
  199. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  200. # Authentication setting
  201. auth_settings = ['apiv4'] # noqa: E501
  202. return self.api_client.call_api(
  203. '/flash_swap/orders',
  204. 'GET',
  205. path_params,
  206. query_params,
  207. header_params,
  208. body=body_params,
  209. post_params=form_params,
  210. files=local_var_files,
  211. response_type='list[FlashSwapOrder]', # noqa: E501
  212. auth_settings=auth_settings,
  213. async_req=local_var_params.get('async_req'),
  214. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  215. _preload_content=local_var_params.get('_preload_content', True),
  216. _request_timeout=local_var_params.get('_request_timeout'),
  217. collection_formats=collection_formats,
  218. )
  219. def create_flash_swap_order(self, flash_swap_order_request, **kwargs): # noqa: E501
  220. """Create a flash swap order # noqa: E501
  221. Initiate a flash swap preview in advance because order creation requires a preview result # noqa: E501
  222. This method makes a synchronous HTTP request by default. To make an
  223. asynchronous HTTP request, please pass async_req=True
  224. >>> thread = api.create_flash_swap_order(flash_swap_order_request, async_req=True)
  225. >>> result = thread.get()
  226. :param bool async_req: execute request asynchronously
  227. :param FlashSwapOrderRequest flash_swap_order_request: (required)
  228. :param _preload_content: if False, the urllib3.HTTPResponse object will
  229. be returned without reading/decoding response
  230. data. Default is True.
  231. :param _request_timeout: timeout setting for this request. If one
  232. number provided, it will be total request
  233. timeout. It can also be a pair (tuple) of
  234. (connection, read) timeouts.
  235. :rtype: gate_api.FlashSwapOrder
  236. :return: If the method is called asynchronously,
  237. returns the request thread.
  238. """
  239. kwargs['_return_http_data_only'] = True
  240. return self.create_flash_swap_order_with_http_info(flash_swap_order_request, **kwargs) # noqa: E501
  241. def create_flash_swap_order_with_http_info(self, flash_swap_order_request, **kwargs): # noqa: E501
  242. """Create a flash swap order # noqa: E501
  243. Initiate a flash swap preview in advance because order creation requires a preview result # noqa: E501
  244. This method makes a synchronous HTTP request by default. To make an
  245. asynchronous HTTP request, please pass async_req=True
  246. >>> thread = api.create_flash_swap_order_with_http_info(flash_swap_order_request, async_req=True)
  247. >>> result = thread.get()
  248. :param bool async_req: execute request asynchronously
  249. :param FlashSwapOrderRequest flash_swap_order_request: (required)
  250. :param _return_http_data_only: response data without head status code
  251. and headers
  252. :param _preload_content: if False, the urllib3.HTTPResponse object will
  253. be returned without reading/decoding response
  254. data. Default is True.
  255. :param _request_timeout: timeout setting for this request. If one
  256. number provided, it will be total request
  257. timeout. It can also be a pair (tuple) of
  258. (connection, read) timeouts.
  259. :rtype: tuple(gate_api.FlashSwapOrder, status_code(int), headers(HTTPHeaderDict))
  260. :return: If the method is called asynchronously,
  261. returns the request thread.
  262. """
  263. local_var_params = locals()
  264. all_params = ['flash_swap_order_request']
  265. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  266. for k, v in six.iteritems(local_var_params['kwargs']):
  267. if k not in all_params:
  268. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_flash_swap_order" % k)
  269. local_var_params[k] = v
  270. del local_var_params['kwargs']
  271. # verify the required parameter 'flash_swap_order_request' is set
  272. if self.api_client.client_side_validation and (
  273. 'flash_swap_order_request' not in local_var_params
  274. or local_var_params['flash_swap_order_request'] is None # noqa: E501
  275. ): # noqa: E501
  276. raise ApiValueError(
  277. "Missing the required parameter `flash_swap_order_request` when calling `create_flash_swap_order`"
  278. ) # noqa: E501
  279. collection_formats = {}
  280. path_params = {}
  281. query_params = []
  282. header_params = {}
  283. form_params = []
  284. local_var_files = {}
  285. body_params = None
  286. if 'flash_swap_order_request' in local_var_params:
  287. body_params = local_var_params['flash_swap_order_request']
  288. # HTTP header `Accept`
  289. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  290. # HTTP header `Content-Type`
  291. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  292. ['application/json']
  293. ) # noqa: E501
  294. # Authentication setting
  295. auth_settings = ['apiv4'] # noqa: E501
  296. return self.api_client.call_api(
  297. '/flash_swap/orders',
  298. 'POST',
  299. path_params,
  300. query_params,
  301. header_params,
  302. body=body_params,
  303. post_params=form_params,
  304. files=local_var_files,
  305. response_type='FlashSwapOrder', # noqa: E501
  306. auth_settings=auth_settings,
  307. async_req=local_var_params.get('async_req'),
  308. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  309. _preload_content=local_var_params.get('_preload_content', True),
  310. _request_timeout=local_var_params.get('_request_timeout'),
  311. collection_formats=collection_formats,
  312. )
  313. def get_flash_swap_order(self, order_id, **kwargs): # noqa: E501
  314. """Get a single flash swap order's detail # noqa: E501
  315. This method makes a synchronous HTTP request by default. To make an
  316. asynchronous HTTP request, please pass async_req=True
  317. >>> thread = api.get_flash_swap_order(order_id, async_req=True)
  318. >>> result = thread.get()
  319. :param bool async_req: execute request asynchronously
  320. :param int order_id: Flash swap order ID (required)
  321. :param _preload_content: if False, the urllib3.HTTPResponse object will
  322. be returned without reading/decoding response
  323. data. Default is True.
  324. :param _request_timeout: timeout setting for this request. If one
  325. number provided, it will be total request
  326. timeout. It can also be a pair (tuple) of
  327. (connection, read) timeouts.
  328. :rtype: gate_api.FlashSwapOrder
  329. :return: If the method is called asynchronously,
  330. returns the request thread.
  331. """
  332. kwargs['_return_http_data_only'] = True
  333. return self.get_flash_swap_order_with_http_info(order_id, **kwargs) # noqa: E501
  334. def get_flash_swap_order_with_http_info(self, order_id, **kwargs): # noqa: E501
  335. """Get a single flash swap order's detail # noqa: E501
  336. This method makes a synchronous HTTP request by default. To make an
  337. asynchronous HTTP request, please pass async_req=True
  338. >>> thread = api.get_flash_swap_order_with_http_info(order_id, async_req=True)
  339. >>> result = thread.get()
  340. :param bool async_req: execute request asynchronously
  341. :param int order_id: Flash swap order ID (required)
  342. :param _return_http_data_only: response data without head status code
  343. and headers
  344. :param _preload_content: if False, the urllib3.HTTPResponse object will
  345. be returned without reading/decoding response
  346. data. Default is True.
  347. :param _request_timeout: timeout setting for this request. If one
  348. number provided, it will be total request
  349. timeout. It can also be a pair (tuple) of
  350. (connection, read) timeouts.
  351. :rtype: tuple(gate_api.FlashSwapOrder, status_code(int), headers(HTTPHeaderDict))
  352. :return: If the method is called asynchronously,
  353. returns the request thread.
  354. """
  355. local_var_params = locals()
  356. all_params = ['order_id']
  357. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  358. for k, v in six.iteritems(local_var_params['kwargs']):
  359. if k not in all_params:
  360. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_flash_swap_order" % k)
  361. local_var_params[k] = v
  362. del local_var_params['kwargs']
  363. # verify the required parameter 'order_id' is set
  364. if self.api_client.client_side_validation and (
  365. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  366. ): # noqa: E501
  367. raise ApiValueError(
  368. "Missing the required parameter `order_id` when calling `get_flash_swap_order`"
  369. ) # noqa: E501
  370. collection_formats = {}
  371. path_params = {}
  372. if 'order_id' in local_var_params:
  373. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  374. query_params = []
  375. header_params = {}
  376. form_params = []
  377. local_var_files = {}
  378. body_params = None
  379. # HTTP header `Accept`
  380. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  381. # Authentication setting
  382. auth_settings = ['apiv4'] # noqa: E501
  383. return self.api_client.call_api(
  384. '/flash_swap/orders/{order_id}',
  385. 'GET',
  386. path_params,
  387. query_params,
  388. header_params,
  389. body=body_params,
  390. post_params=form_params,
  391. files=local_var_files,
  392. response_type='FlashSwapOrder', # noqa: E501
  393. auth_settings=auth_settings,
  394. async_req=local_var_params.get('async_req'),
  395. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  396. _preload_content=local_var_params.get('_preload_content', True),
  397. _request_timeout=local_var_params.get('_request_timeout'),
  398. collection_formats=collection_formats,
  399. )
  400. def preview_flash_swap_order(self, flash_swap_order_request, **kwargs): # noqa: E501
  401. """Initiate a flash swap order preview # noqa: E501
  402. This method makes a synchronous HTTP request by default. To make an
  403. asynchronous HTTP request, please pass async_req=True
  404. >>> thread = api.preview_flash_swap_order(flash_swap_order_request, async_req=True)
  405. >>> result = thread.get()
  406. :param bool async_req: execute request asynchronously
  407. :param FlashSwapOrderRequest flash_swap_order_request: (required)
  408. :param _preload_content: if False, the urllib3.HTTPResponse object will
  409. be returned without reading/decoding response
  410. data. Default is True.
  411. :param _request_timeout: timeout setting for this request. If one
  412. number provided, it will be total request
  413. timeout. It can also be a pair (tuple) of
  414. (connection, read) timeouts.
  415. :rtype: gate_api.FlashSwapOrderPreview
  416. :return: If the method is called asynchronously,
  417. returns the request thread.
  418. """
  419. kwargs['_return_http_data_only'] = True
  420. return self.preview_flash_swap_order_with_http_info(flash_swap_order_request, **kwargs) # noqa: E501
  421. def preview_flash_swap_order_with_http_info(self, flash_swap_order_request, **kwargs): # noqa: E501
  422. """Initiate a flash swap order preview # noqa: E501
  423. This method makes a synchronous HTTP request by default. To make an
  424. asynchronous HTTP request, please pass async_req=True
  425. >>> thread = api.preview_flash_swap_order_with_http_info(flash_swap_order_request, async_req=True)
  426. >>> result = thread.get()
  427. :param bool async_req: execute request asynchronously
  428. :param FlashSwapOrderRequest flash_swap_order_request: (required)
  429. :param _return_http_data_only: response data without head status code
  430. and headers
  431. :param _preload_content: if False, the urllib3.HTTPResponse object will
  432. be returned without reading/decoding response
  433. data. Default is True.
  434. :param _request_timeout: timeout setting for this request. If one
  435. number provided, it will be total request
  436. timeout. It can also be a pair (tuple) of
  437. (connection, read) timeouts.
  438. :rtype: tuple(gate_api.FlashSwapOrderPreview, status_code(int), headers(HTTPHeaderDict))
  439. :return: If the method is called asynchronously,
  440. returns the request thread.
  441. """
  442. local_var_params = locals()
  443. all_params = ['flash_swap_order_request']
  444. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  445. for k, v in six.iteritems(local_var_params['kwargs']):
  446. if k not in all_params:
  447. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method preview_flash_swap_order" % k)
  448. local_var_params[k] = v
  449. del local_var_params['kwargs']
  450. # verify the required parameter 'flash_swap_order_request' is set
  451. if self.api_client.client_side_validation and (
  452. 'flash_swap_order_request' not in local_var_params
  453. or local_var_params['flash_swap_order_request'] is None # noqa: E501
  454. ): # noqa: E501
  455. raise ApiValueError(
  456. "Missing the required parameter `flash_swap_order_request` when calling `preview_flash_swap_order`"
  457. ) # noqa: E501
  458. collection_formats = {}
  459. path_params = {}
  460. query_params = []
  461. header_params = {}
  462. form_params = []
  463. local_var_files = {}
  464. body_params = None
  465. if 'flash_swap_order_request' in local_var_params:
  466. body_params = local_var_params['flash_swap_order_request']
  467. # HTTP header `Accept`
  468. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  469. # HTTP header `Content-Type`
  470. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  471. ['application/json']
  472. ) # noqa: E501
  473. # Authentication setting
  474. auth_settings = ['apiv4'] # noqa: E501
  475. return self.api_client.call_api(
  476. '/flash_swap/orders/preview',
  477. 'POST',
  478. path_params,
  479. query_params,
  480. header_params,
  481. body=body_params,
  482. post_params=form_params,
  483. files=local_var_files,
  484. response_type='FlashSwapOrderPreview', # noqa: E501
  485. auth_settings=auth_settings,
  486. async_req=local_var_params.get('async_req'),
  487. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  488. _preload_content=local_var_params.get('_preload_content', True),
  489. _request_timeout=local_var_params.get('_request_timeout'),
  490. collection_formats=collection_formats,
  491. )