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

5373 lines
276 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 FuturesApi(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_futures_contracts(self, settle, **kwargs): # noqa: E501
  24. """List all futures contracts # 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_futures_contracts(settle, async_req=True)
  28. >>> result = thread.get()
  29. :param bool async_req: execute request asynchronously
  30. :param str settle: Settle currency (required)
  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.Contract]
  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_futures_contracts_with_http_info(settle, **kwargs) # noqa: E501
  44. def list_futures_contracts_with_http_info(self, settle, **kwargs): # noqa: E501
  45. """List all futures contracts # noqa: E501
  46. This method makes a synchronous HTTP request by default. To make an
  47. asynchronous HTTP request, please pass async_req=True
  48. >>> thread = api.list_futures_contracts_with_http_info(settle, async_req=True)
  49. >>> result = thread.get()
  50. :param bool async_req: execute request asynchronously
  51. :param str settle: Settle currency (required)
  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.Contract], 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 = ['settle']
  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_futures_contracts" % k)
  71. local_var_params[k] = v
  72. del local_var_params['kwargs']
  73. # verify the required parameter 'settle' is set
  74. if self.api_client.client_side_validation and (
  75. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  76. ): # noqa: E501
  77. raise ApiValueError(
  78. "Missing the required parameter `settle` when calling `list_futures_contracts`"
  79. ) # noqa: E501
  80. collection_formats = {}
  81. path_params = {}
  82. if 'settle' in local_var_params:
  83. path_params['settle'] = local_var_params['settle'] # noqa: E501
  84. query_params = []
  85. header_params = {}
  86. form_params = []
  87. local_var_files = {}
  88. body_params = None
  89. # HTTP header `Accept`
  90. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  91. # Authentication setting
  92. auth_settings = [] # noqa: E501
  93. return self.api_client.call_api(
  94. '/futures/{settle}/contracts',
  95. 'GET',
  96. path_params,
  97. query_params,
  98. header_params,
  99. body=body_params,
  100. post_params=form_params,
  101. files=local_var_files,
  102. response_type='list[Contract]', # noqa: E501
  103. auth_settings=auth_settings,
  104. async_req=local_var_params.get('async_req'),
  105. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  106. _preload_content=local_var_params.get('_preload_content', True),
  107. _request_timeout=local_var_params.get('_request_timeout'),
  108. collection_formats=collection_formats,
  109. )
  110. def get_futures_contract(self, settle, contract, **kwargs): # noqa: E501
  111. """Get a single contract # noqa: E501
  112. This method makes a synchronous HTTP request by default. To make an
  113. asynchronous HTTP request, please pass async_req=True
  114. >>> thread = api.get_futures_contract(settle, contract, async_req=True)
  115. >>> result = thread.get()
  116. :param bool async_req: execute request asynchronously
  117. :param str settle: Settle currency (required)
  118. :param str contract: Futures contract (required)
  119. :param _preload_content: if False, the urllib3.HTTPResponse object will
  120. be returned without reading/decoding response
  121. data. Default is True.
  122. :param _request_timeout: timeout setting for this request. If one
  123. number provided, it will be total request
  124. timeout. It can also be a pair (tuple) of
  125. (connection, read) timeouts.
  126. :rtype: gate_api.Contract
  127. :return: If the method is called asynchronously,
  128. returns the request thread.
  129. """
  130. kwargs['_return_http_data_only'] = True
  131. return self.get_futures_contract_with_http_info(settle, contract, **kwargs) # noqa: E501
  132. def get_futures_contract_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  133. """Get a single contract # noqa: E501
  134. This method makes a synchronous HTTP request by default. To make an
  135. asynchronous HTTP request, please pass async_req=True
  136. >>> thread = api.get_futures_contract_with_http_info(settle, contract, async_req=True)
  137. >>> result = thread.get()
  138. :param bool async_req: execute request asynchronously
  139. :param str settle: Settle currency (required)
  140. :param str contract: Futures contract (required)
  141. :param _return_http_data_only: response data without head status code
  142. and headers
  143. :param _preload_content: if False, the urllib3.HTTPResponse object will
  144. be returned without reading/decoding response
  145. data. Default is True.
  146. :param _request_timeout: timeout setting for this request. If one
  147. number provided, it will be total request
  148. timeout. It can also be a pair (tuple) of
  149. (connection, read) timeouts.
  150. :rtype: tuple(gate_api.Contract, status_code(int), headers(HTTPHeaderDict))
  151. :return: If the method is called asynchronously,
  152. returns the request thread.
  153. """
  154. local_var_params = locals()
  155. all_params = ['settle', 'contract']
  156. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  157. for k, v in six.iteritems(local_var_params['kwargs']):
  158. if k not in all_params:
  159. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_futures_contract" % k)
  160. local_var_params[k] = v
  161. del local_var_params['kwargs']
  162. # verify the required parameter 'settle' is set
  163. if self.api_client.client_side_validation and (
  164. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  165. ): # noqa: E501
  166. raise ApiValueError(
  167. "Missing the required parameter `settle` when calling `get_futures_contract`"
  168. ) # noqa: E501
  169. # verify the required parameter 'contract' is set
  170. if self.api_client.client_side_validation and (
  171. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  172. ): # noqa: E501
  173. raise ApiValueError(
  174. "Missing the required parameter `contract` when calling `get_futures_contract`"
  175. ) # noqa: E501
  176. collection_formats = {}
  177. path_params = {}
  178. if 'settle' in local_var_params:
  179. path_params['settle'] = local_var_params['settle'] # noqa: E501
  180. if 'contract' in local_var_params:
  181. path_params['contract'] = local_var_params['contract'] # noqa: E501
  182. query_params = []
  183. header_params = {}
  184. form_params = []
  185. local_var_files = {}
  186. body_params = None
  187. # HTTP header `Accept`
  188. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  189. # Authentication setting
  190. auth_settings = [] # noqa: E501
  191. return self.api_client.call_api(
  192. '/futures/{settle}/contracts/{contract}',
  193. 'GET',
  194. path_params,
  195. query_params,
  196. header_params,
  197. body=body_params,
  198. post_params=form_params,
  199. files=local_var_files,
  200. response_type='Contract', # noqa: E501
  201. auth_settings=auth_settings,
  202. async_req=local_var_params.get('async_req'),
  203. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  204. _preload_content=local_var_params.get('_preload_content', True),
  205. _request_timeout=local_var_params.get('_request_timeout'),
  206. collection_formats=collection_formats,
  207. )
  208. def list_futures_order_book(self, settle, contract, **kwargs): # noqa: E501
  209. """Futures order book # noqa: E501
  210. Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501
  211. This method makes a synchronous HTTP request by default. To make an
  212. asynchronous HTTP request, please pass async_req=True
  213. >>> thread = api.list_futures_order_book(settle, contract, async_req=True)
  214. >>> result = thread.get()
  215. :param bool async_req: execute request asynchronously
  216. :param str settle: Settle currency (required)
  217. :param str contract: Futures contract (required)
  218. :param str interval: Order depth. 0 means no aggregation is applied. default to 0
  219. :param int limit: Maximum number of order depth data in asks or bids
  220. :param bool with_id: Whether the order book update ID will be returned. This ID increases by 1 on every order book update
  221. :param _preload_content: if False, the urllib3.HTTPResponse object will
  222. be returned without reading/decoding response
  223. data. Default is True.
  224. :param _request_timeout: timeout setting for this request. If one
  225. number provided, it will be total request
  226. timeout. It can also be a pair (tuple) of
  227. (connection, read) timeouts.
  228. :rtype: gate_api.FuturesOrderBook
  229. :return: If the method is called asynchronously,
  230. returns the request thread.
  231. """
  232. kwargs['_return_http_data_only'] = True
  233. return self.list_futures_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501
  234. def list_futures_order_book_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  235. """Futures order book # noqa: E501
  236. Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501
  237. This method makes a synchronous HTTP request by default. To make an
  238. asynchronous HTTP request, please pass async_req=True
  239. >>> thread = api.list_futures_order_book_with_http_info(settle, contract, async_req=True)
  240. >>> result = thread.get()
  241. :param bool async_req: execute request asynchronously
  242. :param str settle: Settle currency (required)
  243. :param str contract: Futures contract (required)
  244. :param str interval: Order depth. 0 means no aggregation is applied. default to 0
  245. :param int limit: Maximum number of order depth data in asks or bids
  246. :param bool with_id: Whether the order book update ID will be returned. This ID increases by 1 on every order book update
  247. :param _return_http_data_only: response data without head status code
  248. and headers
  249. :param _preload_content: if False, the urllib3.HTTPResponse object will
  250. be returned without reading/decoding response
  251. data. Default is True.
  252. :param _request_timeout: timeout setting for this request. If one
  253. number provided, it will be total request
  254. timeout. It can also be a pair (tuple) of
  255. (connection, read) timeouts.
  256. :rtype: tuple(gate_api.FuturesOrderBook, status_code(int), headers(HTTPHeaderDict))
  257. :return: If the method is called asynchronously,
  258. returns the request thread.
  259. """
  260. local_var_params = locals()
  261. all_params = ['settle', 'contract', 'interval', 'limit', 'with_id']
  262. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  263. for k, v in six.iteritems(local_var_params['kwargs']):
  264. if k not in all_params:
  265. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_order_book" % k)
  266. local_var_params[k] = v
  267. del local_var_params['kwargs']
  268. # verify the required parameter 'settle' is set
  269. if self.api_client.client_side_validation and (
  270. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  271. ): # noqa: E501
  272. raise ApiValueError(
  273. "Missing the required parameter `settle` when calling `list_futures_order_book`"
  274. ) # noqa: E501
  275. # verify the required parameter 'contract' is set
  276. if self.api_client.client_side_validation and (
  277. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  278. ): # noqa: E501
  279. raise ApiValueError(
  280. "Missing the required parameter `contract` when calling `list_futures_order_book`"
  281. ) # noqa: E501
  282. if (
  283. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 50
  284. ): # noqa: E501
  285. raise ApiValueError(
  286. "Invalid value for parameter `limit` when calling `list_futures_order_book`, must be a value less than or equal to `50`"
  287. ) # noqa: E501
  288. if (
  289. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  290. ): # noqa: E501
  291. raise ApiValueError(
  292. "Invalid value for parameter `limit` when calling `list_futures_order_book`, must be a value greater than or equal to `1`"
  293. ) # noqa: E501
  294. collection_formats = {}
  295. path_params = {}
  296. if 'settle' in local_var_params:
  297. path_params['settle'] = local_var_params['settle'] # noqa: E501
  298. query_params = []
  299. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  300. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  301. if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501
  302. query_params.append(('interval', local_var_params['interval'])) # noqa: E501
  303. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  304. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  305. if 'with_id' in local_var_params and local_var_params['with_id'] is not None: # noqa: E501
  306. query_params.append(('with_id', local_var_params['with_id'])) # noqa: E501
  307. header_params = {}
  308. form_params = []
  309. local_var_files = {}
  310. body_params = None
  311. # HTTP header `Accept`
  312. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  313. # Authentication setting
  314. auth_settings = [] # noqa: E501
  315. return self.api_client.call_api(
  316. '/futures/{settle}/order_book',
  317. 'GET',
  318. path_params,
  319. query_params,
  320. header_params,
  321. body=body_params,
  322. post_params=form_params,
  323. files=local_var_files,
  324. response_type='FuturesOrderBook', # noqa: E501
  325. auth_settings=auth_settings,
  326. async_req=local_var_params.get('async_req'),
  327. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  328. _preload_content=local_var_params.get('_preload_content', True),
  329. _request_timeout=local_var_params.get('_request_timeout'),
  330. collection_formats=collection_formats,
  331. )
  332. def list_futures_trades(self, settle, contract, **kwargs): # noqa: E501
  333. """Futures trading history # noqa: E501
  334. This method makes a synchronous HTTP request by default. To make an
  335. asynchronous HTTP request, please pass async_req=True
  336. >>> thread = api.list_futures_trades(settle, contract, async_req=True)
  337. >>> result = thread.get()
  338. :param bool async_req: execute request asynchronously
  339. :param str settle: Settle currency (required)
  340. :param str contract: Futures contract (required)
  341. :param int limit: Maximum number of records to be returned in a single list
  342. :param int offset: List offset, starting from 0
  343. :param str last_id: Specify the starting point for this list based on a previously retrieved id This parameter is deprecated. Use `from` and `to` instead to limit time range
  344. :param int _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned.
  345. :param int to: Specify end time in Unix seconds, default to current time
  346. :param _preload_content: if False, the urllib3.HTTPResponse object will
  347. be returned without reading/decoding response
  348. data. Default is True.
  349. :param _request_timeout: timeout setting for this request. If one
  350. number provided, it will be total request
  351. timeout. It can also be a pair (tuple) of
  352. (connection, read) timeouts.
  353. :rtype: list[gate_api.FuturesTrade]
  354. :return: If the method is called asynchronously,
  355. returns the request thread.
  356. """
  357. kwargs['_return_http_data_only'] = True
  358. return self.list_futures_trades_with_http_info(settle, contract, **kwargs) # noqa: E501
  359. def list_futures_trades_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  360. """Futures trading history # noqa: E501
  361. This method makes a synchronous HTTP request by default. To make an
  362. asynchronous HTTP request, please pass async_req=True
  363. >>> thread = api.list_futures_trades_with_http_info(settle, contract, async_req=True)
  364. >>> result = thread.get()
  365. :param bool async_req: execute request asynchronously
  366. :param str settle: Settle currency (required)
  367. :param str contract: Futures contract (required)
  368. :param int limit: Maximum number of records to be returned in a single list
  369. :param int offset: List offset, starting from 0
  370. :param str last_id: Specify the starting point for this list based on a previously retrieved id This parameter is deprecated. Use `from` and `to` instead to limit time range
  371. :param int _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned.
  372. :param int to: Specify end time in Unix seconds, default to current time
  373. :param _return_http_data_only: response data without head status code
  374. and headers
  375. :param _preload_content: if False, the urllib3.HTTPResponse object will
  376. be returned without reading/decoding response
  377. data. Default is True.
  378. :param _request_timeout: timeout setting for this request. If one
  379. number provided, it will be total request
  380. timeout. It can also be a pair (tuple) of
  381. (connection, read) timeouts.
  382. :rtype: tuple(list[gate_api.FuturesTrade], status_code(int), headers(HTTPHeaderDict))
  383. :return: If the method is called asynchronously,
  384. returns the request thread.
  385. """
  386. local_var_params = locals()
  387. all_params = ['settle', 'contract', 'limit', 'offset', 'last_id', '_from', 'to']
  388. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  389. for k, v in six.iteritems(local_var_params['kwargs']):
  390. if k not in all_params:
  391. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_trades" % k)
  392. local_var_params[k] = v
  393. del local_var_params['kwargs']
  394. # verify the required parameter 'settle' is set
  395. if self.api_client.client_side_validation and (
  396. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  397. ): # noqa: E501
  398. raise ApiValueError(
  399. "Missing the required parameter `settle` when calling `list_futures_trades`"
  400. ) # noqa: E501
  401. # verify the required parameter 'contract' is set
  402. if self.api_client.client_side_validation and (
  403. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  404. ): # noqa: E501
  405. raise ApiValueError(
  406. "Missing the required parameter `contract` when calling `list_futures_trades`"
  407. ) # noqa: E501
  408. if (
  409. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  410. ): # noqa: E501
  411. raise ApiValueError(
  412. "Invalid value for parameter `limit` when calling `list_futures_trades`, must be a value less than or equal to `1000`"
  413. ) # noqa: E501
  414. if (
  415. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  416. ): # noqa: E501
  417. raise ApiValueError(
  418. "Invalid value for parameter `limit` when calling `list_futures_trades`, must be a value greater than or equal to `1`"
  419. ) # noqa: E501
  420. if (
  421. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  422. ): # noqa: E501
  423. raise ApiValueError(
  424. "Invalid value for parameter `offset` when calling `list_futures_trades`, must be a value greater than or equal to `0`"
  425. ) # noqa: E501
  426. collection_formats = {}
  427. path_params = {}
  428. if 'settle' in local_var_params:
  429. path_params['settle'] = local_var_params['settle'] # noqa: E501
  430. query_params = []
  431. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  432. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  433. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  434. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  435. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  436. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  437. if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501
  438. query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501
  439. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  440. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  441. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  442. query_params.append(('to', local_var_params['to'])) # noqa: E501
  443. header_params = {}
  444. form_params = []
  445. local_var_files = {}
  446. body_params = None
  447. # HTTP header `Accept`
  448. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  449. # Authentication setting
  450. auth_settings = [] # noqa: E501
  451. return self.api_client.call_api(
  452. '/futures/{settle}/trades',
  453. 'GET',
  454. path_params,
  455. query_params,
  456. header_params,
  457. body=body_params,
  458. post_params=form_params,
  459. files=local_var_files,
  460. response_type='list[FuturesTrade]', # noqa: E501
  461. auth_settings=auth_settings,
  462. async_req=local_var_params.get('async_req'),
  463. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  464. _preload_content=local_var_params.get('_preload_content', True),
  465. _request_timeout=local_var_params.get('_request_timeout'),
  466. collection_formats=collection_formats,
  467. )
  468. def list_futures_candlesticks(self, settle, contract, **kwargs): # noqa: E501
  469. """Get futures candlesticks # noqa: E501
  470. Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501
  471. This method makes a synchronous HTTP request by default. To make an
  472. asynchronous HTTP request, please pass async_req=True
  473. >>> thread = api.list_futures_candlesticks(settle, contract, async_req=True)
  474. >>> result = thread.get()
  475. :param bool async_req: execute request asynchronously
  476. :param str settle: Settle currency (required)
  477. :param str contract: Futures contract (required)
  478. :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  479. :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  480. :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.
  481. :param str interval: Interval time between data points. Note that `1w` means natual week(Mon-Sun), while `7d` means every 7d since unix 0
  482. :param _preload_content: if False, the urllib3.HTTPResponse object will
  483. be returned without reading/decoding response
  484. data. Default is True.
  485. :param _request_timeout: timeout setting for this request. If one
  486. number provided, it will be total request
  487. timeout. It can also be a pair (tuple) of
  488. (connection, read) timeouts.
  489. :rtype: list[gate_api.FuturesCandlestick]
  490. :return: If the method is called asynchronously,
  491. returns the request thread.
  492. """
  493. kwargs['_return_http_data_only'] = True
  494. return self.list_futures_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501
  495. def list_futures_candlesticks_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  496. """Get futures candlesticks # noqa: E501
  497. Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501
  498. This method makes a synchronous HTTP request by default. To make an
  499. asynchronous HTTP request, please pass async_req=True
  500. >>> thread = api.list_futures_candlesticks_with_http_info(settle, contract, async_req=True)
  501. >>> result = thread.get()
  502. :param bool async_req: execute request asynchronously
  503. :param str settle: Settle currency (required)
  504. :param str contract: Futures contract (required)
  505. :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  506. :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  507. :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.
  508. :param str interval: Interval time between data points. Note that `1w` means natual week(Mon-Sun), while `7d` means every 7d since unix 0
  509. :param _return_http_data_only: response data without head status code
  510. and headers
  511. :param _preload_content: if False, the urllib3.HTTPResponse object will
  512. be returned without reading/decoding response
  513. data. Default is True.
  514. :param _request_timeout: timeout setting for this request. If one
  515. number provided, it will be total request
  516. timeout. It can also be a pair (tuple) of
  517. (connection, read) timeouts.
  518. :rtype: tuple(list[gate_api.FuturesCandlestick], status_code(int), headers(HTTPHeaderDict))
  519. :return: If the method is called asynchronously,
  520. returns the request thread.
  521. """
  522. local_var_params = locals()
  523. all_params = ['settle', 'contract', '_from', 'to', 'limit', 'interval']
  524. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  525. for k, v in six.iteritems(local_var_params['kwargs']):
  526. if k not in all_params:
  527. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_candlesticks" % k)
  528. local_var_params[k] = v
  529. del local_var_params['kwargs']
  530. # verify the required parameter 'settle' is set
  531. if self.api_client.client_side_validation and (
  532. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  533. ): # noqa: E501
  534. raise ApiValueError(
  535. "Missing the required parameter `settle` when calling `list_futures_candlesticks`"
  536. ) # noqa: E501
  537. # verify the required parameter 'contract' is set
  538. if self.api_client.client_side_validation and (
  539. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  540. ): # noqa: E501
  541. raise ApiValueError(
  542. "Missing the required parameter `contract` when calling `list_futures_candlesticks`"
  543. ) # noqa: E501
  544. if (
  545. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 2000
  546. ): # noqa: E501
  547. raise ApiValueError(
  548. "Invalid value for parameter `limit` when calling `list_futures_candlesticks`, must be a value less than or equal to `2000`"
  549. ) # noqa: E501
  550. collection_formats = {}
  551. path_params = {}
  552. if 'settle' in local_var_params:
  553. path_params['settle'] = local_var_params['settle'] # noqa: E501
  554. query_params = []
  555. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  556. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  557. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  558. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  559. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  560. query_params.append(('to', local_var_params['to'])) # noqa: E501
  561. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  562. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  563. if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501
  564. query_params.append(('interval', local_var_params['interval'])) # noqa: E501
  565. header_params = {}
  566. form_params = []
  567. local_var_files = {}
  568. body_params = None
  569. # HTTP header `Accept`
  570. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  571. # Authentication setting
  572. auth_settings = [] # noqa: E501
  573. return self.api_client.call_api(
  574. '/futures/{settle}/candlesticks',
  575. 'GET',
  576. path_params,
  577. query_params,
  578. header_params,
  579. body=body_params,
  580. post_params=form_params,
  581. files=local_var_files,
  582. response_type='list[FuturesCandlestick]', # noqa: E501
  583. auth_settings=auth_settings,
  584. async_req=local_var_params.get('async_req'),
  585. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  586. _preload_content=local_var_params.get('_preload_content', True),
  587. _request_timeout=local_var_params.get('_request_timeout'),
  588. collection_formats=collection_formats,
  589. )
  590. def list_futures_premium_index(self, settle, contract, **kwargs): # noqa: E501
  591. """Premium Index K-Line # noqa: E501
  592. 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
  593. This method makes a synchronous HTTP request by default. To make an
  594. asynchronous HTTP request, please pass async_req=True
  595. >>> thread = api.list_futures_premium_index(settle, contract, async_req=True)
  596. >>> result = thread.get()
  597. :param bool async_req: execute request asynchronously
  598. :param str settle: Settle currency (required)
  599. :param str contract: Futures contract (required)
  600. :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  601. :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  602. :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.
  603. :param str interval: Interval time between data points
  604. :param _preload_content: if False, the urllib3.HTTPResponse object will
  605. be returned without reading/decoding response
  606. data. Default is True.
  607. :param _request_timeout: timeout setting for this request. If one
  608. number provided, it will be total request
  609. timeout. It can also be a pair (tuple) of
  610. (connection, read) timeouts.
  611. :rtype: list[gate_api.FuturesPremiumIndex]
  612. :return: If the method is called asynchronously,
  613. returns the request thread.
  614. """
  615. kwargs['_return_http_data_only'] = True
  616. return self.list_futures_premium_index_with_http_info(settle, contract, **kwargs) # noqa: E501
  617. def list_futures_premium_index_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  618. """Premium Index K-Line # noqa: E501
  619. 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
  620. This method makes a synchronous HTTP request by default. To make an
  621. asynchronous HTTP request, please pass async_req=True
  622. >>> thread = api.list_futures_premium_index_with_http_info(settle, contract, async_req=True)
  623. >>> result = thread.get()
  624. :param bool async_req: execute request asynchronously
  625. :param str settle: Settle currency (required)
  626. :param str contract: Futures contract (required)
  627. :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  628. :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  629. :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.
  630. :param str interval: Interval time between data points
  631. :param _return_http_data_only: response data without head status code
  632. and headers
  633. :param _preload_content: if False, the urllib3.HTTPResponse object will
  634. be returned without reading/decoding response
  635. data. Default is True.
  636. :param _request_timeout: timeout setting for this request. If one
  637. number provided, it will be total request
  638. timeout. It can also be a pair (tuple) of
  639. (connection, read) timeouts.
  640. :rtype: tuple(list[gate_api.FuturesPremiumIndex], status_code(int), headers(HTTPHeaderDict))
  641. :return: If the method is called asynchronously,
  642. returns the request thread.
  643. """
  644. local_var_params = locals()
  645. all_params = ['settle', 'contract', '_from', 'to', 'limit', 'interval']
  646. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  647. for k, v in six.iteritems(local_var_params['kwargs']):
  648. if k not in all_params:
  649. raise ApiTypeError(
  650. "Got an unexpected keyword argument '%s'" " to method list_futures_premium_index" % k
  651. )
  652. local_var_params[k] = v
  653. del local_var_params['kwargs']
  654. # verify the required parameter 'settle' is set
  655. if self.api_client.client_side_validation and (
  656. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  657. ): # noqa: E501
  658. raise ApiValueError(
  659. "Missing the required parameter `settle` when calling `list_futures_premium_index`"
  660. ) # noqa: E501
  661. # verify the required parameter 'contract' is set
  662. if self.api_client.client_side_validation and (
  663. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  664. ): # noqa: E501
  665. raise ApiValueError(
  666. "Missing the required parameter `contract` when calling `list_futures_premium_index`"
  667. ) # noqa: E501
  668. if (
  669. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 2000
  670. ): # noqa: E501
  671. raise ApiValueError(
  672. "Invalid value for parameter `limit` when calling `list_futures_premium_index`, must be a value less than or equal to `2000`"
  673. ) # noqa: E501
  674. collection_formats = {}
  675. path_params = {}
  676. if 'settle' in local_var_params:
  677. path_params['settle'] = local_var_params['settle'] # noqa: E501
  678. query_params = []
  679. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  680. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  681. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  682. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  683. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  684. query_params.append(('to', local_var_params['to'])) # noqa: E501
  685. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  686. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  687. if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501
  688. query_params.append(('interval', local_var_params['interval'])) # noqa: E501
  689. header_params = {}
  690. form_params = []
  691. local_var_files = {}
  692. body_params = None
  693. # HTTP header `Accept`
  694. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  695. # Authentication setting
  696. auth_settings = [] # noqa: E501
  697. return self.api_client.call_api(
  698. '/futures/{settle}/premium_index',
  699. 'GET',
  700. path_params,
  701. query_params,
  702. header_params,
  703. body=body_params,
  704. post_params=form_params,
  705. files=local_var_files,
  706. response_type='list[FuturesPremiumIndex]', # noqa: E501
  707. auth_settings=auth_settings,
  708. async_req=local_var_params.get('async_req'),
  709. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  710. _preload_content=local_var_params.get('_preload_content', True),
  711. _request_timeout=local_var_params.get('_request_timeout'),
  712. collection_formats=collection_formats,
  713. )
  714. def list_futures_tickers(self, settle, **kwargs): # noqa: E501
  715. """List futures tickers # noqa: E501
  716. This method makes a synchronous HTTP request by default. To make an
  717. asynchronous HTTP request, please pass async_req=True
  718. >>> thread = api.list_futures_tickers(settle, async_req=True)
  719. >>> result = thread.get()
  720. :param bool async_req: execute request asynchronously
  721. :param str settle: Settle currency (required)
  722. :param str contract: Futures contract, return related data only if specified
  723. :param _preload_content: if False, the urllib3.HTTPResponse object will
  724. be returned without reading/decoding response
  725. data. Default is True.
  726. :param _request_timeout: timeout setting for this request. If one
  727. number provided, it will be total request
  728. timeout. It can also be a pair (tuple) of
  729. (connection, read) timeouts.
  730. :rtype: list[gate_api.FuturesTicker]
  731. :return: If the method is called asynchronously,
  732. returns the request thread.
  733. """
  734. kwargs['_return_http_data_only'] = True
  735. return self.list_futures_tickers_with_http_info(settle, **kwargs) # noqa: E501
  736. def list_futures_tickers_with_http_info(self, settle, **kwargs): # noqa: E501
  737. """List futures tickers # noqa: E501
  738. This method makes a synchronous HTTP request by default. To make an
  739. asynchronous HTTP request, please pass async_req=True
  740. >>> thread = api.list_futures_tickers_with_http_info(settle, async_req=True)
  741. >>> result = thread.get()
  742. :param bool async_req: execute request asynchronously
  743. :param str settle: Settle currency (required)
  744. :param str contract: Futures contract, return related data only if specified
  745. :param _return_http_data_only: response data without head status code
  746. and headers
  747. :param _preload_content: if False, the urllib3.HTTPResponse object will
  748. be returned without reading/decoding response
  749. data. Default is True.
  750. :param _request_timeout: timeout setting for this request. If one
  751. number provided, it will be total request
  752. timeout. It can also be a pair (tuple) of
  753. (connection, read) timeouts.
  754. :rtype: tuple(list[gate_api.FuturesTicker], status_code(int), headers(HTTPHeaderDict))
  755. :return: If the method is called asynchronously,
  756. returns the request thread.
  757. """
  758. local_var_params = locals()
  759. all_params = ['settle', 'contract']
  760. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  761. for k, v in six.iteritems(local_var_params['kwargs']):
  762. if k not in all_params:
  763. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_tickers" % k)
  764. local_var_params[k] = v
  765. del local_var_params['kwargs']
  766. # verify the required parameter 'settle' is set
  767. if self.api_client.client_side_validation and (
  768. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  769. ): # noqa: E501
  770. raise ApiValueError(
  771. "Missing the required parameter `settle` when calling `list_futures_tickers`"
  772. ) # noqa: E501
  773. collection_formats = {}
  774. path_params = {}
  775. if 'settle' in local_var_params:
  776. path_params['settle'] = local_var_params['settle'] # noqa: E501
  777. query_params = []
  778. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  779. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  780. header_params = {}
  781. form_params = []
  782. local_var_files = {}
  783. body_params = None
  784. # HTTP header `Accept`
  785. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  786. # Authentication setting
  787. auth_settings = [] # noqa: E501
  788. return self.api_client.call_api(
  789. '/futures/{settle}/tickers',
  790. 'GET',
  791. path_params,
  792. query_params,
  793. header_params,
  794. body=body_params,
  795. post_params=form_params,
  796. files=local_var_files,
  797. response_type='list[FuturesTicker]', # noqa: E501
  798. auth_settings=auth_settings,
  799. async_req=local_var_params.get('async_req'),
  800. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  801. _preload_content=local_var_params.get('_preload_content', True),
  802. _request_timeout=local_var_params.get('_request_timeout'),
  803. collection_formats=collection_formats,
  804. )
  805. def list_futures_funding_rate_history(self, settle, contract, **kwargs): # noqa: E501
  806. """Funding rate history # noqa: E501
  807. This method makes a synchronous HTTP request by default. To make an
  808. asynchronous HTTP request, please pass async_req=True
  809. >>> thread = api.list_futures_funding_rate_history(settle, contract, async_req=True)
  810. >>> result = thread.get()
  811. :param bool async_req: execute request asynchronously
  812. :param str settle: Settle currency (required)
  813. :param str contract: Futures contract (required)
  814. :param int limit: Maximum number of records to be returned in a single list
  815. :param _preload_content: if False, the urllib3.HTTPResponse object will
  816. be returned without reading/decoding response
  817. data. Default is True.
  818. :param _request_timeout: timeout setting for this request. If one
  819. number provided, it will be total request
  820. timeout. It can also be a pair (tuple) of
  821. (connection, read) timeouts.
  822. :rtype: list[gate_api.FundingRateRecord]
  823. :return: If the method is called asynchronously,
  824. returns the request thread.
  825. """
  826. kwargs['_return_http_data_only'] = True
  827. return self.list_futures_funding_rate_history_with_http_info(settle, contract, **kwargs) # noqa: E501
  828. def list_futures_funding_rate_history_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  829. """Funding rate history # noqa: E501
  830. This method makes a synchronous HTTP request by default. To make an
  831. asynchronous HTTP request, please pass async_req=True
  832. >>> thread = api.list_futures_funding_rate_history_with_http_info(settle, contract, async_req=True)
  833. >>> result = thread.get()
  834. :param bool async_req: execute request asynchronously
  835. :param str settle: Settle currency (required)
  836. :param str contract: Futures contract (required)
  837. :param int limit: Maximum number of records to be returned in a single list
  838. :param _return_http_data_only: response data without head status code
  839. and headers
  840. :param _preload_content: if False, the urllib3.HTTPResponse object will
  841. be returned without reading/decoding response
  842. data. Default is True.
  843. :param _request_timeout: timeout setting for this request. If one
  844. number provided, it will be total request
  845. timeout. It can also be a pair (tuple) of
  846. (connection, read) timeouts.
  847. :rtype: tuple(list[gate_api.FundingRateRecord], status_code(int), headers(HTTPHeaderDict))
  848. :return: If the method is called asynchronously,
  849. returns the request thread.
  850. """
  851. local_var_params = locals()
  852. all_params = ['settle', 'contract', 'limit']
  853. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  854. for k, v in six.iteritems(local_var_params['kwargs']):
  855. if k not in all_params:
  856. raise ApiTypeError(
  857. "Got an unexpected keyword argument '%s'" " to method list_futures_funding_rate_history" % k
  858. )
  859. local_var_params[k] = v
  860. del local_var_params['kwargs']
  861. # verify the required parameter 'settle' is set
  862. if self.api_client.client_side_validation and (
  863. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  864. ): # noqa: E501
  865. raise ApiValueError(
  866. "Missing the required parameter `settle` when calling `list_futures_funding_rate_history`"
  867. ) # noqa: E501
  868. # verify the required parameter 'contract' is set
  869. if self.api_client.client_side_validation and (
  870. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  871. ): # noqa: E501
  872. raise ApiValueError(
  873. "Missing the required parameter `contract` when calling `list_futures_funding_rate_history`"
  874. ) # noqa: E501
  875. if (
  876. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  877. ): # noqa: E501
  878. raise ApiValueError(
  879. "Invalid value for parameter `limit` when calling `list_futures_funding_rate_history`, must be a value less than or equal to `1000`"
  880. ) # noqa: E501
  881. if (
  882. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  883. ): # noqa: E501
  884. raise ApiValueError(
  885. "Invalid value for parameter `limit` when calling `list_futures_funding_rate_history`, must be a value greater than or equal to `1`"
  886. ) # noqa: E501
  887. collection_formats = {}
  888. path_params = {}
  889. if 'settle' in local_var_params:
  890. path_params['settle'] = local_var_params['settle'] # noqa: E501
  891. query_params = []
  892. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  893. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  894. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  895. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  896. header_params = {}
  897. form_params = []
  898. local_var_files = {}
  899. body_params = None
  900. # HTTP header `Accept`
  901. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  902. # Authentication setting
  903. auth_settings = [] # noqa: E501
  904. return self.api_client.call_api(
  905. '/futures/{settle}/funding_rate',
  906. 'GET',
  907. path_params,
  908. query_params,
  909. header_params,
  910. body=body_params,
  911. post_params=form_params,
  912. files=local_var_files,
  913. response_type='list[FundingRateRecord]', # noqa: E501
  914. auth_settings=auth_settings,
  915. async_req=local_var_params.get('async_req'),
  916. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  917. _preload_content=local_var_params.get('_preload_content', True),
  918. _request_timeout=local_var_params.get('_request_timeout'),
  919. collection_formats=collection_formats,
  920. )
  921. def list_futures_insurance_ledger(self, settle, **kwargs): # noqa: E501
  922. """Futures insurance balance history # noqa: E501
  923. This method makes a synchronous HTTP request by default. To make an
  924. asynchronous HTTP request, please pass async_req=True
  925. >>> thread = api.list_futures_insurance_ledger(settle, async_req=True)
  926. >>> result = thread.get()
  927. :param bool async_req: execute request asynchronously
  928. :param str settle: Settle currency (required)
  929. :param int limit: Maximum number of records to be returned in a single list
  930. :param _preload_content: if False, the urllib3.HTTPResponse object will
  931. be returned without reading/decoding response
  932. data. Default is True.
  933. :param _request_timeout: timeout setting for this request. If one
  934. number provided, it will be total request
  935. timeout. It can also be a pair (tuple) of
  936. (connection, read) timeouts.
  937. :rtype: list[gate_api.InsuranceRecord]
  938. :return: If the method is called asynchronously,
  939. returns the request thread.
  940. """
  941. kwargs['_return_http_data_only'] = True
  942. return self.list_futures_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501
  943. def list_futures_insurance_ledger_with_http_info(self, settle, **kwargs): # noqa: E501
  944. """Futures insurance balance history # noqa: E501
  945. This method makes a synchronous HTTP request by default. To make an
  946. asynchronous HTTP request, please pass async_req=True
  947. >>> thread = api.list_futures_insurance_ledger_with_http_info(settle, async_req=True)
  948. >>> result = thread.get()
  949. :param bool async_req: execute request asynchronously
  950. :param str settle: Settle currency (required)
  951. :param int limit: Maximum number of records to be returned in a single list
  952. :param _return_http_data_only: response data without head status code
  953. and headers
  954. :param _preload_content: if False, the urllib3.HTTPResponse object will
  955. be returned without reading/decoding response
  956. data. Default is True.
  957. :param _request_timeout: timeout setting for this request. If one
  958. number provided, it will be total request
  959. timeout. It can also be a pair (tuple) of
  960. (connection, read) timeouts.
  961. :rtype: tuple(list[gate_api.InsuranceRecord], status_code(int), headers(HTTPHeaderDict))
  962. :return: If the method is called asynchronously,
  963. returns the request thread.
  964. """
  965. local_var_params = locals()
  966. all_params = ['settle', 'limit']
  967. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  968. for k, v in six.iteritems(local_var_params['kwargs']):
  969. if k not in all_params:
  970. raise ApiTypeError(
  971. "Got an unexpected keyword argument '%s'" " to method list_futures_insurance_ledger" % k
  972. )
  973. local_var_params[k] = v
  974. del local_var_params['kwargs']
  975. # verify the required parameter 'settle' is set
  976. if self.api_client.client_side_validation and (
  977. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  978. ): # noqa: E501
  979. raise ApiValueError(
  980. "Missing the required parameter `settle` when calling `list_futures_insurance_ledger`"
  981. ) # noqa: E501
  982. if (
  983. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  984. ): # noqa: E501
  985. raise ApiValueError(
  986. "Invalid value for parameter `limit` when calling `list_futures_insurance_ledger`, must be a value less than or equal to `1000`"
  987. ) # noqa: E501
  988. if (
  989. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  990. ): # noqa: E501
  991. raise ApiValueError(
  992. "Invalid value for parameter `limit` when calling `list_futures_insurance_ledger`, must be a value greater than or equal to `1`"
  993. ) # noqa: E501
  994. collection_formats = {}
  995. path_params = {}
  996. if 'settle' in local_var_params:
  997. path_params['settle'] = local_var_params['settle'] # noqa: E501
  998. query_params = []
  999. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  1000. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  1001. header_params = {}
  1002. form_params = []
  1003. local_var_files = {}
  1004. body_params = None
  1005. # HTTP header `Accept`
  1006. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1007. # Authentication setting
  1008. auth_settings = [] # noqa: E501
  1009. return self.api_client.call_api(
  1010. '/futures/{settle}/insurance',
  1011. 'GET',
  1012. path_params,
  1013. query_params,
  1014. header_params,
  1015. body=body_params,
  1016. post_params=form_params,
  1017. files=local_var_files,
  1018. response_type='list[InsuranceRecord]', # noqa: E501
  1019. auth_settings=auth_settings,
  1020. async_req=local_var_params.get('async_req'),
  1021. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1022. _preload_content=local_var_params.get('_preload_content', True),
  1023. _request_timeout=local_var_params.get('_request_timeout'),
  1024. collection_formats=collection_formats,
  1025. )
  1026. def list_contract_stats(self, settle, contract, **kwargs): # noqa: E501
  1027. """Futures stats # noqa: E501
  1028. This method makes a synchronous HTTP request by default. To make an
  1029. asynchronous HTTP request, please pass async_req=True
  1030. >>> thread = api.list_contract_stats(settle, contract, async_req=True)
  1031. >>> result = thread.get()
  1032. :param bool async_req: execute request asynchronously
  1033. :param str settle: Settle currency (required)
  1034. :param str contract: Futures contract (required)
  1035. :param int _from: Start timestamp
  1036. :param str interval:
  1037. :param int limit:
  1038. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1039. be returned without reading/decoding response
  1040. data. Default is True.
  1041. :param _request_timeout: timeout setting for this request. If one
  1042. number provided, it will be total request
  1043. timeout. It can also be a pair (tuple) of
  1044. (connection, read) timeouts.
  1045. :rtype: list[gate_api.ContractStat]
  1046. :return: If the method is called asynchronously,
  1047. returns the request thread.
  1048. """
  1049. kwargs['_return_http_data_only'] = True
  1050. return self.list_contract_stats_with_http_info(settle, contract, **kwargs) # noqa: E501
  1051. def list_contract_stats_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  1052. """Futures stats # noqa: E501
  1053. This method makes a synchronous HTTP request by default. To make an
  1054. asynchronous HTTP request, please pass async_req=True
  1055. >>> thread = api.list_contract_stats_with_http_info(settle, contract, async_req=True)
  1056. >>> result = thread.get()
  1057. :param bool async_req: execute request asynchronously
  1058. :param str settle: Settle currency (required)
  1059. :param str contract: Futures contract (required)
  1060. :param int _from: Start timestamp
  1061. :param str interval:
  1062. :param int limit:
  1063. :param _return_http_data_only: response data without head status code
  1064. and headers
  1065. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1066. be returned without reading/decoding response
  1067. data. Default is True.
  1068. :param _request_timeout: timeout setting for this request. If one
  1069. number provided, it will be total request
  1070. timeout. It can also be a pair (tuple) of
  1071. (connection, read) timeouts.
  1072. :rtype: tuple(list[gate_api.ContractStat], status_code(int), headers(HTTPHeaderDict))
  1073. :return: If the method is called asynchronously,
  1074. returns the request thread.
  1075. """
  1076. local_var_params = locals()
  1077. all_params = ['settle', 'contract', '_from', 'interval', 'limit']
  1078. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1079. for k, v in six.iteritems(local_var_params['kwargs']):
  1080. if k not in all_params:
  1081. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_contract_stats" % k)
  1082. local_var_params[k] = v
  1083. del local_var_params['kwargs']
  1084. # verify the required parameter 'settle' is set
  1085. if self.api_client.client_side_validation and (
  1086. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1087. ): # noqa: E501
  1088. raise ApiValueError(
  1089. "Missing the required parameter `settle` when calling `list_contract_stats`"
  1090. ) # noqa: E501
  1091. # verify the required parameter 'contract' is set
  1092. if self.api_client.client_side_validation and (
  1093. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  1094. ): # noqa: E501
  1095. raise ApiValueError(
  1096. "Missing the required parameter `contract` when calling `list_contract_stats`"
  1097. ) # noqa: E501
  1098. if (
  1099. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 100
  1100. ): # noqa: E501
  1101. raise ApiValueError(
  1102. "Invalid value for parameter `limit` when calling `list_contract_stats`, must be a value less than or equal to `100`"
  1103. ) # noqa: E501
  1104. if (
  1105. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  1106. ): # noqa: E501
  1107. raise ApiValueError(
  1108. "Invalid value for parameter `limit` when calling `list_contract_stats`, must be a value greater than or equal to `1`"
  1109. ) # noqa: E501
  1110. collection_formats = {}
  1111. path_params = {}
  1112. if 'settle' in local_var_params:
  1113. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1114. query_params = []
  1115. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  1116. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  1117. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  1118. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  1119. if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501
  1120. query_params.append(('interval', local_var_params['interval'])) # noqa: E501
  1121. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  1122. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  1123. header_params = {}
  1124. form_params = []
  1125. local_var_files = {}
  1126. body_params = None
  1127. # HTTP header `Accept`
  1128. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1129. # Authentication setting
  1130. auth_settings = [] # noqa: E501
  1131. return self.api_client.call_api(
  1132. '/futures/{settle}/contract_stats',
  1133. 'GET',
  1134. path_params,
  1135. query_params,
  1136. header_params,
  1137. body=body_params,
  1138. post_params=form_params,
  1139. files=local_var_files,
  1140. response_type='list[ContractStat]', # noqa: E501
  1141. auth_settings=auth_settings,
  1142. async_req=local_var_params.get('async_req'),
  1143. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1144. _preload_content=local_var_params.get('_preload_content', True),
  1145. _request_timeout=local_var_params.get('_request_timeout'),
  1146. collection_formats=collection_formats,
  1147. )
  1148. def get_index_constituents(self, settle, index, **kwargs): # noqa: E501
  1149. """Get index constituents # noqa: E501
  1150. This method makes a synchronous HTTP request by default. To make an
  1151. asynchronous HTTP request, please pass async_req=True
  1152. >>> thread = api.get_index_constituents(settle, index, async_req=True)
  1153. >>> result = thread.get()
  1154. :param bool async_req: execute request asynchronously
  1155. :param str settle: Settle currency (required)
  1156. :param str index: Index name (required)
  1157. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1158. be returned without reading/decoding response
  1159. data. Default is True.
  1160. :param _request_timeout: timeout setting for this request. If one
  1161. number provided, it will be total request
  1162. timeout. It can also be a pair (tuple) of
  1163. (connection, read) timeouts.
  1164. :rtype: gate_api.FuturesIndexConstituents
  1165. :return: If the method is called asynchronously,
  1166. returns the request thread.
  1167. """
  1168. kwargs['_return_http_data_only'] = True
  1169. return self.get_index_constituents_with_http_info(settle, index, **kwargs) # noqa: E501
  1170. def get_index_constituents_with_http_info(self, settle, index, **kwargs): # noqa: E501
  1171. """Get index constituents # noqa: E501
  1172. This method makes a synchronous HTTP request by default. To make an
  1173. asynchronous HTTP request, please pass async_req=True
  1174. >>> thread = api.get_index_constituents_with_http_info(settle, index, async_req=True)
  1175. >>> result = thread.get()
  1176. :param bool async_req: execute request asynchronously
  1177. :param str settle: Settle currency (required)
  1178. :param str index: Index name (required)
  1179. :param _return_http_data_only: response data without head status code
  1180. and headers
  1181. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1182. be returned without reading/decoding response
  1183. data. Default is True.
  1184. :param _request_timeout: timeout setting for this request. If one
  1185. number provided, it will be total request
  1186. timeout. It can also be a pair (tuple) of
  1187. (connection, read) timeouts.
  1188. :rtype: tuple(gate_api.FuturesIndexConstituents, status_code(int), headers(HTTPHeaderDict))
  1189. :return: If the method is called asynchronously,
  1190. returns the request thread.
  1191. """
  1192. local_var_params = locals()
  1193. all_params = ['settle', 'index']
  1194. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1195. for k, v in six.iteritems(local_var_params['kwargs']):
  1196. if k not in all_params:
  1197. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_index_constituents" % k)
  1198. local_var_params[k] = v
  1199. del local_var_params['kwargs']
  1200. # verify the required parameter 'settle' is set
  1201. if self.api_client.client_side_validation and (
  1202. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1203. ): # noqa: E501
  1204. raise ApiValueError(
  1205. "Missing the required parameter `settle` when calling `get_index_constituents`"
  1206. ) # noqa: E501
  1207. # verify the required parameter 'index' is set
  1208. if self.api_client.client_side_validation and (
  1209. 'index' not in local_var_params or local_var_params['index'] is None # noqa: E501
  1210. ): # noqa: E501
  1211. raise ApiValueError(
  1212. "Missing the required parameter `index` when calling `get_index_constituents`"
  1213. ) # noqa: E501
  1214. collection_formats = {}
  1215. path_params = {}
  1216. if 'settle' in local_var_params:
  1217. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1218. if 'index' in local_var_params:
  1219. path_params['index'] = local_var_params['index'] # noqa: E501
  1220. query_params = []
  1221. header_params = {}
  1222. form_params = []
  1223. local_var_files = {}
  1224. body_params = None
  1225. # HTTP header `Accept`
  1226. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1227. # Authentication setting
  1228. auth_settings = [] # noqa: E501
  1229. return self.api_client.call_api(
  1230. '/futures/{settle}/index_constituents/{index}',
  1231. 'GET',
  1232. path_params,
  1233. query_params,
  1234. header_params,
  1235. body=body_params,
  1236. post_params=form_params,
  1237. files=local_var_files,
  1238. response_type='FuturesIndexConstituents', # noqa: E501
  1239. auth_settings=auth_settings,
  1240. async_req=local_var_params.get('async_req'),
  1241. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1242. _preload_content=local_var_params.get('_preload_content', True),
  1243. _request_timeout=local_var_params.get('_request_timeout'),
  1244. collection_formats=collection_formats,
  1245. )
  1246. def list_liquidated_orders(self, settle, **kwargs): # noqa: E501
  1247. """Retrieve liquidation history # noqa: E501
  1248. Interval between `from` and `to` cannot exceeds 3600. Some private fields will not be returned in public endpoints. Refer to field description for detail. # noqa: E501
  1249. This method makes a synchronous HTTP request by default. To make an
  1250. asynchronous HTTP request, please pass async_req=True
  1251. >>> thread = api.list_liquidated_orders(settle, async_req=True)
  1252. >>> result = thread.get()
  1253. :param bool async_req: execute request asynchronously
  1254. :param str settle: Settle currency (required)
  1255. :param str contract: Futures contract, return related data only if specified
  1256. :param int _from: Start timestamp
  1257. :param int to: End timestamp
  1258. :param int limit: Maximum number of records to be returned in a single list
  1259. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1260. be returned without reading/decoding response
  1261. data. Default is True.
  1262. :param _request_timeout: timeout setting for this request. If one
  1263. number provided, it will be total request
  1264. timeout. It can also be a pair (tuple) of
  1265. (connection, read) timeouts.
  1266. :rtype: list[gate_api.FuturesLiquidate]
  1267. :return: If the method is called asynchronously,
  1268. returns the request thread.
  1269. """
  1270. kwargs['_return_http_data_only'] = True
  1271. return self.list_liquidated_orders_with_http_info(settle, **kwargs) # noqa: E501
  1272. def list_liquidated_orders_with_http_info(self, settle, **kwargs): # noqa: E501
  1273. """Retrieve liquidation history # noqa: E501
  1274. Interval between `from` and `to` cannot exceeds 3600. Some private fields will not be returned in public endpoints. Refer to field description for detail. # noqa: E501
  1275. This method makes a synchronous HTTP request by default. To make an
  1276. asynchronous HTTP request, please pass async_req=True
  1277. >>> thread = api.list_liquidated_orders_with_http_info(settle, async_req=True)
  1278. >>> result = thread.get()
  1279. :param bool async_req: execute request asynchronously
  1280. :param str settle: Settle currency (required)
  1281. :param str contract: Futures contract, return related data only if specified
  1282. :param int _from: Start timestamp
  1283. :param int to: End timestamp
  1284. :param int limit: Maximum number of records to be returned in a single list
  1285. :param _return_http_data_only: response data without head status code
  1286. and headers
  1287. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1288. be returned without reading/decoding response
  1289. data. Default is True.
  1290. :param _request_timeout: timeout setting for this request. If one
  1291. number provided, it will be total request
  1292. timeout. It can also be a pair (tuple) of
  1293. (connection, read) timeouts.
  1294. :rtype: tuple(list[gate_api.FuturesLiquidate], status_code(int), headers(HTTPHeaderDict))
  1295. :return: If the method is called asynchronously,
  1296. returns the request thread.
  1297. """
  1298. local_var_params = locals()
  1299. all_params = ['settle', 'contract', '_from', 'to', 'limit']
  1300. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1301. for k, v in six.iteritems(local_var_params['kwargs']):
  1302. if k not in all_params:
  1303. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_liquidated_orders" % k)
  1304. local_var_params[k] = v
  1305. del local_var_params['kwargs']
  1306. # verify the required parameter 'settle' is set
  1307. if self.api_client.client_side_validation and (
  1308. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1309. ): # noqa: E501
  1310. raise ApiValueError(
  1311. "Missing the required parameter `settle` when calling `list_liquidated_orders`"
  1312. ) # noqa: E501
  1313. if (
  1314. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  1315. ): # noqa: E501
  1316. raise ApiValueError(
  1317. "Invalid value for parameter `limit` when calling `list_liquidated_orders`, must be a value less than or equal to `1000`"
  1318. ) # noqa: E501
  1319. if (
  1320. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  1321. ): # noqa: E501
  1322. raise ApiValueError(
  1323. "Invalid value for parameter `limit` when calling `list_liquidated_orders`, must be a value greater than or equal to `1`"
  1324. ) # noqa: E501
  1325. collection_formats = {}
  1326. path_params = {}
  1327. if 'settle' in local_var_params:
  1328. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1329. query_params = []
  1330. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  1331. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  1332. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  1333. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  1334. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  1335. query_params.append(('to', local_var_params['to'])) # noqa: E501
  1336. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  1337. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  1338. header_params = {}
  1339. form_params = []
  1340. local_var_files = {}
  1341. body_params = None
  1342. # HTTP header `Accept`
  1343. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1344. # Authentication setting
  1345. auth_settings = [] # noqa: E501
  1346. return self.api_client.call_api(
  1347. '/futures/{settle}/liq_orders',
  1348. 'GET',
  1349. path_params,
  1350. query_params,
  1351. header_params,
  1352. body=body_params,
  1353. post_params=form_params,
  1354. files=local_var_files,
  1355. response_type='list[FuturesLiquidate]', # noqa: E501
  1356. auth_settings=auth_settings,
  1357. async_req=local_var_params.get('async_req'),
  1358. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1359. _preload_content=local_var_params.get('_preload_content', True),
  1360. _request_timeout=local_var_params.get('_request_timeout'),
  1361. collection_formats=collection_formats,
  1362. )
  1363. def list_futures_accounts(self, settle, **kwargs): # noqa: E501
  1364. """Query futures account # noqa: E501
  1365. This method makes a synchronous HTTP request by default. To make an
  1366. asynchronous HTTP request, please pass async_req=True
  1367. >>> thread = api.list_futures_accounts(settle, async_req=True)
  1368. >>> result = thread.get()
  1369. :param bool async_req: execute request asynchronously
  1370. :param str settle: Settle currency (required)
  1371. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1372. be returned without reading/decoding response
  1373. data. Default is True.
  1374. :param _request_timeout: timeout setting for this request. If one
  1375. number provided, it will be total request
  1376. timeout. It can also be a pair (tuple) of
  1377. (connection, read) timeouts.
  1378. :rtype: gate_api.FuturesAccount
  1379. :return: If the method is called asynchronously,
  1380. returns the request thread.
  1381. """
  1382. kwargs['_return_http_data_only'] = True
  1383. return self.list_futures_accounts_with_http_info(settle, **kwargs) # noqa: E501
  1384. def list_futures_accounts_with_http_info(self, settle, **kwargs): # noqa: E501
  1385. """Query futures account # noqa: E501
  1386. This method makes a synchronous HTTP request by default. To make an
  1387. asynchronous HTTP request, please pass async_req=True
  1388. >>> thread = api.list_futures_accounts_with_http_info(settle, async_req=True)
  1389. >>> result = thread.get()
  1390. :param bool async_req: execute request asynchronously
  1391. :param str settle: Settle currency (required)
  1392. :param _return_http_data_only: response data without head status code
  1393. and headers
  1394. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1395. be returned without reading/decoding response
  1396. data. Default is True.
  1397. :param _request_timeout: timeout setting for this request. If one
  1398. number provided, it will be total request
  1399. timeout. It can also be a pair (tuple) of
  1400. (connection, read) timeouts.
  1401. :rtype: tuple(gate_api.FuturesAccount, status_code(int), headers(HTTPHeaderDict))
  1402. :return: If the method is called asynchronously,
  1403. returns the request thread.
  1404. """
  1405. local_var_params = locals()
  1406. all_params = ['settle']
  1407. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1408. for k, v in six.iteritems(local_var_params['kwargs']):
  1409. if k not in all_params:
  1410. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_accounts" % k)
  1411. local_var_params[k] = v
  1412. del local_var_params['kwargs']
  1413. # verify the required parameter 'settle' is set
  1414. if self.api_client.client_side_validation and (
  1415. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1416. ): # noqa: E501
  1417. raise ApiValueError(
  1418. "Missing the required parameter `settle` when calling `list_futures_accounts`"
  1419. ) # noqa: E501
  1420. collection_formats = {}
  1421. path_params = {}
  1422. if 'settle' in local_var_params:
  1423. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1424. query_params = []
  1425. header_params = {}
  1426. form_params = []
  1427. local_var_files = {}
  1428. body_params = None
  1429. # HTTP header `Accept`
  1430. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1431. # Authentication setting
  1432. auth_settings = ['apiv4'] # noqa: E501
  1433. return self.api_client.call_api(
  1434. '/futures/{settle}/accounts',
  1435. 'GET',
  1436. path_params,
  1437. query_params,
  1438. header_params,
  1439. body=body_params,
  1440. post_params=form_params,
  1441. files=local_var_files,
  1442. response_type='FuturesAccount', # noqa: E501
  1443. auth_settings=auth_settings,
  1444. async_req=local_var_params.get('async_req'),
  1445. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1446. _preload_content=local_var_params.get('_preload_content', True),
  1447. _request_timeout=local_var_params.get('_request_timeout'),
  1448. collection_formats=collection_formats,
  1449. )
  1450. def list_futures_account_book(self, settle, **kwargs): # noqa: E501
  1451. """Query account book # noqa: E501
  1452. This method makes a synchronous HTTP request by default. To make an
  1453. asynchronous HTTP request, please pass async_req=True
  1454. >>> thread = api.list_futures_account_book(settle, async_req=True)
  1455. >>> result = thread.get()
  1456. :param bool async_req: execute request asynchronously
  1457. :param str settle: Settle currency (required)
  1458. :param int limit: Maximum number of records to be returned in a single list
  1459. :param int _from: Start timestamp
  1460. :param int to: End timestamp
  1461. :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate
  1462. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1463. be returned without reading/decoding response
  1464. data. Default is True.
  1465. :param _request_timeout: timeout setting for this request. If one
  1466. number provided, it will be total request
  1467. timeout. It can also be a pair (tuple) of
  1468. (connection, read) timeouts.
  1469. :rtype: list[gate_api.FuturesAccountBook]
  1470. :return: If the method is called asynchronously,
  1471. returns the request thread.
  1472. """
  1473. kwargs['_return_http_data_only'] = True
  1474. return self.list_futures_account_book_with_http_info(settle, **kwargs) # noqa: E501
  1475. def list_futures_account_book_with_http_info(self, settle, **kwargs): # noqa: E501
  1476. """Query account book # noqa: E501
  1477. This method makes a synchronous HTTP request by default. To make an
  1478. asynchronous HTTP request, please pass async_req=True
  1479. >>> thread = api.list_futures_account_book_with_http_info(settle, async_req=True)
  1480. >>> result = thread.get()
  1481. :param bool async_req: execute request asynchronously
  1482. :param str settle: Settle currency (required)
  1483. :param int limit: Maximum number of records to be returned in a single list
  1484. :param int _from: Start timestamp
  1485. :param int to: End timestamp
  1486. :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate
  1487. :param _return_http_data_only: response data without head status code
  1488. and headers
  1489. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1490. be returned without reading/decoding response
  1491. data. Default is True.
  1492. :param _request_timeout: timeout setting for this request. If one
  1493. number provided, it will be total request
  1494. timeout. It can also be a pair (tuple) of
  1495. (connection, read) timeouts.
  1496. :rtype: tuple(list[gate_api.FuturesAccountBook], status_code(int), headers(HTTPHeaderDict))
  1497. :return: If the method is called asynchronously,
  1498. returns the request thread.
  1499. """
  1500. local_var_params = locals()
  1501. all_params = ['settle', 'limit', '_from', 'to', 'type']
  1502. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1503. for k, v in six.iteritems(local_var_params['kwargs']):
  1504. if k not in all_params:
  1505. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_account_book" % k)
  1506. local_var_params[k] = v
  1507. del local_var_params['kwargs']
  1508. # verify the required parameter 'settle' is set
  1509. if self.api_client.client_side_validation and (
  1510. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1511. ): # noqa: E501
  1512. raise ApiValueError(
  1513. "Missing the required parameter `settle` when calling `list_futures_account_book`"
  1514. ) # noqa: E501
  1515. if (
  1516. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  1517. ): # noqa: E501
  1518. raise ApiValueError(
  1519. "Invalid value for parameter `limit` when calling `list_futures_account_book`, must be a value less than or equal to `1000`"
  1520. ) # noqa: E501
  1521. if (
  1522. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  1523. ): # noqa: E501
  1524. raise ApiValueError(
  1525. "Invalid value for parameter `limit` when calling `list_futures_account_book`, must be a value greater than or equal to `1`"
  1526. ) # noqa: E501
  1527. collection_formats = {}
  1528. path_params = {}
  1529. if 'settle' in local_var_params:
  1530. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1531. query_params = []
  1532. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  1533. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  1534. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  1535. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  1536. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  1537. query_params.append(('to', local_var_params['to'])) # noqa: E501
  1538. if 'type' in local_var_params and local_var_params['type'] is not None: # noqa: E501
  1539. query_params.append(('type', local_var_params['type'])) # noqa: E501
  1540. header_params = {}
  1541. form_params = []
  1542. local_var_files = {}
  1543. body_params = None
  1544. # HTTP header `Accept`
  1545. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1546. # Authentication setting
  1547. auth_settings = ['apiv4'] # noqa: E501
  1548. return self.api_client.call_api(
  1549. '/futures/{settle}/account_book',
  1550. 'GET',
  1551. path_params,
  1552. query_params,
  1553. header_params,
  1554. body=body_params,
  1555. post_params=form_params,
  1556. files=local_var_files,
  1557. response_type='list[FuturesAccountBook]', # noqa: E501
  1558. auth_settings=auth_settings,
  1559. async_req=local_var_params.get('async_req'),
  1560. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1561. _preload_content=local_var_params.get('_preload_content', True),
  1562. _request_timeout=local_var_params.get('_request_timeout'),
  1563. collection_formats=collection_formats,
  1564. )
  1565. def list_positions(self, settle, **kwargs): # noqa: E501
  1566. """List all positions of a user # noqa: E501
  1567. This method makes a synchronous HTTP request by default. To make an
  1568. asynchronous HTTP request, please pass async_req=True
  1569. >>> thread = api.list_positions(settle, async_req=True)
  1570. >>> result = thread.get()
  1571. :param bool async_req: execute request asynchronously
  1572. :param str settle: Settle currency (required)
  1573. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1574. be returned without reading/decoding response
  1575. data. Default is True.
  1576. :param _request_timeout: timeout setting for this request. If one
  1577. number provided, it will be total request
  1578. timeout. It can also be a pair (tuple) of
  1579. (connection, read) timeouts.
  1580. :rtype: list[gate_api.Position]
  1581. :return: If the method is called asynchronously,
  1582. returns the request thread.
  1583. """
  1584. kwargs['_return_http_data_only'] = True
  1585. return self.list_positions_with_http_info(settle, **kwargs) # noqa: E501
  1586. def list_positions_with_http_info(self, settle, **kwargs): # noqa: E501
  1587. """List all positions of a user # noqa: E501
  1588. This method makes a synchronous HTTP request by default. To make an
  1589. asynchronous HTTP request, please pass async_req=True
  1590. >>> thread = api.list_positions_with_http_info(settle, async_req=True)
  1591. >>> result = thread.get()
  1592. :param bool async_req: execute request asynchronously
  1593. :param str settle: Settle currency (required)
  1594. :param _return_http_data_only: response data without head status code
  1595. and headers
  1596. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1597. be returned without reading/decoding response
  1598. data. Default is True.
  1599. :param _request_timeout: timeout setting for this request. If one
  1600. number provided, it will be total request
  1601. timeout. It can also be a pair (tuple) of
  1602. (connection, read) timeouts.
  1603. :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict))
  1604. :return: If the method is called asynchronously,
  1605. returns the request thread.
  1606. """
  1607. local_var_params = locals()
  1608. all_params = ['settle']
  1609. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1610. for k, v in six.iteritems(local_var_params['kwargs']):
  1611. if k not in all_params:
  1612. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_positions" % k)
  1613. local_var_params[k] = v
  1614. del local_var_params['kwargs']
  1615. # verify the required parameter 'settle' is set
  1616. if self.api_client.client_side_validation and (
  1617. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1618. ): # noqa: E501
  1619. raise ApiValueError("Missing the required parameter `settle` when calling `list_positions`") # noqa: E501
  1620. collection_formats = {}
  1621. path_params = {}
  1622. if 'settle' in local_var_params:
  1623. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1624. query_params = []
  1625. header_params = {}
  1626. form_params = []
  1627. local_var_files = {}
  1628. body_params = None
  1629. # HTTP header `Accept`
  1630. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1631. # Authentication setting
  1632. auth_settings = ['apiv4'] # noqa: E501
  1633. return self.api_client.call_api(
  1634. '/futures/{settle}/positions',
  1635. 'GET',
  1636. path_params,
  1637. query_params,
  1638. header_params,
  1639. body=body_params,
  1640. post_params=form_params,
  1641. files=local_var_files,
  1642. response_type='list[Position]', # noqa: E501
  1643. auth_settings=auth_settings,
  1644. async_req=local_var_params.get('async_req'),
  1645. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1646. _preload_content=local_var_params.get('_preload_content', True),
  1647. _request_timeout=local_var_params.get('_request_timeout'),
  1648. collection_formats=collection_formats,
  1649. )
  1650. def get_position(self, settle, contract, **kwargs): # noqa: E501
  1651. """Get single position # noqa: E501
  1652. This method makes a synchronous HTTP request by default. To make an
  1653. asynchronous HTTP request, please pass async_req=True
  1654. >>> thread = api.get_position(settle, contract, async_req=True)
  1655. >>> result = thread.get()
  1656. :param bool async_req: execute request asynchronously
  1657. :param str settle: Settle currency (required)
  1658. :param str contract: Futures contract (required)
  1659. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1660. be returned without reading/decoding response
  1661. data. Default is True.
  1662. :param _request_timeout: timeout setting for this request. If one
  1663. number provided, it will be total request
  1664. timeout. It can also be a pair (tuple) of
  1665. (connection, read) timeouts.
  1666. :rtype: gate_api.Position
  1667. :return: If the method is called asynchronously,
  1668. returns the request thread.
  1669. """
  1670. kwargs['_return_http_data_only'] = True
  1671. return self.get_position_with_http_info(settle, contract, **kwargs) # noqa: E501
  1672. def get_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  1673. """Get single position # noqa: E501
  1674. This method makes a synchronous HTTP request by default. To make an
  1675. asynchronous HTTP request, please pass async_req=True
  1676. >>> thread = api.get_position_with_http_info(settle, contract, async_req=True)
  1677. >>> result = thread.get()
  1678. :param bool async_req: execute request asynchronously
  1679. :param str settle: Settle currency (required)
  1680. :param str contract: Futures contract (required)
  1681. :param _return_http_data_only: response data without head status code
  1682. and headers
  1683. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1684. be returned without reading/decoding response
  1685. data. Default is True.
  1686. :param _request_timeout: timeout setting for this request. If one
  1687. number provided, it will be total request
  1688. timeout. It can also be a pair (tuple) of
  1689. (connection, read) timeouts.
  1690. :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict))
  1691. :return: If the method is called asynchronously,
  1692. returns the request thread.
  1693. """
  1694. local_var_params = locals()
  1695. all_params = ['settle', 'contract']
  1696. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1697. for k, v in six.iteritems(local_var_params['kwargs']):
  1698. if k not in all_params:
  1699. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_position" % k)
  1700. local_var_params[k] = v
  1701. del local_var_params['kwargs']
  1702. # verify the required parameter 'settle' is set
  1703. if self.api_client.client_side_validation and (
  1704. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1705. ): # noqa: E501
  1706. raise ApiValueError("Missing the required parameter `settle` when calling `get_position`") # noqa: E501
  1707. # verify the required parameter 'contract' is set
  1708. if self.api_client.client_side_validation and (
  1709. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  1710. ): # noqa: E501
  1711. raise ApiValueError("Missing the required parameter `contract` when calling `get_position`") # noqa: E501
  1712. collection_formats = {}
  1713. path_params = {}
  1714. if 'settle' in local_var_params:
  1715. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1716. if 'contract' in local_var_params:
  1717. path_params['contract'] = local_var_params['contract'] # noqa: E501
  1718. query_params = []
  1719. header_params = {}
  1720. form_params = []
  1721. local_var_files = {}
  1722. body_params = None
  1723. # HTTP header `Accept`
  1724. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1725. # Authentication setting
  1726. auth_settings = ['apiv4'] # noqa: E501
  1727. return self.api_client.call_api(
  1728. '/futures/{settle}/positions/{contract}',
  1729. 'GET',
  1730. path_params,
  1731. query_params,
  1732. header_params,
  1733. body=body_params,
  1734. post_params=form_params,
  1735. files=local_var_files,
  1736. response_type='Position', # noqa: E501
  1737. auth_settings=auth_settings,
  1738. async_req=local_var_params.get('async_req'),
  1739. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1740. _preload_content=local_var_params.get('_preload_content', True),
  1741. _request_timeout=local_var_params.get('_request_timeout'),
  1742. collection_formats=collection_formats,
  1743. )
  1744. def update_position_margin(self, settle, contract, change, **kwargs): # noqa: E501
  1745. """Update position margin # noqa: E501
  1746. This method makes a synchronous HTTP request by default. To make an
  1747. asynchronous HTTP request, please pass async_req=True
  1748. >>> thread = api.update_position_margin(settle, contract, change, async_req=True)
  1749. >>> result = thread.get()
  1750. :param bool async_req: execute request asynchronously
  1751. :param str settle: Settle currency (required)
  1752. :param str contract: Futures contract (required)
  1753. :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required)
  1754. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1755. be returned without reading/decoding response
  1756. data. Default is True.
  1757. :param _request_timeout: timeout setting for this request. If one
  1758. number provided, it will be total request
  1759. timeout. It can also be a pair (tuple) of
  1760. (connection, read) timeouts.
  1761. :rtype: gate_api.Position
  1762. :return: If the method is called asynchronously,
  1763. returns the request thread.
  1764. """
  1765. kwargs['_return_http_data_only'] = True
  1766. return self.update_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501
  1767. def update_position_margin_with_http_info(self, settle, contract, change, **kwargs): # noqa: E501
  1768. """Update position margin # noqa: E501
  1769. This method makes a synchronous HTTP request by default. To make an
  1770. asynchronous HTTP request, please pass async_req=True
  1771. >>> thread = api.update_position_margin_with_http_info(settle, contract, change, async_req=True)
  1772. >>> result = thread.get()
  1773. :param bool async_req: execute request asynchronously
  1774. :param str settle: Settle currency (required)
  1775. :param str contract: Futures contract (required)
  1776. :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required)
  1777. :param _return_http_data_only: response data without head status code
  1778. and headers
  1779. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1780. be returned without reading/decoding response
  1781. data. Default is True.
  1782. :param _request_timeout: timeout setting for this request. If one
  1783. number provided, it will be total request
  1784. timeout. It can also be a pair (tuple) of
  1785. (connection, read) timeouts.
  1786. :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict))
  1787. :return: If the method is called asynchronously,
  1788. returns the request thread.
  1789. """
  1790. local_var_params = locals()
  1791. all_params = ['settle', 'contract', 'change']
  1792. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1793. for k, v in six.iteritems(local_var_params['kwargs']):
  1794. if k not in all_params:
  1795. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_position_margin" % k)
  1796. local_var_params[k] = v
  1797. del local_var_params['kwargs']
  1798. # verify the required parameter 'settle' is set
  1799. if self.api_client.client_side_validation and (
  1800. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1801. ): # noqa: E501
  1802. raise ApiValueError(
  1803. "Missing the required parameter `settle` when calling `update_position_margin`"
  1804. ) # noqa: E501
  1805. # verify the required parameter 'contract' is set
  1806. if self.api_client.client_side_validation and (
  1807. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  1808. ): # noqa: E501
  1809. raise ApiValueError(
  1810. "Missing the required parameter `contract` when calling `update_position_margin`"
  1811. ) # noqa: E501
  1812. # verify the required parameter 'change' is set
  1813. if self.api_client.client_side_validation and (
  1814. 'change' not in local_var_params or local_var_params['change'] is None # noqa: E501
  1815. ): # noqa: E501
  1816. raise ApiValueError(
  1817. "Missing the required parameter `change` when calling `update_position_margin`"
  1818. ) # noqa: E501
  1819. collection_formats = {}
  1820. path_params = {}
  1821. if 'settle' in local_var_params:
  1822. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1823. if 'contract' in local_var_params:
  1824. path_params['contract'] = local_var_params['contract'] # noqa: E501
  1825. query_params = []
  1826. if 'change' in local_var_params and local_var_params['change'] is not None: # noqa: E501
  1827. query_params.append(('change', local_var_params['change'])) # noqa: E501
  1828. header_params = {}
  1829. form_params = []
  1830. local_var_files = {}
  1831. body_params = None
  1832. # HTTP header `Accept`
  1833. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1834. # Authentication setting
  1835. auth_settings = ['apiv4'] # noqa: E501
  1836. return self.api_client.call_api(
  1837. '/futures/{settle}/positions/{contract}/margin',
  1838. 'POST',
  1839. path_params,
  1840. query_params,
  1841. header_params,
  1842. body=body_params,
  1843. post_params=form_params,
  1844. files=local_var_files,
  1845. response_type='Position', # noqa: E501
  1846. auth_settings=auth_settings,
  1847. async_req=local_var_params.get('async_req'),
  1848. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1849. _preload_content=local_var_params.get('_preload_content', True),
  1850. _request_timeout=local_var_params.get('_request_timeout'),
  1851. collection_formats=collection_formats,
  1852. )
  1853. def update_position_leverage(self, settle, contract, leverage, **kwargs): # noqa: E501
  1854. """Update position leverage # noqa: E501
  1855. This method makes a synchronous HTTP request by default. To make an
  1856. asynchronous HTTP request, please pass async_req=True
  1857. >>> thread = api.update_position_leverage(settle, contract, leverage, async_req=True)
  1858. >>> result = thread.get()
  1859. :param bool async_req: execute request asynchronously
  1860. :param str settle: Settle currency (required)
  1861. :param str contract: Futures contract (required)
  1862. :param str leverage: New position leverage (required)
  1863. :param str cross_leverage_limit: Cross margin leverage(valid only when `leverage` is 0)
  1864. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1865. be returned without reading/decoding response
  1866. data. Default is True.
  1867. :param _request_timeout: timeout setting for this request. If one
  1868. number provided, it will be total request
  1869. timeout. It can also be a pair (tuple) of
  1870. (connection, read) timeouts.
  1871. :rtype: gate_api.Position
  1872. :return: If the method is called asynchronously,
  1873. returns the request thread.
  1874. """
  1875. kwargs['_return_http_data_only'] = True
  1876. return self.update_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501
  1877. def update_position_leverage_with_http_info(self, settle, contract, leverage, **kwargs): # noqa: E501
  1878. """Update position leverage # noqa: E501
  1879. This method makes a synchronous HTTP request by default. To make an
  1880. asynchronous HTTP request, please pass async_req=True
  1881. >>> thread = api.update_position_leverage_with_http_info(settle, contract, leverage, async_req=True)
  1882. >>> result = thread.get()
  1883. :param bool async_req: execute request asynchronously
  1884. :param str settle: Settle currency (required)
  1885. :param str contract: Futures contract (required)
  1886. :param str leverage: New position leverage (required)
  1887. :param str cross_leverage_limit: Cross margin leverage(valid only when `leverage` is 0)
  1888. :param _return_http_data_only: response data without head status code
  1889. and headers
  1890. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1891. be returned without reading/decoding response
  1892. data. Default is True.
  1893. :param _request_timeout: timeout setting for this request. If one
  1894. number provided, it will be total request
  1895. timeout. It can also be a pair (tuple) of
  1896. (connection, read) timeouts.
  1897. :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict))
  1898. :return: If the method is called asynchronously,
  1899. returns the request thread.
  1900. """
  1901. local_var_params = locals()
  1902. all_params = ['settle', 'contract', 'leverage', 'cross_leverage_limit']
  1903. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  1904. for k, v in six.iteritems(local_var_params['kwargs']):
  1905. if k not in all_params:
  1906. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_position_leverage" % k)
  1907. local_var_params[k] = v
  1908. del local_var_params['kwargs']
  1909. # verify the required parameter 'settle' is set
  1910. if self.api_client.client_side_validation and (
  1911. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  1912. ): # noqa: E501
  1913. raise ApiValueError(
  1914. "Missing the required parameter `settle` when calling `update_position_leverage`"
  1915. ) # noqa: E501
  1916. # verify the required parameter 'contract' is set
  1917. if self.api_client.client_side_validation and (
  1918. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  1919. ): # noqa: E501
  1920. raise ApiValueError(
  1921. "Missing the required parameter `contract` when calling `update_position_leverage`"
  1922. ) # noqa: E501
  1923. # verify the required parameter 'leverage' is set
  1924. if self.api_client.client_side_validation and (
  1925. 'leverage' not in local_var_params or local_var_params['leverage'] is None # noqa: E501
  1926. ): # noqa: E501
  1927. raise ApiValueError(
  1928. "Missing the required parameter `leverage` when calling `update_position_leverage`"
  1929. ) # noqa: E501
  1930. collection_formats = {}
  1931. path_params = {}
  1932. if 'settle' in local_var_params:
  1933. path_params['settle'] = local_var_params['settle'] # noqa: E501
  1934. if 'contract' in local_var_params:
  1935. path_params['contract'] = local_var_params['contract'] # noqa: E501
  1936. query_params = []
  1937. if 'leverage' in local_var_params and local_var_params['leverage'] is not None: # noqa: E501
  1938. query_params.append(('leverage', local_var_params['leverage'])) # noqa: E501
  1939. if (
  1940. 'cross_leverage_limit' in local_var_params and local_var_params['cross_leverage_limit'] is not None
  1941. ): # noqa: E501
  1942. query_params.append(('cross_leverage_limit', local_var_params['cross_leverage_limit'])) # noqa: E501
  1943. header_params = {}
  1944. form_params = []
  1945. local_var_files = {}
  1946. body_params = None
  1947. # HTTP header `Accept`
  1948. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  1949. # Authentication setting
  1950. auth_settings = ['apiv4'] # noqa: E501
  1951. return self.api_client.call_api(
  1952. '/futures/{settle}/positions/{contract}/leverage',
  1953. 'POST',
  1954. path_params,
  1955. query_params,
  1956. header_params,
  1957. body=body_params,
  1958. post_params=form_params,
  1959. files=local_var_files,
  1960. response_type='Position', # noqa: E501
  1961. auth_settings=auth_settings,
  1962. async_req=local_var_params.get('async_req'),
  1963. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  1964. _preload_content=local_var_params.get('_preload_content', True),
  1965. _request_timeout=local_var_params.get('_request_timeout'),
  1966. collection_formats=collection_formats,
  1967. )
  1968. def update_position_risk_limit(self, settle, contract, risk_limit, **kwargs): # noqa: E501
  1969. """Update position risk limit # noqa: E501
  1970. This method makes a synchronous HTTP request by default. To make an
  1971. asynchronous HTTP request, please pass async_req=True
  1972. >>> thread = api.update_position_risk_limit(settle, contract, risk_limit, async_req=True)
  1973. >>> result = thread.get()
  1974. :param bool async_req: execute request asynchronously
  1975. :param str settle: Settle currency (required)
  1976. :param str contract: Futures contract (required)
  1977. :param str risk_limit: New position risk limit (required)
  1978. :param _preload_content: if False, the urllib3.HTTPResponse object will
  1979. be returned without reading/decoding response
  1980. data. Default is True.
  1981. :param _request_timeout: timeout setting for this request. If one
  1982. number provided, it will be total request
  1983. timeout. It can also be a pair (tuple) of
  1984. (connection, read) timeouts.
  1985. :rtype: gate_api.Position
  1986. :return: If the method is called asynchronously,
  1987. returns the request thread.
  1988. """
  1989. kwargs['_return_http_data_only'] = True
  1990. return self.update_position_risk_limit_with_http_info(settle, contract, risk_limit, **kwargs) # noqa: E501
  1991. def update_position_risk_limit_with_http_info(self, settle, contract, risk_limit, **kwargs): # noqa: E501
  1992. """Update position risk limit # noqa: E501
  1993. This method makes a synchronous HTTP request by default. To make an
  1994. asynchronous HTTP request, please pass async_req=True
  1995. >>> thread = api.update_position_risk_limit_with_http_info(settle, contract, risk_limit, async_req=True)
  1996. >>> result = thread.get()
  1997. :param bool async_req: execute request asynchronously
  1998. :param str settle: Settle currency (required)
  1999. :param str contract: Futures contract (required)
  2000. :param str risk_limit: New position risk limit (required)
  2001. :param _return_http_data_only: response data without head status code
  2002. and headers
  2003. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2004. be returned without reading/decoding response
  2005. data. Default is True.
  2006. :param _request_timeout: timeout setting for this request. If one
  2007. number provided, it will be total request
  2008. timeout. It can also be a pair (tuple) of
  2009. (connection, read) timeouts.
  2010. :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict))
  2011. :return: If the method is called asynchronously,
  2012. returns the request thread.
  2013. """
  2014. local_var_params = locals()
  2015. all_params = ['settle', 'contract', 'risk_limit']
  2016. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2017. for k, v in six.iteritems(local_var_params['kwargs']):
  2018. if k not in all_params:
  2019. raise ApiTypeError(
  2020. "Got an unexpected keyword argument '%s'" " to method update_position_risk_limit" % k
  2021. )
  2022. local_var_params[k] = v
  2023. del local_var_params['kwargs']
  2024. # verify the required parameter 'settle' is set
  2025. if self.api_client.client_side_validation and (
  2026. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2027. ): # noqa: E501
  2028. raise ApiValueError(
  2029. "Missing the required parameter `settle` when calling `update_position_risk_limit`"
  2030. ) # noqa: E501
  2031. # verify the required parameter 'contract' is set
  2032. if self.api_client.client_side_validation and (
  2033. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2034. ): # noqa: E501
  2035. raise ApiValueError(
  2036. "Missing the required parameter `contract` when calling `update_position_risk_limit`"
  2037. ) # noqa: E501
  2038. # verify the required parameter 'risk_limit' is set
  2039. if self.api_client.client_side_validation and (
  2040. 'risk_limit' not in local_var_params or local_var_params['risk_limit'] is None # noqa: E501
  2041. ): # noqa: E501
  2042. raise ApiValueError(
  2043. "Missing the required parameter `risk_limit` when calling `update_position_risk_limit`"
  2044. ) # noqa: E501
  2045. collection_formats = {}
  2046. path_params = {}
  2047. if 'settle' in local_var_params:
  2048. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2049. if 'contract' in local_var_params:
  2050. path_params['contract'] = local_var_params['contract'] # noqa: E501
  2051. query_params = []
  2052. if 'risk_limit' in local_var_params and local_var_params['risk_limit'] is not None: # noqa: E501
  2053. query_params.append(('risk_limit', local_var_params['risk_limit'])) # noqa: E501
  2054. header_params = {}
  2055. form_params = []
  2056. local_var_files = {}
  2057. body_params = None
  2058. # HTTP header `Accept`
  2059. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2060. # Authentication setting
  2061. auth_settings = ['apiv4'] # noqa: E501
  2062. return self.api_client.call_api(
  2063. '/futures/{settle}/positions/{contract}/risk_limit',
  2064. 'POST',
  2065. path_params,
  2066. query_params,
  2067. header_params,
  2068. body=body_params,
  2069. post_params=form_params,
  2070. files=local_var_files,
  2071. response_type='Position', # noqa: E501
  2072. auth_settings=auth_settings,
  2073. async_req=local_var_params.get('async_req'),
  2074. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2075. _preload_content=local_var_params.get('_preload_content', True),
  2076. _request_timeout=local_var_params.get('_request_timeout'),
  2077. collection_formats=collection_formats,
  2078. )
  2079. def set_dual_mode(self, settle, dual_mode, **kwargs): # noqa: E501
  2080. """Enable or disable dual mode # noqa: E501
  2081. Before setting dual mode, make sure all positions are closed and no orders are open # noqa: E501
  2082. This method makes a synchronous HTTP request by default. To make an
  2083. asynchronous HTTP request, please pass async_req=True
  2084. >>> thread = api.set_dual_mode(settle, dual_mode, async_req=True)
  2085. >>> result = thread.get()
  2086. :param bool async_req: execute request asynchronously
  2087. :param str settle: Settle currency (required)
  2088. :param bool dual_mode: Whether to enable dual mode (required)
  2089. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2090. be returned without reading/decoding response
  2091. data. Default is True.
  2092. :param _request_timeout: timeout setting for this request. If one
  2093. number provided, it will be total request
  2094. timeout. It can also be a pair (tuple) of
  2095. (connection, read) timeouts.
  2096. :rtype: gate_api.FuturesAccount
  2097. :return: If the method is called asynchronously,
  2098. returns the request thread.
  2099. """
  2100. kwargs['_return_http_data_only'] = True
  2101. return self.set_dual_mode_with_http_info(settle, dual_mode, **kwargs) # noqa: E501
  2102. def set_dual_mode_with_http_info(self, settle, dual_mode, **kwargs): # noqa: E501
  2103. """Enable or disable dual mode # noqa: E501
  2104. Before setting dual mode, make sure all positions are closed and no orders are open # noqa: E501
  2105. This method makes a synchronous HTTP request by default. To make an
  2106. asynchronous HTTP request, please pass async_req=True
  2107. >>> thread = api.set_dual_mode_with_http_info(settle, dual_mode, async_req=True)
  2108. >>> result = thread.get()
  2109. :param bool async_req: execute request asynchronously
  2110. :param str settle: Settle currency (required)
  2111. :param bool dual_mode: Whether to enable dual mode (required)
  2112. :param _return_http_data_only: response data without head status code
  2113. and headers
  2114. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2115. be returned without reading/decoding response
  2116. data. Default is True.
  2117. :param _request_timeout: timeout setting for this request. If one
  2118. number provided, it will be total request
  2119. timeout. It can also be a pair (tuple) of
  2120. (connection, read) timeouts.
  2121. :rtype: tuple(gate_api.FuturesAccount, status_code(int), headers(HTTPHeaderDict))
  2122. :return: If the method is called asynchronously,
  2123. returns the request thread.
  2124. """
  2125. local_var_params = locals()
  2126. all_params = ['settle', 'dual_mode']
  2127. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2128. for k, v in six.iteritems(local_var_params['kwargs']):
  2129. if k not in all_params:
  2130. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method set_dual_mode" % k)
  2131. local_var_params[k] = v
  2132. del local_var_params['kwargs']
  2133. # verify the required parameter 'settle' is set
  2134. if self.api_client.client_side_validation and (
  2135. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2136. ): # noqa: E501
  2137. raise ApiValueError("Missing the required parameter `settle` when calling `set_dual_mode`") # noqa: E501
  2138. # verify the required parameter 'dual_mode' is set
  2139. if self.api_client.client_side_validation and (
  2140. 'dual_mode' not in local_var_params or local_var_params['dual_mode'] is None # noqa: E501
  2141. ): # noqa: E501
  2142. raise ApiValueError("Missing the required parameter `dual_mode` when calling `set_dual_mode`") # noqa: E501
  2143. collection_formats = {}
  2144. path_params = {}
  2145. if 'settle' in local_var_params:
  2146. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2147. query_params = []
  2148. if 'dual_mode' in local_var_params and local_var_params['dual_mode'] is not None: # noqa: E501
  2149. query_params.append(('dual_mode', local_var_params['dual_mode'])) # noqa: E501
  2150. header_params = {}
  2151. form_params = []
  2152. local_var_files = {}
  2153. body_params = None
  2154. # HTTP header `Accept`
  2155. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2156. # Authentication setting
  2157. auth_settings = ['apiv4'] # noqa: E501
  2158. return self.api_client.call_api(
  2159. '/futures/{settle}/dual_mode',
  2160. 'POST',
  2161. path_params,
  2162. query_params,
  2163. header_params,
  2164. body=body_params,
  2165. post_params=form_params,
  2166. files=local_var_files,
  2167. response_type='FuturesAccount', # noqa: E501
  2168. auth_settings=auth_settings,
  2169. async_req=local_var_params.get('async_req'),
  2170. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2171. _preload_content=local_var_params.get('_preload_content', True),
  2172. _request_timeout=local_var_params.get('_request_timeout'),
  2173. collection_formats=collection_formats,
  2174. )
  2175. def get_dual_mode_position(self, settle, contract, **kwargs): # noqa: E501
  2176. """Retrieve position detail in dual mode # noqa: E501
  2177. This method makes a synchronous HTTP request by default. To make an
  2178. asynchronous HTTP request, please pass async_req=True
  2179. >>> thread = api.get_dual_mode_position(settle, contract, async_req=True)
  2180. >>> result = thread.get()
  2181. :param bool async_req: execute request asynchronously
  2182. :param str settle: Settle currency (required)
  2183. :param str contract: Futures contract (required)
  2184. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2185. be returned without reading/decoding response
  2186. data. Default is True.
  2187. :param _request_timeout: timeout setting for this request. If one
  2188. number provided, it will be total request
  2189. timeout. It can also be a pair (tuple) of
  2190. (connection, read) timeouts.
  2191. :rtype: list[gate_api.Position]
  2192. :return: If the method is called asynchronously,
  2193. returns the request thread.
  2194. """
  2195. kwargs['_return_http_data_only'] = True
  2196. return self.get_dual_mode_position_with_http_info(settle, contract, **kwargs) # noqa: E501
  2197. def get_dual_mode_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  2198. """Retrieve position detail in dual mode # noqa: E501
  2199. This method makes a synchronous HTTP request by default. To make an
  2200. asynchronous HTTP request, please pass async_req=True
  2201. >>> thread = api.get_dual_mode_position_with_http_info(settle, contract, async_req=True)
  2202. >>> result = thread.get()
  2203. :param bool async_req: execute request asynchronously
  2204. :param str settle: Settle currency (required)
  2205. :param str contract: Futures contract (required)
  2206. :param _return_http_data_only: response data without head status code
  2207. and headers
  2208. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2209. be returned without reading/decoding response
  2210. data. Default is True.
  2211. :param _request_timeout: timeout setting for this request. If one
  2212. number provided, it will be total request
  2213. timeout. It can also be a pair (tuple) of
  2214. (connection, read) timeouts.
  2215. :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict))
  2216. :return: If the method is called asynchronously,
  2217. returns the request thread.
  2218. """
  2219. local_var_params = locals()
  2220. all_params = ['settle', 'contract']
  2221. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2222. for k, v in six.iteritems(local_var_params['kwargs']):
  2223. if k not in all_params:
  2224. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_dual_mode_position" % k)
  2225. local_var_params[k] = v
  2226. del local_var_params['kwargs']
  2227. # verify the required parameter 'settle' is set
  2228. if self.api_client.client_side_validation and (
  2229. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2230. ): # noqa: E501
  2231. raise ApiValueError(
  2232. "Missing the required parameter `settle` when calling `get_dual_mode_position`"
  2233. ) # noqa: E501
  2234. # verify the required parameter 'contract' is set
  2235. if self.api_client.client_side_validation and (
  2236. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2237. ): # noqa: E501
  2238. raise ApiValueError(
  2239. "Missing the required parameter `contract` when calling `get_dual_mode_position`"
  2240. ) # noqa: E501
  2241. collection_formats = {}
  2242. path_params = {}
  2243. if 'settle' in local_var_params:
  2244. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2245. if 'contract' in local_var_params:
  2246. path_params['contract'] = local_var_params['contract'] # noqa: E501
  2247. query_params = []
  2248. header_params = {}
  2249. form_params = []
  2250. local_var_files = {}
  2251. body_params = None
  2252. # HTTP header `Accept`
  2253. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2254. # Authentication setting
  2255. auth_settings = ['apiv4'] # noqa: E501
  2256. return self.api_client.call_api(
  2257. '/futures/{settle}/dual_comp/positions/{contract}',
  2258. 'GET',
  2259. path_params,
  2260. query_params,
  2261. header_params,
  2262. body=body_params,
  2263. post_params=form_params,
  2264. files=local_var_files,
  2265. response_type='list[Position]', # noqa: E501
  2266. auth_settings=auth_settings,
  2267. async_req=local_var_params.get('async_req'),
  2268. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2269. _preload_content=local_var_params.get('_preload_content', True),
  2270. _request_timeout=local_var_params.get('_request_timeout'),
  2271. collection_formats=collection_formats,
  2272. )
  2273. def update_dual_mode_position_margin(self, settle, contract, change, dual_side, **kwargs): # noqa: E501
  2274. """Update position margin in dual mode # noqa: E501
  2275. This method makes a synchronous HTTP request by default. To make an
  2276. asynchronous HTTP request, please pass async_req=True
  2277. >>> thread = api.update_dual_mode_position_margin(settle, contract, change, dual_side, async_req=True)
  2278. >>> result = thread.get()
  2279. :param bool async_req: execute request asynchronously
  2280. :param str settle: Settle currency (required)
  2281. :param str contract: Futures contract (required)
  2282. :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required)
  2283. :param str dual_side: Long or short position (required)
  2284. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2285. be returned without reading/decoding response
  2286. data. Default is True.
  2287. :param _request_timeout: timeout setting for this request. If one
  2288. number provided, it will be total request
  2289. timeout. It can also be a pair (tuple) of
  2290. (connection, read) timeouts.
  2291. :rtype: list[gate_api.Position]
  2292. :return: If the method is called asynchronously,
  2293. returns the request thread.
  2294. """
  2295. kwargs['_return_http_data_only'] = True
  2296. return self.update_dual_mode_position_margin_with_http_info(
  2297. settle, contract, change, dual_side, **kwargs
  2298. ) # noqa: E501
  2299. def update_dual_mode_position_margin_with_http_info(
  2300. self, settle, contract, change, dual_side, **kwargs
  2301. ): # noqa: E501
  2302. """Update position margin in dual mode # noqa: E501
  2303. This method makes a synchronous HTTP request by default. To make an
  2304. asynchronous HTTP request, please pass async_req=True
  2305. >>> thread = api.update_dual_mode_position_margin_with_http_info(settle, contract, change, dual_side, async_req=True)
  2306. >>> result = thread.get()
  2307. :param bool async_req: execute request asynchronously
  2308. :param str settle: Settle currency (required)
  2309. :param str contract: Futures contract (required)
  2310. :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required)
  2311. :param str dual_side: Long or short position (required)
  2312. :param _return_http_data_only: response data without head status code
  2313. and headers
  2314. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2315. be returned without reading/decoding response
  2316. data. Default is True.
  2317. :param _request_timeout: timeout setting for this request. If one
  2318. number provided, it will be total request
  2319. timeout. It can also be a pair (tuple) of
  2320. (connection, read) timeouts.
  2321. :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict))
  2322. :return: If the method is called asynchronously,
  2323. returns the request thread.
  2324. """
  2325. local_var_params = locals()
  2326. all_params = ['settle', 'contract', 'change', 'dual_side']
  2327. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2328. for k, v in six.iteritems(local_var_params['kwargs']):
  2329. if k not in all_params:
  2330. raise ApiTypeError(
  2331. "Got an unexpected keyword argument '%s'" " to method update_dual_mode_position_margin" % k
  2332. )
  2333. local_var_params[k] = v
  2334. del local_var_params['kwargs']
  2335. # verify the required parameter 'settle' is set
  2336. if self.api_client.client_side_validation and (
  2337. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2338. ): # noqa: E501
  2339. raise ApiValueError(
  2340. "Missing the required parameter `settle` when calling `update_dual_mode_position_margin`"
  2341. ) # noqa: E501
  2342. # verify the required parameter 'contract' is set
  2343. if self.api_client.client_side_validation and (
  2344. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2345. ): # noqa: E501
  2346. raise ApiValueError(
  2347. "Missing the required parameter `contract` when calling `update_dual_mode_position_margin`"
  2348. ) # noqa: E501
  2349. # verify the required parameter 'change' is set
  2350. if self.api_client.client_side_validation and (
  2351. 'change' not in local_var_params or local_var_params['change'] is None # noqa: E501
  2352. ): # noqa: E501
  2353. raise ApiValueError(
  2354. "Missing the required parameter `change` when calling `update_dual_mode_position_margin`"
  2355. ) # noqa: E501
  2356. # verify the required parameter 'dual_side' is set
  2357. if self.api_client.client_side_validation and (
  2358. 'dual_side' not in local_var_params or local_var_params['dual_side'] is None # noqa: E501
  2359. ): # noqa: E501
  2360. raise ApiValueError(
  2361. "Missing the required parameter `dual_side` when calling `update_dual_mode_position_margin`"
  2362. ) # noqa: E501
  2363. collection_formats = {}
  2364. path_params = {}
  2365. if 'settle' in local_var_params:
  2366. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2367. if 'contract' in local_var_params:
  2368. path_params['contract'] = local_var_params['contract'] # noqa: E501
  2369. query_params = []
  2370. if 'change' in local_var_params and local_var_params['change'] is not None: # noqa: E501
  2371. query_params.append(('change', local_var_params['change'])) # noqa: E501
  2372. if 'dual_side' in local_var_params and local_var_params['dual_side'] is not None: # noqa: E501
  2373. query_params.append(('dual_side', local_var_params['dual_side'])) # noqa: E501
  2374. header_params = {}
  2375. form_params = []
  2376. local_var_files = {}
  2377. body_params = None
  2378. # HTTP header `Accept`
  2379. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2380. # Authentication setting
  2381. auth_settings = ['apiv4'] # noqa: E501
  2382. return self.api_client.call_api(
  2383. '/futures/{settle}/dual_comp/positions/{contract}/margin',
  2384. 'POST',
  2385. path_params,
  2386. query_params,
  2387. header_params,
  2388. body=body_params,
  2389. post_params=form_params,
  2390. files=local_var_files,
  2391. response_type='list[Position]', # noqa: E501
  2392. auth_settings=auth_settings,
  2393. async_req=local_var_params.get('async_req'),
  2394. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2395. _preload_content=local_var_params.get('_preload_content', True),
  2396. _request_timeout=local_var_params.get('_request_timeout'),
  2397. collection_formats=collection_formats,
  2398. )
  2399. def update_dual_mode_position_leverage(self, settle, contract, leverage, **kwargs): # noqa: E501
  2400. """Update position leverage in dual mode # noqa: E501
  2401. This method makes a synchronous HTTP request by default. To make an
  2402. asynchronous HTTP request, please pass async_req=True
  2403. >>> thread = api.update_dual_mode_position_leverage(settle, contract, leverage, async_req=True)
  2404. >>> result = thread.get()
  2405. :param bool async_req: execute request asynchronously
  2406. :param str settle: Settle currency (required)
  2407. :param str contract: Futures contract (required)
  2408. :param str leverage: New position leverage (required)
  2409. :param str cross_leverage_limit: Cross margin leverage(valid only when `leverage` is 0)
  2410. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2411. be returned without reading/decoding response
  2412. data. Default is True.
  2413. :param _request_timeout: timeout setting for this request. If one
  2414. number provided, it will be total request
  2415. timeout. It can also be a pair (tuple) of
  2416. (connection, read) timeouts.
  2417. :rtype: list[gate_api.Position]
  2418. :return: If the method is called asynchronously,
  2419. returns the request thread.
  2420. """
  2421. kwargs['_return_http_data_only'] = True
  2422. return self.update_dual_mode_position_leverage_with_http_info(
  2423. settle, contract, leverage, **kwargs
  2424. ) # noqa: E501
  2425. def update_dual_mode_position_leverage_with_http_info(self, settle, contract, leverage, **kwargs): # noqa: E501
  2426. """Update position leverage in dual mode # noqa: E501
  2427. This method makes a synchronous HTTP request by default. To make an
  2428. asynchronous HTTP request, please pass async_req=True
  2429. >>> thread = api.update_dual_mode_position_leverage_with_http_info(settle, contract, leverage, async_req=True)
  2430. >>> result = thread.get()
  2431. :param bool async_req: execute request asynchronously
  2432. :param str settle: Settle currency (required)
  2433. :param str contract: Futures contract (required)
  2434. :param str leverage: New position leverage (required)
  2435. :param str cross_leverage_limit: Cross margin leverage(valid only when `leverage` is 0)
  2436. :param _return_http_data_only: response data without head status code
  2437. and headers
  2438. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2439. be returned without reading/decoding response
  2440. data. Default is True.
  2441. :param _request_timeout: timeout setting for this request. If one
  2442. number provided, it will be total request
  2443. timeout. It can also be a pair (tuple) of
  2444. (connection, read) timeouts.
  2445. :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict))
  2446. :return: If the method is called asynchronously,
  2447. returns the request thread.
  2448. """
  2449. local_var_params = locals()
  2450. all_params = ['settle', 'contract', 'leverage', 'cross_leverage_limit']
  2451. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2452. for k, v in six.iteritems(local_var_params['kwargs']):
  2453. if k not in all_params:
  2454. raise ApiTypeError(
  2455. "Got an unexpected keyword argument '%s'" " to method update_dual_mode_position_leverage" % k
  2456. )
  2457. local_var_params[k] = v
  2458. del local_var_params['kwargs']
  2459. # verify the required parameter 'settle' is set
  2460. if self.api_client.client_side_validation and (
  2461. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2462. ): # noqa: E501
  2463. raise ApiValueError(
  2464. "Missing the required parameter `settle` when calling `update_dual_mode_position_leverage`"
  2465. ) # noqa: E501
  2466. # verify the required parameter 'contract' is set
  2467. if self.api_client.client_side_validation and (
  2468. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2469. ): # noqa: E501
  2470. raise ApiValueError(
  2471. "Missing the required parameter `contract` when calling `update_dual_mode_position_leverage`"
  2472. ) # noqa: E501
  2473. # verify the required parameter 'leverage' is set
  2474. if self.api_client.client_side_validation and (
  2475. 'leverage' not in local_var_params or local_var_params['leverage'] is None # noqa: E501
  2476. ): # noqa: E501
  2477. raise ApiValueError(
  2478. "Missing the required parameter `leverage` when calling `update_dual_mode_position_leverage`"
  2479. ) # noqa: E501
  2480. collection_formats = {}
  2481. path_params = {}
  2482. if 'settle' in local_var_params:
  2483. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2484. if 'contract' in local_var_params:
  2485. path_params['contract'] = local_var_params['contract'] # noqa: E501
  2486. query_params = []
  2487. if 'leverage' in local_var_params and local_var_params['leverage'] is not None: # noqa: E501
  2488. query_params.append(('leverage', local_var_params['leverage'])) # noqa: E501
  2489. if (
  2490. 'cross_leverage_limit' in local_var_params and local_var_params['cross_leverage_limit'] is not None
  2491. ): # noqa: E501
  2492. query_params.append(('cross_leverage_limit', local_var_params['cross_leverage_limit'])) # noqa: E501
  2493. header_params = {}
  2494. form_params = []
  2495. local_var_files = {}
  2496. body_params = None
  2497. # HTTP header `Accept`
  2498. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2499. # Authentication setting
  2500. auth_settings = ['apiv4'] # noqa: E501
  2501. return self.api_client.call_api(
  2502. '/futures/{settle}/dual_comp/positions/{contract}/leverage',
  2503. 'POST',
  2504. path_params,
  2505. query_params,
  2506. header_params,
  2507. body=body_params,
  2508. post_params=form_params,
  2509. files=local_var_files,
  2510. response_type='list[Position]', # noqa: E501
  2511. auth_settings=auth_settings,
  2512. async_req=local_var_params.get('async_req'),
  2513. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2514. _preload_content=local_var_params.get('_preload_content', True),
  2515. _request_timeout=local_var_params.get('_request_timeout'),
  2516. collection_formats=collection_formats,
  2517. )
  2518. def update_dual_mode_position_risk_limit(self, settle, contract, risk_limit, **kwargs): # noqa: E501
  2519. """Update position risk limit in dual mode # noqa: E501
  2520. This method makes a synchronous HTTP request by default. To make an
  2521. asynchronous HTTP request, please pass async_req=True
  2522. >>> thread = api.update_dual_mode_position_risk_limit(settle, contract, risk_limit, async_req=True)
  2523. >>> result = thread.get()
  2524. :param bool async_req: execute request asynchronously
  2525. :param str settle: Settle currency (required)
  2526. :param str contract: Futures contract (required)
  2527. :param str risk_limit: New position risk limit (required)
  2528. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2529. be returned without reading/decoding response
  2530. data. Default is True.
  2531. :param _request_timeout: timeout setting for this request. If one
  2532. number provided, it will be total request
  2533. timeout. It can also be a pair (tuple) of
  2534. (connection, read) timeouts.
  2535. :rtype: list[gate_api.Position]
  2536. :return: If the method is called asynchronously,
  2537. returns the request thread.
  2538. """
  2539. kwargs['_return_http_data_only'] = True
  2540. return self.update_dual_mode_position_risk_limit_with_http_info(
  2541. settle, contract, risk_limit, **kwargs
  2542. ) # noqa: E501
  2543. def update_dual_mode_position_risk_limit_with_http_info(self, settle, contract, risk_limit, **kwargs): # noqa: E501
  2544. """Update position risk limit in dual mode # noqa: E501
  2545. This method makes a synchronous HTTP request by default. To make an
  2546. asynchronous HTTP request, please pass async_req=True
  2547. >>> thread = api.update_dual_mode_position_risk_limit_with_http_info(settle, contract, risk_limit, async_req=True)
  2548. >>> result = thread.get()
  2549. :param bool async_req: execute request asynchronously
  2550. :param str settle: Settle currency (required)
  2551. :param str contract: Futures contract (required)
  2552. :param str risk_limit: New position risk limit (required)
  2553. :param _return_http_data_only: response data without head status code
  2554. and headers
  2555. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2556. be returned without reading/decoding response
  2557. data. Default is True.
  2558. :param _request_timeout: timeout setting for this request. If one
  2559. number provided, it will be total request
  2560. timeout. It can also be a pair (tuple) of
  2561. (connection, read) timeouts.
  2562. :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict))
  2563. :return: If the method is called asynchronously,
  2564. returns the request thread.
  2565. """
  2566. local_var_params = locals()
  2567. all_params = ['settle', 'contract', 'risk_limit']
  2568. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2569. for k, v in six.iteritems(local_var_params['kwargs']):
  2570. if k not in all_params:
  2571. raise ApiTypeError(
  2572. "Got an unexpected keyword argument '%s'" " to method update_dual_mode_position_risk_limit" % k
  2573. )
  2574. local_var_params[k] = v
  2575. del local_var_params['kwargs']
  2576. # verify the required parameter 'settle' is set
  2577. if self.api_client.client_side_validation and (
  2578. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2579. ): # noqa: E501
  2580. raise ApiValueError(
  2581. "Missing the required parameter `settle` when calling `update_dual_mode_position_risk_limit`"
  2582. ) # noqa: E501
  2583. # verify the required parameter 'contract' is set
  2584. if self.api_client.client_side_validation and (
  2585. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2586. ): # noqa: E501
  2587. raise ApiValueError(
  2588. "Missing the required parameter `contract` when calling `update_dual_mode_position_risk_limit`"
  2589. ) # noqa: E501
  2590. # verify the required parameter 'risk_limit' is set
  2591. if self.api_client.client_side_validation and (
  2592. 'risk_limit' not in local_var_params or local_var_params['risk_limit'] is None # noqa: E501
  2593. ): # noqa: E501
  2594. raise ApiValueError(
  2595. "Missing the required parameter `risk_limit` when calling `update_dual_mode_position_risk_limit`"
  2596. ) # noqa: E501
  2597. collection_formats = {}
  2598. path_params = {}
  2599. if 'settle' in local_var_params:
  2600. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2601. if 'contract' in local_var_params:
  2602. path_params['contract'] = local_var_params['contract'] # noqa: E501
  2603. query_params = []
  2604. if 'risk_limit' in local_var_params and local_var_params['risk_limit'] is not None: # noqa: E501
  2605. query_params.append(('risk_limit', local_var_params['risk_limit'])) # noqa: E501
  2606. header_params = {}
  2607. form_params = []
  2608. local_var_files = {}
  2609. body_params = None
  2610. # HTTP header `Accept`
  2611. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2612. # Authentication setting
  2613. auth_settings = ['apiv4'] # noqa: E501
  2614. return self.api_client.call_api(
  2615. '/futures/{settle}/dual_comp/positions/{contract}/risk_limit',
  2616. 'POST',
  2617. path_params,
  2618. query_params,
  2619. header_params,
  2620. body=body_params,
  2621. post_params=form_params,
  2622. files=local_var_files,
  2623. response_type='list[Position]', # noqa: E501
  2624. auth_settings=auth_settings,
  2625. async_req=local_var_params.get('async_req'),
  2626. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2627. _preload_content=local_var_params.get('_preload_content', True),
  2628. _request_timeout=local_var_params.get('_request_timeout'),
  2629. collection_formats=collection_formats,
  2630. )
  2631. def list_futures_orders(self, settle, contract, status, **kwargs): # noqa: E501
  2632. """List futures orders # noqa: E501
  2633. Zero-filled order cannot be retrieved 10 minutes after order cancellation # noqa: E501
  2634. This method makes a synchronous HTTP request by default. To make an
  2635. asynchronous HTTP request, please pass async_req=True
  2636. >>> thread = api.list_futures_orders(settle, contract, status, async_req=True)
  2637. >>> result = thread.get()
  2638. :param bool async_req: execute request asynchronously
  2639. :param str settle: Settle currency (required)
  2640. :param str contract: Futures contract (required)
  2641. :param str status: Only list the orders with this status (required)
  2642. :param int limit: Maximum number of records to be returned in a single list
  2643. :param int offset: List offset, starting from 0
  2644. :param str last_id: Specify list staring point using the `id` of last record in previous list-query results
  2645. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2646. be returned without reading/decoding response
  2647. data. Default is True.
  2648. :param _request_timeout: timeout setting for this request. If one
  2649. number provided, it will be total request
  2650. timeout. It can also be a pair (tuple) of
  2651. (connection, read) timeouts.
  2652. :rtype: list[gate_api.FuturesOrder]
  2653. :return: If the method is called asynchronously,
  2654. returns the request thread.
  2655. """
  2656. kwargs['_return_http_data_only'] = True
  2657. return self.list_futures_orders_with_http_info(settle, contract, status, **kwargs) # noqa: E501
  2658. def list_futures_orders_with_http_info(self, settle, contract, status, **kwargs): # noqa: E501
  2659. """List futures orders # noqa: E501
  2660. Zero-filled order cannot be retrieved 10 minutes after order cancellation # noqa: E501
  2661. This method makes a synchronous HTTP request by default. To make an
  2662. asynchronous HTTP request, please pass async_req=True
  2663. >>> thread = api.list_futures_orders_with_http_info(settle, contract, status, async_req=True)
  2664. >>> result = thread.get()
  2665. :param bool async_req: execute request asynchronously
  2666. :param str settle: Settle currency (required)
  2667. :param str contract: Futures contract (required)
  2668. :param str status: Only list the orders with this status (required)
  2669. :param int limit: Maximum number of records to be returned in a single list
  2670. :param int offset: List offset, starting from 0
  2671. :param str last_id: Specify list staring point using the `id` of last record in previous list-query results
  2672. :param _return_http_data_only: response data without head status code
  2673. and headers
  2674. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2675. be returned without reading/decoding response
  2676. data. Default is True.
  2677. :param _request_timeout: timeout setting for this request. If one
  2678. number provided, it will be total request
  2679. timeout. It can also be a pair (tuple) of
  2680. (connection, read) timeouts.
  2681. :rtype: tuple(list[gate_api.FuturesOrder], status_code(int), headers(HTTPHeaderDict))
  2682. :return: If the method is called asynchronously,
  2683. returns the request thread.
  2684. """
  2685. local_var_params = locals()
  2686. all_params = ['settle', 'contract', 'status', 'limit', 'offset', 'last_id']
  2687. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2688. for k, v in six.iteritems(local_var_params['kwargs']):
  2689. if k not in all_params:
  2690. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_orders" % k)
  2691. local_var_params[k] = v
  2692. del local_var_params['kwargs']
  2693. # verify the required parameter 'settle' is set
  2694. if self.api_client.client_side_validation and (
  2695. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2696. ): # noqa: E501
  2697. raise ApiValueError(
  2698. "Missing the required parameter `settle` when calling `list_futures_orders`"
  2699. ) # noqa: E501
  2700. # verify the required parameter 'contract' is set
  2701. if self.api_client.client_side_validation and (
  2702. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2703. ): # noqa: E501
  2704. raise ApiValueError(
  2705. "Missing the required parameter `contract` when calling `list_futures_orders`"
  2706. ) # noqa: E501
  2707. # verify the required parameter 'status' is set
  2708. if self.api_client.client_side_validation and (
  2709. 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501
  2710. ): # noqa: E501
  2711. raise ApiValueError(
  2712. "Missing the required parameter `status` when calling `list_futures_orders`"
  2713. ) # noqa: E501
  2714. if (
  2715. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  2716. ): # noqa: E501
  2717. raise ApiValueError(
  2718. "Invalid value for parameter `limit` when calling `list_futures_orders`, must be a value less than or equal to `1000`"
  2719. ) # noqa: E501
  2720. if (
  2721. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  2722. ): # noqa: E501
  2723. raise ApiValueError(
  2724. "Invalid value for parameter `limit` when calling `list_futures_orders`, must be a value greater than or equal to `1`"
  2725. ) # noqa: E501
  2726. if (
  2727. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  2728. ): # noqa: E501
  2729. raise ApiValueError(
  2730. "Invalid value for parameter `offset` when calling `list_futures_orders`, must be a value greater than or equal to `0`"
  2731. ) # noqa: E501
  2732. collection_formats = {}
  2733. path_params = {}
  2734. if 'settle' in local_var_params:
  2735. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2736. query_params = []
  2737. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  2738. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  2739. if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501
  2740. query_params.append(('status', local_var_params['status'])) # noqa: E501
  2741. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  2742. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  2743. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  2744. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  2745. if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501
  2746. query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501
  2747. header_params = {}
  2748. form_params = []
  2749. local_var_files = {}
  2750. body_params = None
  2751. # HTTP header `Accept`
  2752. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2753. # Authentication setting
  2754. auth_settings = ['apiv4'] # noqa: E501
  2755. return self.api_client.call_api(
  2756. '/futures/{settle}/orders',
  2757. 'GET',
  2758. path_params,
  2759. query_params,
  2760. header_params,
  2761. body=body_params,
  2762. post_params=form_params,
  2763. files=local_var_files,
  2764. response_type='list[FuturesOrder]', # noqa: E501
  2765. auth_settings=auth_settings,
  2766. async_req=local_var_params.get('async_req'),
  2767. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2768. _preload_content=local_var_params.get('_preload_content', True),
  2769. _request_timeout=local_var_params.get('_request_timeout'),
  2770. collection_formats=collection_formats,
  2771. )
  2772. def create_futures_order(self, settle, futures_order, **kwargs): # noqa: E501
  2773. """Create a futures order # noqa: E501
  2774. - Creating futures orders requires `size`, which is number of contracts instead of currency amount. You can use `quanto_multiplier` in contract detail response to know how much currency 1 size contract represents - Zero-filled order cannot be retrieved 10 minutes after order cancellation. You will get a 404 not found for such orders - Set `reduce_only` to `true` can keep the position from changing side when reducing position size - In single position mode, to close a position, you need to set `size` to 0 and `close` to `true` - In dual position mode, to close one side position, you need to set `auto_size` side, `reduce_only` to true and `size` to 0 - Set `stp_act` to decide the strategy of self-trade prevention. For detailed usage, refer to the `stp_act` parameter in request body # noqa: E501
  2775. This method makes a synchronous HTTP request by default. To make an
  2776. asynchronous HTTP request, please pass async_req=True
  2777. >>> thread = api.create_futures_order(settle, futures_order, async_req=True)
  2778. >>> result = thread.get()
  2779. :param bool async_req: execute request asynchronously
  2780. :param str settle: Settle currency (required)
  2781. :param FuturesOrder futures_order: (required)
  2782. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2783. be returned without reading/decoding response
  2784. data. Default is True.
  2785. :param _request_timeout: timeout setting for this request. If one
  2786. number provided, it will be total request
  2787. timeout. It can also be a pair (tuple) of
  2788. (connection, read) timeouts.
  2789. :rtype: gate_api.FuturesOrder
  2790. :return: If the method is called asynchronously,
  2791. returns the request thread.
  2792. """
  2793. kwargs['_return_http_data_only'] = True
  2794. return self.create_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501
  2795. def create_futures_order_with_http_info(self, settle, futures_order, **kwargs): # noqa: E501
  2796. """Create a futures order # noqa: E501
  2797. - Creating futures orders requires `size`, which is number of contracts instead of currency amount. You can use `quanto_multiplier` in contract detail response to know how much currency 1 size contract represents - Zero-filled order cannot be retrieved 10 minutes after order cancellation. You will get a 404 not found for such orders - Set `reduce_only` to `true` can keep the position from changing side when reducing position size - In single position mode, to close a position, you need to set `size` to 0 and `close` to `true` - In dual position mode, to close one side position, you need to set `auto_size` side, `reduce_only` to true and `size` to 0 - Set `stp_act` to decide the strategy of self-trade prevention. For detailed usage, refer to the `stp_act` parameter in request body # noqa: E501
  2798. This method makes a synchronous HTTP request by default. To make an
  2799. asynchronous HTTP request, please pass async_req=True
  2800. >>> thread = api.create_futures_order_with_http_info(settle, futures_order, async_req=True)
  2801. >>> result = thread.get()
  2802. :param bool async_req: execute request asynchronously
  2803. :param str settle: Settle currency (required)
  2804. :param FuturesOrder futures_order: (required)
  2805. :param _return_http_data_only: response data without head status code
  2806. and headers
  2807. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2808. be returned without reading/decoding response
  2809. data. Default is True.
  2810. :param _request_timeout: timeout setting for this request. If one
  2811. number provided, it will be total request
  2812. timeout. It can also be a pair (tuple) of
  2813. (connection, read) timeouts.
  2814. :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict))
  2815. :return: If the method is called asynchronously,
  2816. returns the request thread.
  2817. """
  2818. local_var_params = locals()
  2819. all_params = ['settle', 'futures_order']
  2820. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2821. for k, v in six.iteritems(local_var_params['kwargs']):
  2822. if k not in all_params:
  2823. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_futures_order" % k)
  2824. local_var_params[k] = v
  2825. del local_var_params['kwargs']
  2826. # verify the required parameter 'settle' is set
  2827. if self.api_client.client_side_validation and (
  2828. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2829. ): # noqa: E501
  2830. raise ApiValueError(
  2831. "Missing the required parameter `settle` when calling `create_futures_order`"
  2832. ) # noqa: E501
  2833. # verify the required parameter 'futures_order' is set
  2834. if self.api_client.client_side_validation and (
  2835. 'futures_order' not in local_var_params or local_var_params['futures_order'] is None # noqa: E501
  2836. ): # noqa: E501
  2837. raise ApiValueError(
  2838. "Missing the required parameter `futures_order` when calling `create_futures_order`"
  2839. ) # noqa: E501
  2840. collection_formats = {}
  2841. path_params = {}
  2842. if 'settle' in local_var_params:
  2843. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2844. query_params = []
  2845. header_params = {}
  2846. form_params = []
  2847. local_var_files = {}
  2848. body_params = None
  2849. if 'futures_order' in local_var_params:
  2850. body_params = local_var_params['futures_order']
  2851. # HTTP header `Accept`
  2852. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2853. # HTTP header `Content-Type`
  2854. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  2855. ['application/json']
  2856. ) # noqa: E501
  2857. # Authentication setting
  2858. auth_settings = ['apiv4'] # noqa: E501
  2859. return self.api_client.call_api(
  2860. '/futures/{settle}/orders',
  2861. 'POST',
  2862. path_params,
  2863. query_params,
  2864. header_params,
  2865. body=body_params,
  2866. post_params=form_params,
  2867. files=local_var_files,
  2868. response_type='FuturesOrder', # noqa: E501
  2869. auth_settings=auth_settings,
  2870. async_req=local_var_params.get('async_req'),
  2871. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2872. _preload_content=local_var_params.get('_preload_content', True),
  2873. _request_timeout=local_var_params.get('_request_timeout'),
  2874. collection_formats=collection_formats,
  2875. )
  2876. def cancel_futures_orders(self, settle, contract, **kwargs): # noqa: E501
  2877. """Cancel all `open` orders matched # noqa: E501
  2878. Zero-filled order cannot be retrieved 10 minutes after order cancellation # noqa: E501
  2879. This method makes a synchronous HTTP request by default. To make an
  2880. asynchronous HTTP request, please pass async_req=True
  2881. >>> thread = api.cancel_futures_orders(settle, contract, async_req=True)
  2882. >>> result = thread.get()
  2883. :param bool async_req: execute request asynchronously
  2884. :param str settle: Settle currency (required)
  2885. :param str contract: Futures contract (required)
  2886. :param str side: All bids or asks. Both included if not specified
  2887. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2888. be returned without reading/decoding response
  2889. data. Default is True.
  2890. :param _request_timeout: timeout setting for this request. If one
  2891. number provided, it will be total request
  2892. timeout. It can also be a pair (tuple) of
  2893. (connection, read) timeouts.
  2894. :rtype: list[gate_api.FuturesOrder]
  2895. :return: If the method is called asynchronously,
  2896. returns the request thread.
  2897. """
  2898. kwargs['_return_http_data_only'] = True
  2899. return self.cancel_futures_orders_with_http_info(settle, contract, **kwargs) # noqa: E501
  2900. def cancel_futures_orders_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  2901. """Cancel all `open` orders matched # noqa: E501
  2902. Zero-filled order cannot be retrieved 10 minutes after order cancellation # noqa: E501
  2903. This method makes a synchronous HTTP request by default. To make an
  2904. asynchronous HTTP request, please pass async_req=True
  2905. >>> thread = api.cancel_futures_orders_with_http_info(settle, contract, async_req=True)
  2906. >>> result = thread.get()
  2907. :param bool async_req: execute request asynchronously
  2908. :param str settle: Settle currency (required)
  2909. :param str contract: Futures contract (required)
  2910. :param str side: All bids or asks. Both included if not specified
  2911. :param _return_http_data_only: response data without head status code
  2912. and headers
  2913. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2914. be returned without reading/decoding response
  2915. data. Default is True.
  2916. :param _request_timeout: timeout setting for this request. If one
  2917. number provided, it will be total request
  2918. timeout. It can also be a pair (tuple) of
  2919. (connection, read) timeouts.
  2920. :rtype: tuple(list[gate_api.FuturesOrder], status_code(int), headers(HTTPHeaderDict))
  2921. :return: If the method is called asynchronously,
  2922. returns the request thread.
  2923. """
  2924. local_var_params = locals()
  2925. all_params = ['settle', 'contract', 'side']
  2926. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  2927. for k, v in six.iteritems(local_var_params['kwargs']):
  2928. if k not in all_params:
  2929. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_futures_orders" % k)
  2930. local_var_params[k] = v
  2931. del local_var_params['kwargs']
  2932. # verify the required parameter 'settle' is set
  2933. if self.api_client.client_side_validation and (
  2934. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  2935. ): # noqa: E501
  2936. raise ApiValueError(
  2937. "Missing the required parameter `settle` when calling `cancel_futures_orders`"
  2938. ) # noqa: E501
  2939. # verify the required parameter 'contract' is set
  2940. if self.api_client.client_side_validation and (
  2941. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  2942. ): # noqa: E501
  2943. raise ApiValueError(
  2944. "Missing the required parameter `contract` when calling `cancel_futures_orders`"
  2945. ) # noqa: E501
  2946. collection_formats = {}
  2947. path_params = {}
  2948. if 'settle' in local_var_params:
  2949. path_params['settle'] = local_var_params['settle'] # noqa: E501
  2950. query_params = []
  2951. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  2952. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  2953. if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501
  2954. query_params.append(('side', local_var_params['side'])) # noqa: E501
  2955. header_params = {}
  2956. form_params = []
  2957. local_var_files = {}
  2958. body_params = None
  2959. # HTTP header `Accept`
  2960. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  2961. # Authentication setting
  2962. auth_settings = ['apiv4'] # noqa: E501
  2963. return self.api_client.call_api(
  2964. '/futures/{settle}/orders',
  2965. 'DELETE',
  2966. path_params,
  2967. query_params,
  2968. header_params,
  2969. body=body_params,
  2970. post_params=form_params,
  2971. files=local_var_files,
  2972. response_type='list[FuturesOrder]', # noqa: E501
  2973. auth_settings=auth_settings,
  2974. async_req=local_var_params.get('async_req'),
  2975. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  2976. _preload_content=local_var_params.get('_preload_content', True),
  2977. _request_timeout=local_var_params.get('_request_timeout'),
  2978. collection_formats=collection_formats,
  2979. )
  2980. def create_batch_futures_order(self, settle, futures_order, **kwargs): # noqa: E501
  2981. """Create a batch of futures orders # noqa: E501
  2982. - Up to 10 orders per request - If any of the order's parameters are missing or in the wrong format, all of them will not be executed, and a http status 400 error will be returned directly - If the parameters are checked and passed, all are executed. Even if there is a business logic error in the middle (such as insufficient funds), it will not affect other execution orders - The returned result is in array format, and the order corresponds to the orders in the request body - In the returned result, the `succeeded` field of type bool indicates whether the execution was successful or not - If the execution is successful, the normal order content is included; if the execution fails, the `label` field is included to indicate the cause of the error - In the rate limiting, each order is counted individually # noqa: E501
  2983. This method makes a synchronous HTTP request by default. To make an
  2984. asynchronous HTTP request, please pass async_req=True
  2985. >>> thread = api.create_batch_futures_order(settle, futures_order, async_req=True)
  2986. >>> result = thread.get()
  2987. :param bool async_req: execute request asynchronously
  2988. :param str settle: Settle currency (required)
  2989. :param list[FuturesOrder] futures_order: (required)
  2990. :param _preload_content: if False, the urllib3.HTTPResponse object will
  2991. be returned without reading/decoding response
  2992. data. Default is True.
  2993. :param _request_timeout: timeout setting for this request. If one
  2994. number provided, it will be total request
  2995. timeout. It can also be a pair (tuple) of
  2996. (connection, read) timeouts.
  2997. :rtype: list[gate_api.BatchFuturesOrder]
  2998. :return: If the method is called asynchronously,
  2999. returns the request thread.
  3000. """
  3001. kwargs['_return_http_data_only'] = True
  3002. return self.create_batch_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501
  3003. def create_batch_futures_order_with_http_info(self, settle, futures_order, **kwargs): # noqa: E501
  3004. """Create a batch of futures orders # noqa: E501
  3005. - Up to 10 orders per request - If any of the order's parameters are missing or in the wrong format, all of them will not be executed, and a http status 400 error will be returned directly - If the parameters are checked and passed, all are executed. Even if there is a business logic error in the middle (such as insufficient funds), it will not affect other execution orders - The returned result is in array format, and the order corresponds to the orders in the request body - In the returned result, the `succeeded` field of type bool indicates whether the execution was successful or not - If the execution is successful, the normal order content is included; if the execution fails, the `label` field is included to indicate the cause of the error - In the rate limiting, each order is counted individually # noqa: E501
  3006. This method makes a synchronous HTTP request by default. To make an
  3007. asynchronous HTTP request, please pass async_req=True
  3008. >>> thread = api.create_batch_futures_order_with_http_info(settle, futures_order, async_req=True)
  3009. >>> result = thread.get()
  3010. :param bool async_req: execute request asynchronously
  3011. :param str settle: Settle currency (required)
  3012. :param list[FuturesOrder] futures_order: (required)
  3013. :param _return_http_data_only: response data without head status code
  3014. and headers
  3015. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3016. be returned without reading/decoding response
  3017. data. Default is True.
  3018. :param _request_timeout: timeout setting for this request. If one
  3019. number provided, it will be total request
  3020. timeout. It can also be a pair (tuple) of
  3021. (connection, read) timeouts.
  3022. :rtype: tuple(list[gate_api.BatchFuturesOrder], status_code(int), headers(HTTPHeaderDict))
  3023. :return: If the method is called asynchronously,
  3024. returns the request thread.
  3025. """
  3026. local_var_params = locals()
  3027. all_params = ['settle', 'futures_order']
  3028. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3029. for k, v in six.iteritems(local_var_params['kwargs']):
  3030. if k not in all_params:
  3031. raise ApiTypeError(
  3032. "Got an unexpected keyword argument '%s'" " to method create_batch_futures_order" % k
  3033. )
  3034. local_var_params[k] = v
  3035. del local_var_params['kwargs']
  3036. # verify the required parameter 'settle' is set
  3037. if self.api_client.client_side_validation and (
  3038. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3039. ): # noqa: E501
  3040. raise ApiValueError(
  3041. "Missing the required parameter `settle` when calling `create_batch_futures_order`"
  3042. ) # noqa: E501
  3043. # verify the required parameter 'futures_order' is set
  3044. if self.api_client.client_side_validation and (
  3045. 'futures_order' not in local_var_params or local_var_params['futures_order'] is None # noqa: E501
  3046. ): # noqa: E501
  3047. raise ApiValueError(
  3048. "Missing the required parameter `futures_order` when calling `create_batch_futures_order`"
  3049. ) # noqa: E501
  3050. collection_formats = {}
  3051. path_params = {}
  3052. if 'settle' in local_var_params:
  3053. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3054. query_params = []
  3055. header_params = {}
  3056. form_params = []
  3057. local_var_files = {}
  3058. body_params = None
  3059. if 'futures_order' in local_var_params:
  3060. body_params = local_var_params['futures_order']
  3061. # HTTP header `Accept`
  3062. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3063. # HTTP header `Content-Type`
  3064. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  3065. ['application/json']
  3066. ) # noqa: E501
  3067. # Authentication setting
  3068. auth_settings = ['apiv4'] # noqa: E501
  3069. return self.api_client.call_api(
  3070. '/futures/{settle}/batch_orders',
  3071. 'POST',
  3072. path_params,
  3073. query_params,
  3074. header_params,
  3075. body=body_params,
  3076. post_params=form_params,
  3077. files=local_var_files,
  3078. response_type='list[BatchFuturesOrder]', # noqa: E501
  3079. auth_settings=auth_settings,
  3080. async_req=local_var_params.get('async_req'),
  3081. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3082. _preload_content=local_var_params.get('_preload_content', True),
  3083. _request_timeout=local_var_params.get('_request_timeout'),
  3084. collection_formats=collection_formats,
  3085. )
  3086. def get_futures_order(self, settle, order_id, **kwargs): # noqa: E501
  3087. """Get a single order # noqa: E501
  3088. Zero-filled order cannot be retrieved 10 minutes after order cancellation # noqa: E501
  3089. This method makes a synchronous HTTP request by default. To make an
  3090. asynchronous HTTP request, please pass async_req=True
  3091. >>> thread = api.get_futures_order(settle, order_id, async_req=True)
  3092. >>> result = thread.get()
  3093. :param bool async_req: execute request asynchronously
  3094. :param str settle: Settle currency (required)
  3095. :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 60 seconds after the end of the order. After that, only order ID is accepted. (required)
  3096. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3097. be returned without reading/decoding response
  3098. data. Default is True.
  3099. :param _request_timeout: timeout setting for this request. If one
  3100. number provided, it will be total request
  3101. timeout. It can also be a pair (tuple) of
  3102. (connection, read) timeouts.
  3103. :rtype: gate_api.FuturesOrder
  3104. :return: If the method is called asynchronously,
  3105. returns the request thread.
  3106. """
  3107. kwargs['_return_http_data_only'] = True
  3108. return self.get_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501
  3109. def get_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501
  3110. """Get a single order # noqa: E501
  3111. Zero-filled order cannot be retrieved 10 minutes after order cancellation # noqa: E501
  3112. This method makes a synchronous HTTP request by default. To make an
  3113. asynchronous HTTP request, please pass async_req=True
  3114. >>> thread = api.get_futures_order_with_http_info(settle, order_id, async_req=True)
  3115. >>> result = thread.get()
  3116. :param bool async_req: execute request asynchronously
  3117. :param str settle: Settle currency (required)
  3118. :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 60 seconds after the end of the order. After that, only order ID is accepted. (required)
  3119. :param _return_http_data_only: response data without head status code
  3120. and headers
  3121. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3122. be returned without reading/decoding response
  3123. data. Default is True.
  3124. :param _request_timeout: timeout setting for this request. If one
  3125. number provided, it will be total request
  3126. timeout. It can also be a pair (tuple) of
  3127. (connection, read) timeouts.
  3128. :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict))
  3129. :return: If the method is called asynchronously,
  3130. returns the request thread.
  3131. """
  3132. local_var_params = locals()
  3133. all_params = ['settle', 'order_id']
  3134. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3135. for k, v in six.iteritems(local_var_params['kwargs']):
  3136. if k not in all_params:
  3137. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_futures_order" % k)
  3138. local_var_params[k] = v
  3139. del local_var_params['kwargs']
  3140. # verify the required parameter 'settle' is set
  3141. if self.api_client.client_side_validation and (
  3142. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3143. ): # noqa: E501
  3144. raise ApiValueError(
  3145. "Missing the required parameter `settle` when calling `get_futures_order`"
  3146. ) # noqa: E501
  3147. # verify the required parameter 'order_id' is set
  3148. if self.api_client.client_side_validation and (
  3149. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  3150. ): # noqa: E501
  3151. raise ApiValueError(
  3152. "Missing the required parameter `order_id` when calling `get_futures_order`"
  3153. ) # noqa: E501
  3154. collection_formats = {}
  3155. path_params = {}
  3156. if 'settle' in local_var_params:
  3157. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3158. if 'order_id' in local_var_params:
  3159. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  3160. query_params = []
  3161. header_params = {}
  3162. form_params = []
  3163. local_var_files = {}
  3164. body_params = None
  3165. # HTTP header `Accept`
  3166. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3167. # Authentication setting
  3168. auth_settings = ['apiv4'] # noqa: E501
  3169. return self.api_client.call_api(
  3170. '/futures/{settle}/orders/{order_id}',
  3171. 'GET',
  3172. path_params,
  3173. query_params,
  3174. header_params,
  3175. body=body_params,
  3176. post_params=form_params,
  3177. files=local_var_files,
  3178. response_type='FuturesOrder', # noqa: E501
  3179. auth_settings=auth_settings,
  3180. async_req=local_var_params.get('async_req'),
  3181. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3182. _preload_content=local_var_params.get('_preload_content', True),
  3183. _request_timeout=local_var_params.get('_request_timeout'),
  3184. collection_formats=collection_formats,
  3185. )
  3186. def amend_futures_order(self, settle, order_id, futures_order_amendment, **kwargs): # noqa: E501
  3187. """Amend an order # noqa: E501
  3188. This method makes a synchronous HTTP request by default. To make an
  3189. asynchronous HTTP request, please pass async_req=True
  3190. >>> thread = api.amend_futures_order(settle, order_id, futures_order_amendment, async_req=True)
  3191. >>> result = thread.get()
  3192. :param bool async_req: execute request asynchronously
  3193. :param str settle: Settle currency (required)
  3194. :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 60 seconds after the end of the order. After that, only order ID is accepted. (required)
  3195. :param FuturesOrderAmendment futures_order_amendment: (required)
  3196. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3197. be returned without reading/decoding response
  3198. data. Default is True.
  3199. :param _request_timeout: timeout setting for this request. If one
  3200. number provided, it will be total request
  3201. timeout. It can also be a pair (tuple) of
  3202. (connection, read) timeouts.
  3203. :rtype: gate_api.FuturesOrder
  3204. :return: If the method is called asynchronously,
  3205. returns the request thread.
  3206. """
  3207. kwargs['_return_http_data_only'] = True
  3208. return self.amend_futures_order_with_http_info(
  3209. settle, order_id, futures_order_amendment, **kwargs
  3210. ) # noqa: E501
  3211. def amend_futures_order_with_http_info(self, settle, order_id, futures_order_amendment, **kwargs): # noqa: E501
  3212. """Amend an order # noqa: E501
  3213. This method makes a synchronous HTTP request by default. To make an
  3214. asynchronous HTTP request, please pass async_req=True
  3215. >>> thread = api.amend_futures_order_with_http_info(settle, order_id, futures_order_amendment, async_req=True)
  3216. >>> result = thread.get()
  3217. :param bool async_req: execute request asynchronously
  3218. :param str settle: Settle currency (required)
  3219. :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 60 seconds after the end of the order. After that, only order ID is accepted. (required)
  3220. :param FuturesOrderAmendment futures_order_amendment: (required)
  3221. :param _return_http_data_only: response data without head status code
  3222. and headers
  3223. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3224. be returned without reading/decoding response
  3225. data. Default is True.
  3226. :param _request_timeout: timeout setting for this request. If one
  3227. number provided, it will be total request
  3228. timeout. It can also be a pair (tuple) of
  3229. (connection, read) timeouts.
  3230. :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict))
  3231. :return: If the method is called asynchronously,
  3232. returns the request thread.
  3233. """
  3234. local_var_params = locals()
  3235. all_params = ['settle', 'order_id', 'futures_order_amendment']
  3236. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3237. for k, v in six.iteritems(local_var_params['kwargs']):
  3238. if k not in all_params:
  3239. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method amend_futures_order" % k)
  3240. local_var_params[k] = v
  3241. del local_var_params['kwargs']
  3242. # verify the required parameter 'settle' is set
  3243. if self.api_client.client_side_validation and (
  3244. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3245. ): # noqa: E501
  3246. raise ApiValueError(
  3247. "Missing the required parameter `settle` when calling `amend_futures_order`"
  3248. ) # noqa: E501
  3249. # verify the required parameter 'order_id' is set
  3250. if self.api_client.client_side_validation and (
  3251. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  3252. ): # noqa: E501
  3253. raise ApiValueError(
  3254. "Missing the required parameter `order_id` when calling `amend_futures_order`"
  3255. ) # noqa: E501
  3256. # verify the required parameter 'futures_order_amendment' is set
  3257. if self.api_client.client_side_validation and (
  3258. 'futures_order_amendment' not in local_var_params
  3259. or local_var_params['futures_order_amendment'] is None # noqa: E501
  3260. ): # noqa: E501
  3261. raise ApiValueError(
  3262. "Missing the required parameter `futures_order_amendment` when calling `amend_futures_order`"
  3263. ) # noqa: E501
  3264. collection_formats = {}
  3265. path_params = {}
  3266. if 'settle' in local_var_params:
  3267. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3268. if 'order_id' in local_var_params:
  3269. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  3270. query_params = []
  3271. header_params = {}
  3272. form_params = []
  3273. local_var_files = {}
  3274. body_params = None
  3275. if 'futures_order_amendment' in local_var_params:
  3276. body_params = local_var_params['futures_order_amendment']
  3277. # HTTP header `Accept`
  3278. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3279. # HTTP header `Content-Type`
  3280. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  3281. ['application/json']
  3282. ) # noqa: E501
  3283. # Authentication setting
  3284. auth_settings = ['apiv4'] # noqa: E501
  3285. return self.api_client.call_api(
  3286. '/futures/{settle}/orders/{order_id}',
  3287. 'PUT',
  3288. path_params,
  3289. query_params,
  3290. header_params,
  3291. body=body_params,
  3292. post_params=form_params,
  3293. files=local_var_files,
  3294. response_type='FuturesOrder', # noqa: E501
  3295. auth_settings=auth_settings,
  3296. async_req=local_var_params.get('async_req'),
  3297. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3298. _preload_content=local_var_params.get('_preload_content', True),
  3299. _request_timeout=local_var_params.get('_request_timeout'),
  3300. collection_formats=collection_formats,
  3301. )
  3302. def cancel_futures_order(self, settle, order_id, **kwargs): # noqa: E501
  3303. """Cancel a single order # noqa: E501
  3304. This method makes a synchronous HTTP request by default. To make an
  3305. asynchronous HTTP request, please pass async_req=True
  3306. >>> thread = api.cancel_futures_order(settle, order_id, async_req=True)
  3307. >>> result = thread.get()
  3308. :param bool async_req: execute request asynchronously
  3309. :param str settle: Settle currency (required)
  3310. :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 60 seconds after the end of the order. After that, only order ID is accepted. (required)
  3311. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3312. be returned without reading/decoding response
  3313. data. Default is True.
  3314. :param _request_timeout: timeout setting for this request. If one
  3315. number provided, it will be total request
  3316. timeout. It can also be a pair (tuple) of
  3317. (connection, read) timeouts.
  3318. :rtype: gate_api.FuturesOrder
  3319. :return: If the method is called asynchronously,
  3320. returns the request thread.
  3321. """
  3322. kwargs['_return_http_data_only'] = True
  3323. return self.cancel_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501
  3324. def cancel_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501
  3325. """Cancel a single order # noqa: E501
  3326. This method makes a synchronous HTTP request by default. To make an
  3327. asynchronous HTTP request, please pass async_req=True
  3328. >>> thread = api.cancel_futures_order_with_http_info(settle, order_id, async_req=True)
  3329. >>> result = thread.get()
  3330. :param bool async_req: execute request asynchronously
  3331. :param str settle: Settle currency (required)
  3332. :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 60 seconds after the end of the order. After that, only order ID is accepted. (required)
  3333. :param _return_http_data_only: response data without head status code
  3334. and headers
  3335. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3336. be returned without reading/decoding response
  3337. data. Default is True.
  3338. :param _request_timeout: timeout setting for this request. If one
  3339. number provided, it will be total request
  3340. timeout. It can also be a pair (tuple) of
  3341. (connection, read) timeouts.
  3342. :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict))
  3343. :return: If the method is called asynchronously,
  3344. returns the request thread.
  3345. """
  3346. local_var_params = locals()
  3347. all_params = ['settle', 'order_id']
  3348. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3349. for k, v in six.iteritems(local_var_params['kwargs']):
  3350. if k not in all_params:
  3351. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_futures_order" % k)
  3352. local_var_params[k] = v
  3353. del local_var_params['kwargs']
  3354. # verify the required parameter 'settle' is set
  3355. if self.api_client.client_side_validation and (
  3356. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3357. ): # noqa: E501
  3358. raise ApiValueError(
  3359. "Missing the required parameter `settle` when calling `cancel_futures_order`"
  3360. ) # noqa: E501
  3361. # verify the required parameter 'order_id' is set
  3362. if self.api_client.client_side_validation and (
  3363. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  3364. ): # noqa: E501
  3365. raise ApiValueError(
  3366. "Missing the required parameter `order_id` when calling `cancel_futures_order`"
  3367. ) # noqa: E501
  3368. collection_formats = {}
  3369. path_params = {}
  3370. if 'settle' in local_var_params:
  3371. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3372. if 'order_id' in local_var_params:
  3373. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  3374. query_params = []
  3375. header_params = {}
  3376. form_params = []
  3377. local_var_files = {}
  3378. body_params = None
  3379. # HTTP header `Accept`
  3380. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3381. # Authentication setting
  3382. auth_settings = ['apiv4'] # noqa: E501
  3383. return self.api_client.call_api(
  3384. '/futures/{settle}/orders/{order_id}',
  3385. 'DELETE',
  3386. path_params,
  3387. query_params,
  3388. header_params,
  3389. body=body_params,
  3390. post_params=form_params,
  3391. files=local_var_files,
  3392. response_type='FuturesOrder', # noqa: E501
  3393. auth_settings=auth_settings,
  3394. async_req=local_var_params.get('async_req'),
  3395. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3396. _preload_content=local_var_params.get('_preload_content', True),
  3397. _request_timeout=local_var_params.get('_request_timeout'),
  3398. collection_formats=collection_formats,
  3399. )
  3400. def get_my_trades(self, settle, **kwargs): # noqa: E501
  3401. """List personal trading history # noqa: E501
  3402. This method makes a synchronous HTTP request by default. To make an
  3403. asynchronous HTTP request, please pass async_req=True
  3404. >>> thread = api.get_my_trades(settle, async_req=True)
  3405. >>> result = thread.get()
  3406. :param bool async_req: execute request asynchronously
  3407. :param str settle: Settle currency (required)
  3408. :param str contract: Futures contract, return related data only if specified
  3409. :param int order: Futures order ID, return related data only if specified
  3410. :param int limit: Maximum number of records to be returned in a single list
  3411. :param int offset: List offset, starting from 0
  3412. :param str last_id: Specify list staring point using the `id` of last record in previous list-query results
  3413. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3414. be returned without reading/decoding response
  3415. data. Default is True.
  3416. :param _request_timeout: timeout setting for this request. If one
  3417. number provided, it will be total request
  3418. timeout. It can also be a pair (tuple) of
  3419. (connection, read) timeouts.
  3420. :rtype: list[gate_api.MyFuturesTrade]
  3421. :return: If the method is called asynchronously,
  3422. returns the request thread.
  3423. """
  3424. kwargs['_return_http_data_only'] = True
  3425. return self.get_my_trades_with_http_info(settle, **kwargs) # noqa: E501
  3426. def get_my_trades_with_http_info(self, settle, **kwargs): # noqa: E501
  3427. """List personal trading history # noqa: E501
  3428. This method makes a synchronous HTTP request by default. To make an
  3429. asynchronous HTTP request, please pass async_req=True
  3430. >>> thread = api.get_my_trades_with_http_info(settle, async_req=True)
  3431. >>> result = thread.get()
  3432. :param bool async_req: execute request asynchronously
  3433. :param str settle: Settle currency (required)
  3434. :param str contract: Futures contract, return related data only if specified
  3435. :param int order: Futures order ID, return related data only if specified
  3436. :param int limit: Maximum number of records to be returned in a single list
  3437. :param int offset: List offset, starting from 0
  3438. :param str last_id: Specify list staring point using the `id` of last record in previous list-query results
  3439. :param _return_http_data_only: response data without head status code
  3440. and headers
  3441. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3442. be returned without reading/decoding response
  3443. data. Default is True.
  3444. :param _request_timeout: timeout setting for this request. If one
  3445. number provided, it will be total request
  3446. timeout. It can also be a pair (tuple) of
  3447. (connection, read) timeouts.
  3448. :rtype: tuple(list[gate_api.MyFuturesTrade], status_code(int), headers(HTTPHeaderDict))
  3449. :return: If the method is called asynchronously,
  3450. returns the request thread.
  3451. """
  3452. local_var_params = locals()
  3453. all_params = ['settle', 'contract', 'order', 'limit', 'offset', 'last_id']
  3454. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3455. for k, v in six.iteritems(local_var_params['kwargs']):
  3456. if k not in all_params:
  3457. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_my_trades" % k)
  3458. local_var_params[k] = v
  3459. del local_var_params['kwargs']
  3460. # verify the required parameter 'settle' is set
  3461. if self.api_client.client_side_validation and (
  3462. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3463. ): # noqa: E501
  3464. raise ApiValueError("Missing the required parameter `settle` when calling `get_my_trades`") # noqa: E501
  3465. if (
  3466. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  3467. ): # noqa: E501
  3468. raise ApiValueError(
  3469. "Invalid value for parameter `limit` when calling `get_my_trades`, must be a value less than or equal to `1000`"
  3470. ) # noqa: E501
  3471. if (
  3472. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  3473. ): # noqa: E501
  3474. raise ApiValueError(
  3475. "Invalid value for parameter `limit` when calling `get_my_trades`, must be a value greater than or equal to `1`"
  3476. ) # noqa: E501
  3477. if (
  3478. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  3479. ): # noqa: E501
  3480. raise ApiValueError(
  3481. "Invalid value for parameter `offset` when calling `get_my_trades`, must be a value greater than or equal to `0`"
  3482. ) # noqa: E501
  3483. collection_formats = {}
  3484. path_params = {}
  3485. if 'settle' in local_var_params:
  3486. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3487. query_params = []
  3488. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  3489. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  3490. if 'order' in local_var_params and local_var_params['order'] is not None: # noqa: E501
  3491. query_params.append(('order', local_var_params['order'])) # noqa: E501
  3492. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  3493. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  3494. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  3495. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  3496. if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501
  3497. query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501
  3498. header_params = {}
  3499. form_params = []
  3500. local_var_files = {}
  3501. body_params = None
  3502. # HTTP header `Accept`
  3503. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3504. # Authentication setting
  3505. auth_settings = ['apiv4'] # noqa: E501
  3506. return self.api_client.call_api(
  3507. '/futures/{settle}/my_trades',
  3508. 'GET',
  3509. path_params,
  3510. query_params,
  3511. header_params,
  3512. body=body_params,
  3513. post_params=form_params,
  3514. files=local_var_files,
  3515. response_type='list[MyFuturesTrade]', # noqa: E501
  3516. auth_settings=auth_settings,
  3517. async_req=local_var_params.get('async_req'),
  3518. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3519. _preload_content=local_var_params.get('_preload_content', True),
  3520. _request_timeout=local_var_params.get('_request_timeout'),
  3521. collection_formats=collection_formats,
  3522. )
  3523. def get_my_trades_with_time_range(self, settle, **kwargs): # noqa: E501
  3524. """List personal trading history by time range # noqa: E501
  3525. This method makes a synchronous HTTP request by default. To make an
  3526. asynchronous HTTP request, please pass async_req=True
  3527. >>> thread = api.get_my_trades_with_time_range(settle, async_req=True)
  3528. >>> result = thread.get()
  3529. :param bool async_req: execute request asynchronously
  3530. :param str settle: Settle currency (required)
  3531. :param str contract: Futures contract, return related data only if specified
  3532. :param int _from: Start timestamp
  3533. :param int to: End timestamp
  3534. :param int limit: Maximum number of records to be returned in a single list
  3535. :param int offset: List offset, starting from 0
  3536. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3537. be returned without reading/decoding response
  3538. data. Default is True.
  3539. :param _request_timeout: timeout setting for this request. If one
  3540. number provided, it will be total request
  3541. timeout. It can also be a pair (tuple) of
  3542. (connection, read) timeouts.
  3543. :rtype: list[gate_api.MyFuturesTradeTimeRange]
  3544. :return: If the method is called asynchronously,
  3545. returns the request thread.
  3546. """
  3547. kwargs['_return_http_data_only'] = True
  3548. return self.get_my_trades_with_time_range_with_http_info(settle, **kwargs) # noqa: E501
  3549. def get_my_trades_with_time_range_with_http_info(self, settle, **kwargs): # noqa: E501
  3550. """List personal trading history by time range # noqa: E501
  3551. This method makes a synchronous HTTP request by default. To make an
  3552. asynchronous HTTP request, please pass async_req=True
  3553. >>> thread = api.get_my_trades_with_time_range_with_http_info(settle, async_req=True)
  3554. >>> result = thread.get()
  3555. :param bool async_req: execute request asynchronously
  3556. :param str settle: Settle currency (required)
  3557. :param str contract: Futures contract, return related data only if specified
  3558. :param int _from: Start timestamp
  3559. :param int to: End timestamp
  3560. :param int limit: Maximum number of records to be returned in a single list
  3561. :param int offset: List offset, starting from 0
  3562. :param _return_http_data_only: response data without head status code
  3563. and headers
  3564. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3565. be returned without reading/decoding response
  3566. data. Default is True.
  3567. :param _request_timeout: timeout setting for this request. If one
  3568. number provided, it will be total request
  3569. timeout. It can also be a pair (tuple) of
  3570. (connection, read) timeouts.
  3571. :rtype: tuple(list[gate_api.MyFuturesTradeTimeRange], status_code(int), headers(HTTPHeaderDict))
  3572. :return: If the method is called asynchronously,
  3573. returns the request thread.
  3574. """
  3575. local_var_params = locals()
  3576. all_params = ['settle', 'contract', '_from', 'to', 'limit', 'offset']
  3577. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3578. for k, v in six.iteritems(local_var_params['kwargs']):
  3579. if k not in all_params:
  3580. raise ApiTypeError(
  3581. "Got an unexpected keyword argument '%s'" " to method get_my_trades_with_time_range" % k
  3582. )
  3583. local_var_params[k] = v
  3584. del local_var_params['kwargs']
  3585. # verify the required parameter 'settle' is set
  3586. if self.api_client.client_side_validation and (
  3587. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3588. ): # noqa: E501
  3589. raise ApiValueError(
  3590. "Missing the required parameter `settle` when calling `get_my_trades_with_time_range`"
  3591. ) # noqa: E501
  3592. if (
  3593. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  3594. ): # noqa: E501
  3595. raise ApiValueError(
  3596. "Invalid value for parameter `limit` when calling `get_my_trades_with_time_range`, must be a value less than or equal to `1000`"
  3597. ) # noqa: E501
  3598. if (
  3599. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  3600. ): # noqa: E501
  3601. raise ApiValueError(
  3602. "Invalid value for parameter `limit` when calling `get_my_trades_with_time_range`, must be a value greater than or equal to `1`"
  3603. ) # noqa: E501
  3604. if (
  3605. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  3606. ): # noqa: E501
  3607. raise ApiValueError(
  3608. "Invalid value for parameter `offset` when calling `get_my_trades_with_time_range`, must be a value greater than or equal to `0`"
  3609. ) # noqa: E501
  3610. collection_formats = {}
  3611. path_params = {}
  3612. if 'settle' in local_var_params:
  3613. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3614. query_params = []
  3615. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  3616. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  3617. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  3618. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  3619. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  3620. query_params.append(('to', local_var_params['to'])) # noqa: E501
  3621. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  3622. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  3623. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  3624. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  3625. header_params = {}
  3626. form_params = []
  3627. local_var_files = {}
  3628. body_params = None
  3629. # HTTP header `Accept`
  3630. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3631. # Authentication setting
  3632. auth_settings = ['apiv4'] # noqa: E501
  3633. return self.api_client.call_api(
  3634. '/futures/{settle}/my_trades_timerange',
  3635. 'GET',
  3636. path_params,
  3637. query_params,
  3638. header_params,
  3639. body=body_params,
  3640. post_params=form_params,
  3641. files=local_var_files,
  3642. response_type='list[MyFuturesTradeTimeRange]', # noqa: E501
  3643. auth_settings=auth_settings,
  3644. async_req=local_var_params.get('async_req'),
  3645. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3646. _preload_content=local_var_params.get('_preload_content', True),
  3647. _request_timeout=local_var_params.get('_request_timeout'),
  3648. collection_formats=collection_formats,
  3649. )
  3650. def list_position_close(self, settle, **kwargs): # noqa: E501
  3651. """List position close history # noqa: E501
  3652. This method makes a synchronous HTTP request by default. To make an
  3653. asynchronous HTTP request, please pass async_req=True
  3654. >>> thread = api.list_position_close(settle, async_req=True)
  3655. >>> result = thread.get()
  3656. :param bool async_req: execute request asynchronously
  3657. :param str settle: Settle currency (required)
  3658. :param str contract: Futures contract, return related data only if specified
  3659. :param int limit: Maximum number of records to be returned in a single list
  3660. :param int offset: List offset, starting from 0
  3661. :param int _from: Start timestamp
  3662. :param int to: End timestamp
  3663. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3664. be returned without reading/decoding response
  3665. data. Default is True.
  3666. :param _request_timeout: timeout setting for this request. If one
  3667. number provided, it will be total request
  3668. timeout. It can also be a pair (tuple) of
  3669. (connection, read) timeouts.
  3670. :rtype: list[gate_api.PositionClose]
  3671. :return: If the method is called asynchronously,
  3672. returns the request thread.
  3673. """
  3674. kwargs['_return_http_data_only'] = True
  3675. return self.list_position_close_with_http_info(settle, **kwargs) # noqa: E501
  3676. def list_position_close_with_http_info(self, settle, **kwargs): # noqa: E501
  3677. """List position close history # noqa: E501
  3678. This method makes a synchronous HTTP request by default. To make an
  3679. asynchronous HTTP request, please pass async_req=True
  3680. >>> thread = api.list_position_close_with_http_info(settle, async_req=True)
  3681. >>> result = thread.get()
  3682. :param bool async_req: execute request asynchronously
  3683. :param str settle: Settle currency (required)
  3684. :param str contract: Futures contract, return related data only if specified
  3685. :param int limit: Maximum number of records to be returned in a single list
  3686. :param int offset: List offset, starting from 0
  3687. :param int _from: Start timestamp
  3688. :param int to: End timestamp
  3689. :param _return_http_data_only: response data without head status code
  3690. and headers
  3691. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3692. be returned without reading/decoding response
  3693. data. Default is True.
  3694. :param _request_timeout: timeout setting for this request. If one
  3695. number provided, it will be total request
  3696. timeout. It can also be a pair (tuple) of
  3697. (connection, read) timeouts.
  3698. :rtype: tuple(list[gate_api.PositionClose], status_code(int), headers(HTTPHeaderDict))
  3699. :return: If the method is called asynchronously,
  3700. returns the request thread.
  3701. """
  3702. local_var_params = locals()
  3703. all_params = ['settle', 'contract', 'limit', 'offset', '_from', 'to']
  3704. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3705. for k, v in six.iteritems(local_var_params['kwargs']):
  3706. if k not in all_params:
  3707. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_position_close" % k)
  3708. local_var_params[k] = v
  3709. del local_var_params['kwargs']
  3710. # verify the required parameter 'settle' is set
  3711. if self.api_client.client_side_validation and (
  3712. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3713. ): # noqa: E501
  3714. raise ApiValueError(
  3715. "Missing the required parameter `settle` when calling `list_position_close`"
  3716. ) # noqa: E501
  3717. if (
  3718. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  3719. ): # noqa: E501
  3720. raise ApiValueError(
  3721. "Invalid value for parameter `limit` when calling `list_position_close`, must be a value less than or equal to `1000`"
  3722. ) # noqa: E501
  3723. if (
  3724. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  3725. ): # noqa: E501
  3726. raise ApiValueError(
  3727. "Invalid value for parameter `limit` when calling `list_position_close`, must be a value greater than or equal to `1`"
  3728. ) # noqa: E501
  3729. if (
  3730. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  3731. ): # noqa: E501
  3732. raise ApiValueError(
  3733. "Invalid value for parameter `offset` when calling `list_position_close`, must be a value greater than or equal to `0`"
  3734. ) # noqa: E501
  3735. collection_formats = {}
  3736. path_params = {}
  3737. if 'settle' in local_var_params:
  3738. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3739. query_params = []
  3740. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  3741. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  3742. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  3743. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  3744. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  3745. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  3746. if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501
  3747. query_params.append(('from', local_var_params['_from'])) # noqa: E501
  3748. if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501
  3749. query_params.append(('to', local_var_params['to'])) # noqa: E501
  3750. header_params = {}
  3751. form_params = []
  3752. local_var_files = {}
  3753. body_params = None
  3754. # HTTP header `Accept`
  3755. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3756. # Authentication setting
  3757. auth_settings = ['apiv4'] # noqa: E501
  3758. return self.api_client.call_api(
  3759. '/futures/{settle}/position_close',
  3760. 'GET',
  3761. path_params,
  3762. query_params,
  3763. header_params,
  3764. body=body_params,
  3765. post_params=form_params,
  3766. files=local_var_files,
  3767. response_type='list[PositionClose]', # noqa: E501
  3768. auth_settings=auth_settings,
  3769. async_req=local_var_params.get('async_req'),
  3770. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3771. _preload_content=local_var_params.get('_preload_content', True),
  3772. _request_timeout=local_var_params.get('_request_timeout'),
  3773. collection_formats=collection_formats,
  3774. )
  3775. def list_liquidates(self, settle, **kwargs): # noqa: E501
  3776. """List liquidation history # noqa: E501
  3777. This method makes a synchronous HTTP request by default. To make an
  3778. asynchronous HTTP request, please pass async_req=True
  3779. >>> thread = api.list_liquidates(settle, async_req=True)
  3780. >>> result = thread.get()
  3781. :param bool async_req: execute request asynchronously
  3782. :param str settle: Settle currency (required)
  3783. :param str contract: Futures contract, return related data only if specified
  3784. :param int limit: Maximum number of records to be returned in a single list
  3785. :param int at: Specify a liquidation timestamp
  3786. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3787. be returned without reading/decoding response
  3788. data. Default is True.
  3789. :param _request_timeout: timeout setting for this request. If one
  3790. number provided, it will be total request
  3791. timeout. It can also be a pair (tuple) of
  3792. (connection, read) timeouts.
  3793. :rtype: list[gate_api.FuturesLiquidate]
  3794. :return: If the method is called asynchronously,
  3795. returns the request thread.
  3796. """
  3797. kwargs['_return_http_data_only'] = True
  3798. return self.list_liquidates_with_http_info(settle, **kwargs) # noqa: E501
  3799. def list_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501
  3800. """List liquidation history # noqa: E501
  3801. This method makes a synchronous HTTP request by default. To make an
  3802. asynchronous HTTP request, please pass async_req=True
  3803. >>> thread = api.list_liquidates_with_http_info(settle, async_req=True)
  3804. >>> result = thread.get()
  3805. :param bool async_req: execute request asynchronously
  3806. :param str settle: Settle currency (required)
  3807. :param str contract: Futures contract, return related data only if specified
  3808. :param int limit: Maximum number of records to be returned in a single list
  3809. :param int at: Specify a liquidation timestamp
  3810. :param _return_http_data_only: response data without head status code
  3811. and headers
  3812. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3813. be returned without reading/decoding response
  3814. data. Default is True.
  3815. :param _request_timeout: timeout setting for this request. If one
  3816. number provided, it will be total request
  3817. timeout. It can also be a pair (tuple) of
  3818. (connection, read) timeouts.
  3819. :rtype: tuple(list[gate_api.FuturesLiquidate], status_code(int), headers(HTTPHeaderDict))
  3820. :return: If the method is called asynchronously,
  3821. returns the request thread.
  3822. """
  3823. local_var_params = locals()
  3824. all_params = ['settle', 'contract', 'limit', 'at']
  3825. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3826. for k, v in six.iteritems(local_var_params['kwargs']):
  3827. if k not in all_params:
  3828. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_liquidates" % k)
  3829. local_var_params[k] = v
  3830. del local_var_params['kwargs']
  3831. # verify the required parameter 'settle' is set
  3832. if self.api_client.client_side_validation and (
  3833. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3834. ): # noqa: E501
  3835. raise ApiValueError("Missing the required parameter `settle` when calling `list_liquidates`") # noqa: E501
  3836. if (
  3837. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  3838. ): # noqa: E501
  3839. raise ApiValueError(
  3840. "Invalid value for parameter `limit` when calling `list_liquidates`, must be a value less than or equal to `1000`"
  3841. ) # noqa: E501
  3842. if (
  3843. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  3844. ): # noqa: E501
  3845. raise ApiValueError(
  3846. "Invalid value for parameter `limit` when calling `list_liquidates`, must be a value greater than or equal to `1`"
  3847. ) # noqa: E501
  3848. collection_formats = {}
  3849. path_params = {}
  3850. if 'settle' in local_var_params:
  3851. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3852. query_params = []
  3853. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  3854. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  3855. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  3856. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  3857. if 'at' in local_var_params and local_var_params['at'] is not None: # noqa: E501
  3858. query_params.append(('at', local_var_params['at'])) # noqa: E501
  3859. header_params = {}
  3860. form_params = []
  3861. local_var_files = {}
  3862. body_params = None
  3863. # HTTP header `Accept`
  3864. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3865. # Authentication setting
  3866. auth_settings = ['apiv4'] # noqa: E501
  3867. return self.api_client.call_api(
  3868. '/futures/{settle}/liquidates',
  3869. 'GET',
  3870. path_params,
  3871. query_params,
  3872. header_params,
  3873. body=body_params,
  3874. post_params=form_params,
  3875. files=local_var_files,
  3876. response_type='list[FuturesLiquidate]', # noqa: E501
  3877. auth_settings=auth_settings,
  3878. async_req=local_var_params.get('async_req'),
  3879. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3880. _preload_content=local_var_params.get('_preload_content', True),
  3881. _request_timeout=local_var_params.get('_request_timeout'),
  3882. collection_formats=collection_formats,
  3883. )
  3884. def list_auto_deleverages(self, settle, **kwargs): # noqa: E501
  3885. """List Auto-Deleveraging History # noqa: E501
  3886. This method makes a synchronous HTTP request by default. To make an
  3887. asynchronous HTTP request, please pass async_req=True
  3888. >>> thread = api.list_auto_deleverages(settle, async_req=True)
  3889. >>> result = thread.get()
  3890. :param bool async_req: execute request asynchronously
  3891. :param str settle: Settle currency (required)
  3892. :param str contract: Futures contract, return related data only if specified
  3893. :param int limit: Maximum number of records to be returned in a single list
  3894. :param int at: Specify an auto-deleveraging timestamp
  3895. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3896. be returned without reading/decoding response
  3897. data. Default is True.
  3898. :param _request_timeout: timeout setting for this request. If one
  3899. number provided, it will be total request
  3900. timeout. It can also be a pair (tuple) of
  3901. (connection, read) timeouts.
  3902. :rtype: list[gate_api.FuturesAutoDeleverage]
  3903. :return: If the method is called asynchronously,
  3904. returns the request thread.
  3905. """
  3906. kwargs['_return_http_data_only'] = True
  3907. return self.list_auto_deleverages_with_http_info(settle, **kwargs) # noqa: E501
  3908. def list_auto_deleverages_with_http_info(self, settle, **kwargs): # noqa: E501
  3909. """List Auto-Deleveraging History # noqa: E501
  3910. This method makes a synchronous HTTP request by default. To make an
  3911. asynchronous HTTP request, please pass async_req=True
  3912. >>> thread = api.list_auto_deleverages_with_http_info(settle, async_req=True)
  3913. >>> result = thread.get()
  3914. :param bool async_req: execute request asynchronously
  3915. :param str settle: Settle currency (required)
  3916. :param str contract: Futures contract, return related data only if specified
  3917. :param int limit: Maximum number of records to be returned in a single list
  3918. :param int at: Specify an auto-deleveraging timestamp
  3919. :param _return_http_data_only: response data without head status code
  3920. and headers
  3921. :param _preload_content: if False, the urllib3.HTTPResponse object will
  3922. be returned without reading/decoding response
  3923. data. Default is True.
  3924. :param _request_timeout: timeout setting for this request. If one
  3925. number provided, it will be total request
  3926. timeout. It can also be a pair (tuple) of
  3927. (connection, read) timeouts.
  3928. :rtype: tuple(list[gate_api.FuturesAutoDeleverage], status_code(int), headers(HTTPHeaderDict))
  3929. :return: If the method is called asynchronously,
  3930. returns the request thread.
  3931. """
  3932. local_var_params = locals()
  3933. all_params = ['settle', 'contract', 'limit', 'at']
  3934. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  3935. for k, v in six.iteritems(local_var_params['kwargs']):
  3936. if k not in all_params:
  3937. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_auto_deleverages" % k)
  3938. local_var_params[k] = v
  3939. del local_var_params['kwargs']
  3940. # verify the required parameter 'settle' is set
  3941. if self.api_client.client_side_validation and (
  3942. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  3943. ): # noqa: E501
  3944. raise ApiValueError(
  3945. "Missing the required parameter `settle` when calling `list_auto_deleverages`"
  3946. ) # noqa: E501
  3947. if (
  3948. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  3949. ): # noqa: E501
  3950. raise ApiValueError(
  3951. "Invalid value for parameter `limit` when calling `list_auto_deleverages`, must be a value less than or equal to `1000`"
  3952. ) # noqa: E501
  3953. if (
  3954. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  3955. ): # noqa: E501
  3956. raise ApiValueError(
  3957. "Invalid value for parameter `limit` when calling `list_auto_deleverages`, must be a value greater than or equal to `1`"
  3958. ) # noqa: E501
  3959. collection_formats = {}
  3960. path_params = {}
  3961. if 'settle' in local_var_params:
  3962. path_params['settle'] = local_var_params['settle'] # noqa: E501
  3963. query_params = []
  3964. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  3965. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  3966. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  3967. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  3968. if 'at' in local_var_params and local_var_params['at'] is not None: # noqa: E501
  3969. query_params.append(('at', local_var_params['at'])) # noqa: E501
  3970. header_params = {}
  3971. form_params = []
  3972. local_var_files = {}
  3973. body_params = None
  3974. # HTTP header `Accept`
  3975. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  3976. # Authentication setting
  3977. auth_settings = ['apiv4'] # noqa: E501
  3978. return self.api_client.call_api(
  3979. '/futures/{settle}/auto_deleverages',
  3980. 'GET',
  3981. path_params,
  3982. query_params,
  3983. header_params,
  3984. body=body_params,
  3985. post_params=form_params,
  3986. files=local_var_files,
  3987. response_type='list[FuturesAutoDeleverage]', # noqa: E501
  3988. auth_settings=auth_settings,
  3989. async_req=local_var_params.get('async_req'),
  3990. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  3991. _preload_content=local_var_params.get('_preload_content', True),
  3992. _request_timeout=local_var_params.get('_request_timeout'),
  3993. collection_formats=collection_formats,
  3994. )
  3995. def countdown_cancel_all_futures(self, settle, countdown_cancel_all_futures_task, **kwargs): # noqa: E501
  3996. """Countdown cancel orders # noqa: E501
  3997. 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
  3998. This method makes a synchronous HTTP request by default. To make an
  3999. asynchronous HTTP request, please pass async_req=True
  4000. >>> thread = api.countdown_cancel_all_futures(settle, countdown_cancel_all_futures_task, async_req=True)
  4001. >>> result = thread.get()
  4002. :param bool async_req: execute request asynchronously
  4003. :param str settle: Settle currency (required)
  4004. :param CountdownCancelAllFuturesTask countdown_cancel_all_futures_task: (required)
  4005. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4006. be returned without reading/decoding response
  4007. data. Default is True.
  4008. :param _request_timeout: timeout setting for this request. If one
  4009. number provided, it will be total request
  4010. timeout. It can also be a pair (tuple) of
  4011. (connection, read) timeouts.
  4012. :rtype: gate_api.TriggerTime
  4013. :return: If the method is called asynchronously,
  4014. returns the request thread.
  4015. """
  4016. kwargs['_return_http_data_only'] = True
  4017. return self.countdown_cancel_all_futures_with_http_info(
  4018. settle, countdown_cancel_all_futures_task, **kwargs
  4019. ) # noqa: E501
  4020. def countdown_cancel_all_futures_with_http_info(
  4021. self, settle, countdown_cancel_all_futures_task, **kwargs
  4022. ): # noqa: E501
  4023. """Countdown cancel orders # noqa: E501
  4024. 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
  4025. This method makes a synchronous HTTP request by default. To make an
  4026. asynchronous HTTP request, please pass async_req=True
  4027. >>> thread = api.countdown_cancel_all_futures_with_http_info(settle, countdown_cancel_all_futures_task, async_req=True)
  4028. >>> result = thread.get()
  4029. :param bool async_req: execute request asynchronously
  4030. :param str settle: Settle currency (required)
  4031. :param CountdownCancelAllFuturesTask countdown_cancel_all_futures_task: (required)
  4032. :param _return_http_data_only: response data without head status code
  4033. and headers
  4034. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4035. be returned without reading/decoding response
  4036. data. Default is True.
  4037. :param _request_timeout: timeout setting for this request. If one
  4038. number provided, it will be total request
  4039. timeout. It can also be a pair (tuple) of
  4040. (connection, read) timeouts.
  4041. :rtype: tuple(gate_api.TriggerTime, status_code(int), headers(HTTPHeaderDict))
  4042. :return: If the method is called asynchronously,
  4043. returns the request thread.
  4044. """
  4045. local_var_params = locals()
  4046. all_params = ['settle', 'countdown_cancel_all_futures_task']
  4047. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  4048. for k, v in six.iteritems(local_var_params['kwargs']):
  4049. if k not in all_params:
  4050. raise ApiTypeError(
  4051. "Got an unexpected keyword argument '%s'" " to method countdown_cancel_all_futures" % k
  4052. )
  4053. local_var_params[k] = v
  4054. del local_var_params['kwargs']
  4055. # verify the required parameter 'settle' is set
  4056. if self.api_client.client_side_validation and (
  4057. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  4058. ): # noqa: E501
  4059. raise ApiValueError(
  4060. "Missing the required parameter `settle` when calling `countdown_cancel_all_futures`"
  4061. ) # noqa: E501
  4062. # verify the required parameter 'countdown_cancel_all_futures_task' is set
  4063. if self.api_client.client_side_validation and (
  4064. 'countdown_cancel_all_futures_task' not in local_var_params
  4065. or local_var_params['countdown_cancel_all_futures_task'] is None # noqa: E501
  4066. ): # noqa: E501
  4067. raise ApiValueError(
  4068. "Missing the required parameter `countdown_cancel_all_futures_task` when calling `countdown_cancel_all_futures`"
  4069. ) # noqa: E501
  4070. collection_formats = {}
  4071. path_params = {}
  4072. if 'settle' in local_var_params:
  4073. path_params['settle'] = local_var_params['settle'] # noqa: E501
  4074. query_params = []
  4075. header_params = {}
  4076. form_params = []
  4077. local_var_files = {}
  4078. body_params = None
  4079. if 'countdown_cancel_all_futures_task' in local_var_params:
  4080. body_params = local_var_params['countdown_cancel_all_futures_task']
  4081. # HTTP header `Accept`
  4082. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  4083. # HTTP header `Content-Type`
  4084. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  4085. ['application/json']
  4086. ) # noqa: E501
  4087. # Authentication setting
  4088. auth_settings = ['apiv4'] # noqa: E501
  4089. return self.api_client.call_api(
  4090. '/futures/{settle}/countdown_cancel_all',
  4091. 'POST',
  4092. path_params,
  4093. query_params,
  4094. header_params,
  4095. body=body_params,
  4096. post_params=form_params,
  4097. files=local_var_files,
  4098. response_type='TriggerTime', # noqa: E501
  4099. auth_settings=auth_settings,
  4100. async_req=local_var_params.get('async_req'),
  4101. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  4102. _preload_content=local_var_params.get('_preload_content', True),
  4103. _request_timeout=local_var_params.get('_request_timeout'),
  4104. collection_formats=collection_formats,
  4105. )
  4106. def list_price_triggered_orders(self, settle, status, **kwargs): # noqa: E501
  4107. """List all auto orders # noqa: E501
  4108. This method makes a synchronous HTTP request by default. To make an
  4109. asynchronous HTTP request, please pass async_req=True
  4110. >>> thread = api.list_price_triggered_orders(settle, status, async_req=True)
  4111. >>> result = thread.get()
  4112. :param bool async_req: execute request asynchronously
  4113. :param str settle: Settle currency (required)
  4114. :param str status: Only list the orders with this status (required)
  4115. :param str contract: Futures contract, return related data only if specified
  4116. :param int limit: Maximum number of records to be returned in a single list
  4117. :param int offset: List offset, starting from 0
  4118. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4119. be returned without reading/decoding response
  4120. data. Default is True.
  4121. :param _request_timeout: timeout setting for this request. If one
  4122. number provided, it will be total request
  4123. timeout. It can also be a pair (tuple) of
  4124. (connection, read) timeouts.
  4125. :rtype: list[gate_api.FuturesPriceTriggeredOrder]
  4126. :return: If the method is called asynchronously,
  4127. returns the request thread.
  4128. """
  4129. kwargs['_return_http_data_only'] = True
  4130. return self.list_price_triggered_orders_with_http_info(settle, status, **kwargs) # noqa: E501
  4131. def list_price_triggered_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501
  4132. """List all auto orders # noqa: E501
  4133. This method makes a synchronous HTTP request by default. To make an
  4134. asynchronous HTTP request, please pass async_req=True
  4135. >>> thread = api.list_price_triggered_orders_with_http_info(settle, status, async_req=True)
  4136. >>> result = thread.get()
  4137. :param bool async_req: execute request asynchronously
  4138. :param str settle: Settle currency (required)
  4139. :param str status: Only list the orders with this status (required)
  4140. :param str contract: Futures contract, return related data only if specified
  4141. :param int limit: Maximum number of records to be returned in a single list
  4142. :param int offset: List offset, starting from 0
  4143. :param _return_http_data_only: response data without head status code
  4144. and headers
  4145. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4146. be returned without reading/decoding response
  4147. data. Default is True.
  4148. :param _request_timeout: timeout setting for this request. If one
  4149. number provided, it will be total request
  4150. timeout. It can also be a pair (tuple) of
  4151. (connection, read) timeouts.
  4152. :rtype: tuple(list[gate_api.FuturesPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict))
  4153. :return: If the method is called asynchronously,
  4154. returns the request thread.
  4155. """
  4156. local_var_params = locals()
  4157. all_params = ['settle', 'status', 'contract', 'limit', 'offset']
  4158. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  4159. for k, v in six.iteritems(local_var_params['kwargs']):
  4160. if k not in all_params:
  4161. raise ApiTypeError(
  4162. "Got an unexpected keyword argument '%s'" " to method list_price_triggered_orders" % k
  4163. )
  4164. local_var_params[k] = v
  4165. del local_var_params['kwargs']
  4166. # verify the required parameter 'settle' is set
  4167. if self.api_client.client_side_validation and (
  4168. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  4169. ): # noqa: E501
  4170. raise ApiValueError(
  4171. "Missing the required parameter `settle` when calling `list_price_triggered_orders`"
  4172. ) # noqa: E501
  4173. # verify the required parameter 'status' is set
  4174. if self.api_client.client_side_validation and (
  4175. 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501
  4176. ): # noqa: E501
  4177. raise ApiValueError(
  4178. "Missing the required parameter `status` when calling `list_price_triggered_orders`"
  4179. ) # noqa: E501
  4180. if (
  4181. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000
  4182. ): # noqa: E501
  4183. raise ApiValueError(
  4184. "Invalid value for parameter `limit` when calling `list_price_triggered_orders`, must be a value less than or equal to `1000`"
  4185. ) # noqa: E501
  4186. if (
  4187. self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1
  4188. ): # noqa: E501
  4189. raise ApiValueError(
  4190. "Invalid value for parameter `limit` when calling `list_price_triggered_orders`, must be a value greater than or equal to `1`"
  4191. ) # noqa: E501
  4192. if (
  4193. self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0
  4194. ): # noqa: E501
  4195. raise ApiValueError(
  4196. "Invalid value for parameter `offset` when calling `list_price_triggered_orders`, must be a value greater than or equal to `0`"
  4197. ) # noqa: E501
  4198. collection_formats = {}
  4199. path_params = {}
  4200. if 'settle' in local_var_params:
  4201. path_params['settle'] = local_var_params['settle'] # noqa: E501
  4202. query_params = []
  4203. if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501
  4204. query_params.append(('status', local_var_params['status'])) # noqa: E501
  4205. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  4206. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  4207. if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501
  4208. query_params.append(('limit', local_var_params['limit'])) # noqa: E501
  4209. if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501
  4210. query_params.append(('offset', local_var_params['offset'])) # noqa: E501
  4211. header_params = {}
  4212. form_params = []
  4213. local_var_files = {}
  4214. body_params = None
  4215. # HTTP header `Accept`
  4216. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  4217. # Authentication setting
  4218. auth_settings = ['apiv4'] # noqa: E501
  4219. return self.api_client.call_api(
  4220. '/futures/{settle}/price_orders',
  4221. 'GET',
  4222. path_params,
  4223. query_params,
  4224. header_params,
  4225. body=body_params,
  4226. post_params=form_params,
  4227. files=local_var_files,
  4228. response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501
  4229. auth_settings=auth_settings,
  4230. async_req=local_var_params.get('async_req'),
  4231. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  4232. _preload_content=local_var_params.get('_preload_content', True),
  4233. _request_timeout=local_var_params.get('_request_timeout'),
  4234. collection_formats=collection_formats,
  4235. )
  4236. def create_price_triggered_order(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501
  4237. """Create a price-triggered order # noqa: E501
  4238. This method makes a synchronous HTTP request by default. To make an
  4239. asynchronous HTTP request, please pass async_req=True
  4240. >>> thread = api.create_price_triggered_order(settle, futures_price_triggered_order, async_req=True)
  4241. >>> result = thread.get()
  4242. :param bool async_req: execute request asynchronously
  4243. :param str settle: Settle currency (required)
  4244. :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required)
  4245. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4246. be returned without reading/decoding response
  4247. data. Default is True.
  4248. :param _request_timeout: timeout setting for this request. If one
  4249. number provided, it will be total request
  4250. timeout. It can also be a pair (tuple) of
  4251. (connection, read) timeouts.
  4252. :rtype: gate_api.TriggerOrderResponse
  4253. :return: If the method is called asynchronously,
  4254. returns the request thread.
  4255. """
  4256. kwargs['_return_http_data_only'] = True
  4257. return self.create_price_triggered_order_with_http_info(
  4258. settle, futures_price_triggered_order, **kwargs
  4259. ) # noqa: E501
  4260. def create_price_triggered_order_with_http_info(
  4261. self, settle, futures_price_triggered_order, **kwargs
  4262. ): # noqa: E501
  4263. """Create a price-triggered order # noqa: E501
  4264. This method makes a synchronous HTTP request by default. To make an
  4265. asynchronous HTTP request, please pass async_req=True
  4266. >>> thread = api.create_price_triggered_order_with_http_info(settle, futures_price_triggered_order, async_req=True)
  4267. >>> result = thread.get()
  4268. :param bool async_req: execute request asynchronously
  4269. :param str settle: Settle currency (required)
  4270. :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required)
  4271. :param _return_http_data_only: response data without head status code
  4272. and headers
  4273. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4274. be returned without reading/decoding response
  4275. data. Default is True.
  4276. :param _request_timeout: timeout setting for this request. If one
  4277. number provided, it will be total request
  4278. timeout. It can also be a pair (tuple) of
  4279. (connection, read) timeouts.
  4280. :rtype: tuple(gate_api.TriggerOrderResponse, status_code(int), headers(HTTPHeaderDict))
  4281. :return: If the method is called asynchronously,
  4282. returns the request thread.
  4283. """
  4284. local_var_params = locals()
  4285. all_params = ['settle', 'futures_price_triggered_order']
  4286. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  4287. for k, v in six.iteritems(local_var_params['kwargs']):
  4288. if k not in all_params:
  4289. raise ApiTypeError(
  4290. "Got an unexpected keyword argument '%s'" " to method create_price_triggered_order" % k
  4291. )
  4292. local_var_params[k] = v
  4293. del local_var_params['kwargs']
  4294. # verify the required parameter 'settle' is set
  4295. if self.api_client.client_side_validation and (
  4296. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  4297. ): # noqa: E501
  4298. raise ApiValueError(
  4299. "Missing the required parameter `settle` when calling `create_price_triggered_order`"
  4300. ) # noqa: E501
  4301. # verify the required parameter 'futures_price_triggered_order' is set
  4302. if self.api_client.client_side_validation and (
  4303. 'futures_price_triggered_order' not in local_var_params
  4304. or local_var_params['futures_price_triggered_order'] is None # noqa: E501
  4305. ): # noqa: E501
  4306. raise ApiValueError(
  4307. "Missing the required parameter `futures_price_triggered_order` when calling `create_price_triggered_order`"
  4308. ) # noqa: E501
  4309. collection_formats = {}
  4310. path_params = {}
  4311. if 'settle' in local_var_params:
  4312. path_params['settle'] = local_var_params['settle'] # noqa: E501
  4313. query_params = []
  4314. header_params = {}
  4315. form_params = []
  4316. local_var_files = {}
  4317. body_params = None
  4318. if 'futures_price_triggered_order' in local_var_params:
  4319. body_params = local_var_params['futures_price_triggered_order']
  4320. # HTTP header `Accept`
  4321. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  4322. # HTTP header `Content-Type`
  4323. header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
  4324. ['application/json']
  4325. ) # noqa: E501
  4326. # Authentication setting
  4327. auth_settings = ['apiv4'] # noqa: E501
  4328. return self.api_client.call_api(
  4329. '/futures/{settle}/price_orders',
  4330. 'POST',
  4331. path_params,
  4332. query_params,
  4333. header_params,
  4334. body=body_params,
  4335. post_params=form_params,
  4336. files=local_var_files,
  4337. response_type='TriggerOrderResponse', # noqa: E501
  4338. auth_settings=auth_settings,
  4339. async_req=local_var_params.get('async_req'),
  4340. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  4341. _preload_content=local_var_params.get('_preload_content', True),
  4342. _request_timeout=local_var_params.get('_request_timeout'),
  4343. collection_formats=collection_formats,
  4344. )
  4345. def cancel_price_triggered_order_list(self, settle, contract, **kwargs): # noqa: E501
  4346. """Cancel all open orders # noqa: E501
  4347. This method makes a synchronous HTTP request by default. To make an
  4348. asynchronous HTTP request, please pass async_req=True
  4349. >>> thread = api.cancel_price_triggered_order_list(settle, contract, async_req=True)
  4350. >>> result = thread.get()
  4351. :param bool async_req: execute request asynchronously
  4352. :param str settle: Settle currency (required)
  4353. :param str contract: Futures contract (required)
  4354. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4355. be returned without reading/decoding response
  4356. data. Default is True.
  4357. :param _request_timeout: timeout setting for this request. If one
  4358. number provided, it will be total request
  4359. timeout. It can also be a pair (tuple) of
  4360. (connection, read) timeouts.
  4361. :rtype: list[gate_api.FuturesPriceTriggeredOrder]
  4362. :return: If the method is called asynchronously,
  4363. returns the request thread.
  4364. """
  4365. kwargs['_return_http_data_only'] = True
  4366. return self.cancel_price_triggered_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501
  4367. def cancel_price_triggered_order_list_with_http_info(self, settle, contract, **kwargs): # noqa: E501
  4368. """Cancel all open orders # noqa: E501
  4369. This method makes a synchronous HTTP request by default. To make an
  4370. asynchronous HTTP request, please pass async_req=True
  4371. >>> thread = api.cancel_price_triggered_order_list_with_http_info(settle, contract, async_req=True)
  4372. >>> result = thread.get()
  4373. :param bool async_req: execute request asynchronously
  4374. :param str settle: Settle currency (required)
  4375. :param str contract: Futures contract (required)
  4376. :param _return_http_data_only: response data without head status code
  4377. and headers
  4378. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4379. be returned without reading/decoding response
  4380. data. Default is True.
  4381. :param _request_timeout: timeout setting for this request. If one
  4382. number provided, it will be total request
  4383. timeout. It can also be a pair (tuple) of
  4384. (connection, read) timeouts.
  4385. :rtype: tuple(list[gate_api.FuturesPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict))
  4386. :return: If the method is called asynchronously,
  4387. returns the request thread.
  4388. """
  4389. local_var_params = locals()
  4390. all_params = ['settle', 'contract']
  4391. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  4392. for k, v in six.iteritems(local_var_params['kwargs']):
  4393. if k not in all_params:
  4394. raise ApiTypeError(
  4395. "Got an unexpected keyword argument '%s'" " to method cancel_price_triggered_order_list" % k
  4396. )
  4397. local_var_params[k] = v
  4398. del local_var_params['kwargs']
  4399. # verify the required parameter 'settle' is set
  4400. if self.api_client.client_side_validation and (
  4401. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  4402. ): # noqa: E501
  4403. raise ApiValueError(
  4404. "Missing the required parameter `settle` when calling `cancel_price_triggered_order_list`"
  4405. ) # noqa: E501
  4406. # verify the required parameter 'contract' is set
  4407. if self.api_client.client_side_validation and (
  4408. 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501
  4409. ): # noqa: E501
  4410. raise ApiValueError(
  4411. "Missing the required parameter `contract` when calling `cancel_price_triggered_order_list`"
  4412. ) # noqa: E501
  4413. collection_formats = {}
  4414. path_params = {}
  4415. if 'settle' in local_var_params:
  4416. path_params['settle'] = local_var_params['settle'] # noqa: E501
  4417. query_params = []
  4418. if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501
  4419. query_params.append(('contract', local_var_params['contract'])) # noqa: E501
  4420. header_params = {}
  4421. form_params = []
  4422. local_var_files = {}
  4423. body_params = None
  4424. # HTTP header `Accept`
  4425. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  4426. # Authentication setting
  4427. auth_settings = ['apiv4'] # noqa: E501
  4428. return self.api_client.call_api(
  4429. '/futures/{settle}/price_orders',
  4430. 'DELETE',
  4431. path_params,
  4432. query_params,
  4433. header_params,
  4434. body=body_params,
  4435. post_params=form_params,
  4436. files=local_var_files,
  4437. response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501
  4438. auth_settings=auth_settings,
  4439. async_req=local_var_params.get('async_req'),
  4440. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  4441. _preload_content=local_var_params.get('_preload_content', True),
  4442. _request_timeout=local_var_params.get('_request_timeout'),
  4443. collection_formats=collection_formats,
  4444. )
  4445. def get_price_triggered_order(self, settle, order_id, **kwargs): # noqa: E501
  4446. """Get a price-triggered order # noqa: E501
  4447. This method makes a synchronous HTTP request by default. To make an
  4448. asynchronous HTTP request, please pass async_req=True
  4449. >>> thread = api.get_price_triggered_order(settle, order_id, async_req=True)
  4450. >>> result = thread.get()
  4451. :param bool async_req: execute request asynchronously
  4452. :param str settle: Settle currency (required)
  4453. :param str order_id: Retrieve the data of the order with the specified ID (required)
  4454. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4455. be returned without reading/decoding response
  4456. data. Default is True.
  4457. :param _request_timeout: timeout setting for this request. If one
  4458. number provided, it will be total request
  4459. timeout. It can also be a pair (tuple) of
  4460. (connection, read) timeouts.
  4461. :rtype: gate_api.FuturesPriceTriggeredOrder
  4462. :return: If the method is called asynchronously,
  4463. returns the request thread.
  4464. """
  4465. kwargs['_return_http_data_only'] = True
  4466. return self.get_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501
  4467. def get_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501
  4468. """Get a price-triggered order # noqa: E501
  4469. This method makes a synchronous HTTP request by default. To make an
  4470. asynchronous HTTP request, please pass async_req=True
  4471. >>> thread = api.get_price_triggered_order_with_http_info(settle, order_id, async_req=True)
  4472. >>> result = thread.get()
  4473. :param bool async_req: execute request asynchronously
  4474. :param str settle: Settle currency (required)
  4475. :param str order_id: Retrieve the data of the order with the specified ID (required)
  4476. :param _return_http_data_only: response data without head status code
  4477. and headers
  4478. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4479. be returned without reading/decoding response
  4480. data. Default is True.
  4481. :param _request_timeout: timeout setting for this request. If one
  4482. number provided, it will be total request
  4483. timeout. It can also be a pair (tuple) of
  4484. (connection, read) timeouts.
  4485. :rtype: tuple(gate_api.FuturesPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict))
  4486. :return: If the method is called asynchronously,
  4487. returns the request thread.
  4488. """
  4489. local_var_params = locals()
  4490. all_params = ['settle', 'order_id']
  4491. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  4492. for k, v in six.iteritems(local_var_params['kwargs']):
  4493. if k not in all_params:
  4494. raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_price_triggered_order" % k)
  4495. local_var_params[k] = v
  4496. del local_var_params['kwargs']
  4497. # verify the required parameter 'settle' is set
  4498. if self.api_client.client_side_validation and (
  4499. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  4500. ): # noqa: E501
  4501. raise ApiValueError(
  4502. "Missing the required parameter `settle` when calling `get_price_triggered_order`"
  4503. ) # noqa: E501
  4504. # verify the required parameter 'order_id' is set
  4505. if self.api_client.client_side_validation and (
  4506. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  4507. ): # noqa: E501
  4508. raise ApiValueError(
  4509. "Missing the required parameter `order_id` when calling `get_price_triggered_order`"
  4510. ) # noqa: E501
  4511. collection_formats = {}
  4512. path_params = {}
  4513. if 'settle' in local_var_params:
  4514. path_params['settle'] = local_var_params['settle'] # noqa: E501
  4515. if 'order_id' in local_var_params:
  4516. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  4517. query_params = []
  4518. header_params = {}
  4519. form_params = []
  4520. local_var_files = {}
  4521. body_params = None
  4522. # HTTP header `Accept`
  4523. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  4524. # Authentication setting
  4525. auth_settings = ['apiv4'] # noqa: E501
  4526. return self.api_client.call_api(
  4527. '/futures/{settle}/price_orders/{order_id}',
  4528. 'GET',
  4529. path_params,
  4530. query_params,
  4531. header_params,
  4532. body=body_params,
  4533. post_params=form_params,
  4534. files=local_var_files,
  4535. response_type='FuturesPriceTriggeredOrder', # noqa: E501
  4536. auth_settings=auth_settings,
  4537. async_req=local_var_params.get('async_req'),
  4538. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  4539. _preload_content=local_var_params.get('_preload_content', True),
  4540. _request_timeout=local_var_params.get('_request_timeout'),
  4541. collection_formats=collection_formats,
  4542. )
  4543. def cancel_price_triggered_order(self, settle, order_id, **kwargs): # noqa: E501
  4544. """cancel a price-triggered order # noqa: E501
  4545. This method makes a synchronous HTTP request by default. To make an
  4546. asynchronous HTTP request, please pass async_req=True
  4547. >>> thread = api.cancel_price_triggered_order(settle, order_id, async_req=True)
  4548. >>> result = thread.get()
  4549. :param bool async_req: execute request asynchronously
  4550. :param str settle: Settle currency (required)
  4551. :param str order_id: Retrieve the data of the order with the specified ID (required)
  4552. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4553. be returned without reading/decoding response
  4554. data. Default is True.
  4555. :param _request_timeout: timeout setting for this request. If one
  4556. number provided, it will be total request
  4557. timeout. It can also be a pair (tuple) of
  4558. (connection, read) timeouts.
  4559. :rtype: gate_api.FuturesPriceTriggeredOrder
  4560. :return: If the method is called asynchronously,
  4561. returns the request thread.
  4562. """
  4563. kwargs['_return_http_data_only'] = True
  4564. return self.cancel_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501
  4565. def cancel_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501
  4566. """cancel a price-triggered order # noqa: E501
  4567. This method makes a synchronous HTTP request by default. To make an
  4568. asynchronous HTTP request, please pass async_req=True
  4569. >>> thread = api.cancel_price_triggered_order_with_http_info(settle, order_id, async_req=True)
  4570. >>> result = thread.get()
  4571. :param bool async_req: execute request asynchronously
  4572. :param str settle: Settle currency (required)
  4573. :param str order_id: Retrieve the data of the order with the specified ID (required)
  4574. :param _return_http_data_only: response data without head status code
  4575. and headers
  4576. :param _preload_content: if False, the urllib3.HTTPResponse object will
  4577. be returned without reading/decoding response
  4578. data. Default is True.
  4579. :param _request_timeout: timeout setting for this request. If one
  4580. number provided, it will be total request
  4581. timeout. It can also be a pair (tuple) of
  4582. (connection, read) timeouts.
  4583. :rtype: tuple(gate_api.FuturesPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict))
  4584. :return: If the method is called asynchronously,
  4585. returns the request thread.
  4586. """
  4587. local_var_params = locals()
  4588. all_params = ['settle', 'order_id']
  4589. all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout'])
  4590. for k, v in six.iteritems(local_var_params['kwargs']):
  4591. if k not in all_params:
  4592. raise ApiTypeError(
  4593. "Got an unexpected keyword argument '%s'" " to method cancel_price_triggered_order" % k
  4594. )
  4595. local_var_params[k] = v
  4596. del local_var_params['kwargs']
  4597. # verify the required parameter 'settle' is set
  4598. if self.api_client.client_side_validation and (
  4599. 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501
  4600. ): # noqa: E501
  4601. raise ApiValueError(
  4602. "Missing the required parameter `settle` when calling `cancel_price_triggered_order`"
  4603. ) # noqa: E501
  4604. # verify the required parameter 'order_id' is set
  4605. if self.api_client.client_side_validation and (
  4606. 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501
  4607. ): # noqa: E501
  4608. raise ApiValueError(
  4609. "Missing the required parameter `order_id` when calling `cancel_price_triggered_order`"
  4610. ) # noqa: E501
  4611. collection_formats = {}
  4612. path_params = {}
  4613. if 'settle' in local_var_params:
  4614. path_params['settle'] = local_var_params['settle'] # noqa: E501
  4615. if 'order_id' in local_var_params:
  4616. path_params['order_id'] = local_var_params['order_id'] # noqa: E501
  4617. query_params = []
  4618. header_params = {}
  4619. form_params = []
  4620. local_var_files = {}
  4621. body_params = None
  4622. # HTTP header `Accept`
  4623. header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501
  4624. # Authentication setting
  4625. auth_settings = ['apiv4'] # noqa: E501
  4626. return self.api_client.call_api(
  4627. '/futures/{settle}/price_orders/{order_id}',
  4628. 'DELETE',
  4629. path_params,
  4630. query_params,
  4631. header_params,
  4632. body=body_params,
  4633. post_params=form_params,
  4634. files=local_var_files,
  4635. response_type='FuturesPriceTriggeredOrder', # noqa: E501
  4636. auth_settings=auth_settings,
  4637. async_req=local_var_params.get('async_req'),
  4638. _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
  4639. _preload_content=local_var_params.get('_preload_content', True),
  4640. _request_timeout=local_var_params.get('_request_timeout'),
  4641. collection_formats=collection_formats,
  4642. )