okxv5 1.8.11__py3-none-any.whl → 1.8.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
okxv5/Trade_api.py CHANGED
@@ -3,58 +3,15 @@ from .consts import *
3
3
 
4
4
 
5
5
  class TradeAPI(Client):
6
- """
7
- 交易API类,继承自Client,用于执行各种交易操作。
8
- """
9
6
 
10
7
  def __init__(self, api_key, api_secret_key, passphrase, use_server_time=False, flag='1'):
11
- """
12
- 初始化TradeAPI客户端。
13
-
14
- Args:
15
- api_key (str): API密钥。
16
- api_secret_key (str): API秘密密钥。
17
- passphrase (str): 密码。
18
- use_server_time (bool, optional): 是否使用服务器时间。默认为False。
19
- flag (str, optional): 区域标识。默认为'1'。
20
- """
21
8
  Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag)
22
9
 
23
- # Place Order 下单
10
+ # Place Order
24
11
  def place_order(self, instId, tdMode, side, ordType, sz, ccy='', clOrdId='', tag='', posSide='', px='',
25
12
  reduceOnly='', tgtCcy='', banAmend='',quickMgnType='',tpTriggerPx = '', tpOrdPx = '',
26
13
  slTriggerPx = '', slOrdPx = '', tpTriggerPxType = '', slTriggerPxType = '',stpId='',
27
14
  stpMode='',attachAlgoClOrdId=''):
28
- """
29
- 下单。
30
-
31
- Args:
32
- instId (str): 产品ID。
33
- tdMode (str): 交易模式。
34
- side (str): 交易方向。
35
- ordType (str): 订单类型。
36
- sz (str): 订单数量。
37
- ccy (str, optional): 保证金币种。默认为空。
38
- clOrdId (str, optional): 客户自定义订单ID。默认为空。
39
- tag (str, optional): 订单标签。默认为空。
40
- posSide (str, optional): 持仓方向。默认为空。
41
- px (str, optional): 委托价格。默认为空。
42
- reduceOnly (str, optional): 是否只减仓。默认为空。
43
- tgtCcy (str, optional): 交易币种。默认为空。
44
- banAmend (str, optional): 是否禁止修改。默认为空。
45
- quickMgnType (str, optional): 快速追加保证金类型。默认为空。
46
- tpTriggerPx (str, optional): 止盈触发价。默认为空。
47
- tpOrdPx (str, optional): 止盈委托价。默认为空。
48
- slTriggerPx (str, optional): 止损触发价。默认为空。
49
- slOrdPx (str, optional): 止损委托价。默认为空。
50
- tpTriggerPxType (str, optional): 止盈触发价类型。默认为空。
51
- slTriggerPxType (str, optional): 止损触发价类型。默认为空。
52
- stpId (str, optional): 自成交保护ID。默认为空。
53
- stpMode (str, optional): 自成交保护模式。默认为空。
54
- attachAlgoClOrdId (str, optional): 关联的策略订单ID。默认为空。
55
- Returns:
56
- dict: API请求结果。
57
- """
58
15
  params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy,
59
16
  'clOrdId': clOrdId, 'tag': tag, 'posSide': posSide, 'px': px, 'reduceOnly': reduceOnly,
60
17
  'tgtCcy': tgtCcy, 'banAmend': banAmend,'quickMgnType':quickMgnType,'tpTriggerPx':tpTriggerPx,'tpOrdPx':tpOrdPx,'slTriggerPx':slTriggerPx
@@ -62,219 +19,69 @@ class TradeAPI(Client):
62
19
  'stpId':stpId,'stpMode':stpMode,'attachAlgoClOrdId':attachAlgoClOrdId}
63
20
  return self._request_with_params(POST, PLACR_ORDER, params)
64
21
 
65
- # Place Multiple Orders 批量下单
22
+ # Place Multiple Orders
66
23
  def place_multiple_orders(self, orders_data):
67
- """
68
- 批量下单。
69
-
70
- Args:
71
- orders_data (list): 订单数据列表。
72
- Returns:
73
- dict: API请求结果。
74
- """
75
24
  return self._request_with_params(POST, BATCH_ORDERS, orders_data)
76
25
 
77
- # Cancel Order 撤销订单
26
+ # Cancel Order
78
27
  def cancel_order(self, instId, ordId='', clOrdId=''):
79
- """
80
- 撤销订单。
81
-
82
- Args:
83
- instId (str): 产品ID。
84
- ordId (str, optional): 订单ID。默认为空。
85
- clOrdId (str, optional): 客户自定义订单ID。默认为空。
86
- Returns:
87
- dict: API请求结果。
88
- """
89
28
  params = {'instId': instId, 'ordId': ordId, 'clOrdId': clOrdId}
90
29
  return self._request_with_params(POST, CANAEL_ORDER, params)
91
30
 
92
- # Cancel Multiple Orders 批量撤销订单
31
+ # Cancel Multiple Orders
93
32
  def cancel_multiple_orders(self, orders_data):
94
- """
95
- 批量撤销订单。
96
-
97
- Args:
98
- orders_data (list): 订单数据列表。
99
- Returns:
100
- dict: API请求结果。
101
- """
102
33
  return self._request_with_params(POST, CANAEL_BATCH_ORDERS, orders_data)
103
34
 
104
- # Amend Order 修改订单
35
+ # Amend Order
105
36
  def amend_order(self, instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='',
106
37
  newPx = '', newTpTriggerPx='', newTpOrdPx='',newSlTriggerPx='', newSlOrdPx='',
107
38
  newTpTriggerPxType='', newSlTriggerPxType=''):
108
- """
109
- 修改订单。
110
-
111
- Args:
112
- instId (str): 产品ID。
113
- cxlOnFail (str, optional): 订单修改失败后是否自动撤销。默认为空。
114
- ordId (str, optional): 订单ID。默认为空。
115
- clOrdId (str, optional): 客户自定义订单ID。默认为空。
116
- reqId (str, optional): 请求ID。默认为空。
117
- newSz (str, optional): 新的订单数量。默认为空。
118
- newPx (str, optional): 新的委托价格。默认为空。
119
- newTpTriggerPx (str, optional): 新的止盈触发价。默认为空。
120
- newTpOrdPx (str, optional): 新的止盈委托价。默认为空。
121
- newSlTriggerPx (str, optional): 新的止损触发价。默认为空。
122
- newSlOrdPx (str, optional): 新的止损委托价。默认为空。
123
- newTpTriggerPxType (str, optional): 新的止盈触发价类型。默认为空。
124
- newSlTriggerPxType (str, optional): 新的止损触发价类型。默认为空。
125
- Returns:
126
- dict: API请求结果。
127
- """
128
39
  params = {'instId': instId, 'cxlOnFailc': cxlOnFail, 'ordId': ordId, 'clOrdId': clOrdId, 'reqId': reqId,
129
40
  'newSz': newSz,'newPx': newPx,'newTpTriggerPx': newTpTriggerPx,'newTpOrdPx': newTpOrdPx,
130
41
  'newSlTriggerPx': newSlTriggerPx,'newSlOrdPx': newSlOrdPx,'newTpTriggerPxType': newTpTriggerPxType,
131
42
  'newSlTriggerPxType': newSlTriggerPxType}
132
43
  return self._request_with_params(POST, AMEND_ORDER, params)
133
44
 
134
- # Amend Multiple Orders 批量修改订单
45
+ # Amend Multiple Orders
135
46
  def amend_multiple_orders(self, orders_data):
136
- """
137
- 批量修改订单。
138
-
139
- Args:
140
- orders_data (list): 订单数据列表。
141
- Returns:
142
- dict: API请求结果。
143
- """
144
47
  return self._request_with_params(POST, AMEND_BATCH_ORDER, orders_data)
145
48
 
146
- # Close Positions 平仓
49
+ # Close Positions
147
50
  def close_positions(self, instId, mgnMode, posSide='', ccy='',autoCxl='',clOrdId='',tag=''):
148
- """
149
- 平仓。
150
-
151
- Args:
152
- instId (str): 产品ID。
153
- mgnMode (str): 保证金模式。
154
- posSide (str, optional): 持仓方向。默认为空。
155
- ccy (str, optional): 保证金币种。默认为空。
156
- autoCxl (str, optional): 是否自动撤销。默认为空。
157
- clOrdId (str, optional): 客户自定义订单ID。默认为空。
158
- tag (str, optional): 订单标签。默认为空。
159
- Returns:
160
- dict: API请求结果。
161
- """
162
51
  params = {'instId': instId, 'mgnMode': mgnMode, 'posSide': posSide, 'ccy': ccy,'autoCxl':autoCxl,'clOrdId':clOrdId,'tag':tag}
163
52
  return self._request_with_params(POST, CLOSE_POSITION, params)
164
53
 
165
- # Get Order Details 获取订单详情
54
+ # Get Order Details
166
55
  def get_orders(self, instId, ordId='', clOrdId=''):
167
- """
168
- 获取订单详情。
169
-
170
- Args:
171
- instId (str): 产品ID。
172
- ordId (str, optional): 订单ID。默认为空。
173
- clOrdId (str, optional): 客户自定义订单ID。默认为空。
174
- Returns:
175
- dict: API请求结果。
176
- """
177
56
  params = {'instId': instId, 'ordId': ordId, 'clOrdId': clOrdId}
178
57
  return self._request_with_params(GET, ORDER_INFO, params)
179
58
 
180
- # Get Order List 获取订单列表
59
+ # Get Order List
181
60
  def get_order_list(self, instType='', uly='', instId='', ordType='', state='', after='', before='', limit='', instFamily = ''):
182
- """
183
- 获取订单列表。
184
-
185
- Args:
186
- instType (str, optional): 产品类型。默认为空。
187
- uly (str, optional): 标的。默认为空。
188
- instId (str, optional): 产品ID。默认为空。
189
- ordType (str, optional): 订单类型。默认为空。
190
- state (str, optional): 订单状态。默认为空。
191
- after (str, optional): 查询ID的起始点。默认为空。
192
- before (str, optional): 查询ID的结束点。默认为空。
193
- limit (str, optional): 返回结果数量。默认为空。
194
- instFamily (str, optional): 产品族。默认为空。
195
- Returns:
196
- dict: API请求结果。
197
- """
198
61
  params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordType': ordType, 'state': state,
199
62
  'after': after, 'before': before, 'limit': limit, 'instFamily':instFamily}
200
63
  return self._request_with_params(GET, ORDERS_PENDING, params)
201
64
 
202
- # Get Order History (last 7 days)获取订单历史(最近7天)
65
+ # Get Order History (last 7 days
203
66
  def get_orders_history(self, instType='', uly='', instId='', ordType='', state='', after='', before='', limit='', instFamily ='', category = '', begin = '', end = ''):
204
- """
205
- 获取订单历史(最近7天)。
206
-
207
- Args:
208
- instType (str, optional): 产品类型。默认为空。
209
- uly (str, optional): 标的。默认为空。
210
- instId (str, optional): 产品ID。默认为空。
211
- ordType (str, optional): 订单类型。默认为空。
212
- state (str, optional): 订单状态。默认为空。
213
- after (str, optional): 查询ID的起始点。默认为空。
214
- before (str, optional): 查询ID的结束点。默认为空。
215
- limit (str, optional): 返回结果数量。默认为空。
216
- instFamily (str, optional): 产品族。默认为空。
217
- category (str, optional): 订单种类。默认为空。
218
- begin (str, optional): 查询的起始时间。默认为空。
219
- end (str, optional): 查询的结束时间。默认为空。
220
- Returns:
221
- dict: API请求结果。
222
- """
223
67
  params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordType': ordType, 'state': state,
224
68
  'after': after, 'before': before, 'limit': limit, 'instFamily': instFamily, 'category': category, 'begin': begin, 'end': end}
225
69
  return self._request_with_params(GET, ORDERS_HISTORY, params)
226
70
 
227
- # Get Order History (last 3 months) 获取订单历史(最近3个月)
71
+ # Get Order History (last 3 months)
228
72
  def orders_history_archive(self, instType, uly='', instId='', ordType='', state='', after='', before='', limit='', instFamily ='', category = '', begin = '', end = ''):
229
- """
230
- 获取订单历史(最近3个月)。
231
-
232
- Args:
233
- instType (str): 产品类型。
234
- uly (str, optional): 标的。默认为空。
235
- instId (str, optional): 产品ID。默认为空。
236
- ordType (str, optional): 订单类型。默认为空。
237
- state (str, optional): 订单状态。默认为空。
238
- after (str, optional): 查询ID的起始点。默认为空。
239
- before (str, optional): 查询ID的结束点。默认为空。
240
- limit (str, optional): 返回结果数量。默认为空。
241
- instFamily (str, optional): 产品族。默认为空。
242
- category (str, optional): 订单种类。默认为空。
243
- begin (str, optional): 查询的起始时间。默认为空。
244
- end (str, optional): 查询的结束时间。默认为空。
245
- Returns:
246
- dict: API请求结果。
247
- """
248
73
  params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordType': ordType, 'state': state,
249
74
  'after': after, 'before': before, 'limit': limit, 'instFamily': instFamily, 'category': category, 'begin': begin, 'end': end}
250
75
  return self._request_with_params(GET, ORDERS_HISTORY_ARCHIVE, params)
251
76
 
252
- # Get Transaction Details 获取成交明细
77
+ # Get Transaction Details
253
78
  def get_fills(self, instType='', uly='', instId='', ordId='', after='', before='',
254
79
  limit='', instFamily = '', begin = '', end = '',subType=''):
255
- """
256
- 获取成交明细。
257
-
258
- Args:
259
- instType (str, optional): 产品类型。默认为空。
260
- uly (str, optional): 标的。默认为空。
261
- instId (str, optional): 产品ID。默认为空。
262
- ordId (str, optional): 订单ID。默认为空。
263
- after (str, optional): 查询ID的起始点。默认为空。
264
- before (str, optional): 查询ID的结束点。默认为空。
265
- limit (str, optional): 返回结果数量。默认为空。
266
- instFamily (str, optional): 产品族。默认为空。
267
- begin (str, optional): 查询的起始时间。默认为空。
268
- end (str, optional): 查询的结束时间。默认为空。
269
- subType (str, optional): 交易类型。默认为空。
270
- Returns:
271
- dict: API请求结果。
272
- """
273
80
  params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordId': ordId, 'after': after, 'before': before,
274
81
  'limit': limit, 'instFamily': instFamily, 'begin': begin, 'end': end,'subType':subType}
275
82
  return self._request_with_params(GET, ORDER_FILLS, params)
276
83
 
277
- # Place Algo Order 下策略订单
84
+ # Place Algo Order
278
85
  def place_algo_order(self, instId='', tdMode='', side='', ordType='', sz='', ccy='',
279
86
  posSide='', reduceOnly='', tpTriggerPx='',
280
87
  tpOrdPx='', slTriggerPx='', slOrdPx='',
@@ -283,45 +90,6 @@ class TradeAPI(Client):
283
90
  szLimit='', pxLimit='', timeInterval='', tpTriggerPxType='', slTriggerPxType='',
284
91
  callbackRatio='',callbackSpread='',activePx='',tag='',triggerPxType='',
285
92
  algoClOrdId='',quickMgnType='',closeFraction='', attachAlgoClOrdId=''):
286
- """
287
- 下策略订单。
288
-
289
- Args:
290
- instId (str, optional): 产品ID。默认为空。
291
- tdMode (str, optional): 交易模式。默认为空。
292
- side (str, optional): 交易方向。默认为空。
293
- ordType (str, optional): 订单类型。默认为空。
294
- sz (str, optional): 订单数量。默认为空。
295
- ccy (str, optional): 保证金币种。默认为空。
296
- posSide (str, optional): 持仓方向。默认为空。
297
- reduceOnly (str, optional): 是否只减仓。默认为空。
298
- tpTriggerPx (str, optional): 止盈触发价。默认为空。
299
- tpOrdPx (str, optional): 止盈委托价。默认为空。
300
- slTriggerPx (str, optional): 止损触发价。默认为空。
301
- slOrdPx (str, optional): 止损委托价。默认为空。
302
- triggerPx (str, optional): 触发价格。默认为空。
303
- orderPx (str, optional): 委托价格。默认为空。
304
- tgtCcy (str, optional): 交易币种。默认为空。
305
- pxVar (str, optional): 价格波动幅度。默认为空。
306
- pxSpread (str, optional): 价格点差。默认为空。
307
- cxlOnClosePos (str, optional): 平仓时是否自动撤销策略订单。默认为空。
308
- szLimit (str, optional): 数量限制。默认为空。
309
- pxLimit (str, optional): 价格限制。默认为空。
310
- timeInterval (str, optional): 时间间隔。默认为空。
311
- tpTriggerPxType (str, optional): 止盈触发价类型。默认为空。
312
- slTriggerPxType (str, optional): 止损触发价类型。默认为空。
313
- callbackRatio (str, optional): 回调比例。默认为空。
314
- callbackSpread (str, optional): 回调点差。默认为空。
315
- activePx (str, optional): 激活价格。默认为空。
316
- tag (str, optional): 订单标签。默认为空。
317
- triggerPxType (str, optional): 触发价格类型。默认为空。
318
- algoClOrdId (str, optional): 策略订单ID。默认为空。
319
- quickMgnType (str, optional): 快速追加保证金类型。默认为空。
320
- closeFraction (str, optional): 平仓比例。默认为空。
321
- attachAlgoClOrdId (str, optional): 关联的策略订单ID。默认为空。
322
- Returns:
323
- dict: API请求结果。
324
- """
325
93
  params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy,
326
94
  'posSide': posSide, 'reduceOnly': reduceOnly, 'tpTriggerPx': tpTriggerPx, 'tpOrdPx': tpOrdPx,
327
95
  'slTriggerPx': slTriggerPx, 'slOrdPx': slOrdPx, 'triggerPx': triggerPx, 'orderPx': orderPx,
@@ -333,46 +101,15 @@ class TradeAPI(Client):
333
101
  'closeFraction':closeFraction, 'attachAlgoClOrdId':attachAlgoClOrdId}
334
102
  return self._request_with_params(POST, PLACE_ALGO_ORDER, params)
335
103
 
336
- # Cancel Algo Order 撤销策略订单
104
+ # Cancel Algo Order
337
105
  def cancel_algo_order(self, params):
338
- """
339
- 撤销策略订单。
340
-
341
- Args:
342
- params (dict): 撤销策略订单的参数。
343
- Returns:
344
- dict: API请求结果。
345
- """
346
106
  return self._request_with_params(POST, CANCEL_ALGOS, params)
347
107
 
348
- # POST /api/v5/trade/amend-algos 修改策略订单
108
+ # POST /api/v5/trade/amend-algos
349
109
  def amend_algos(self, instId='', algoId='', algoClOrdId='', cxlOnFail = '',reqId = '',newSz = '',
350
110
  newTpTriggerPx = '',newTpOrdPx = '',newSlTriggerPx = '',
351
111
  newSlOrdPx = '',newTpTriggerPxType = '',newSlTriggerPxType='',
352
112
  newTriggerPx='',newOrdPx='',newTriggerPxType='',attachAlgoOrds=[]):
353
- """
354
- 修改策略订单。
355
-
356
- Args:
357
- instId (str, optional): 产品ID。默认为空。
358
- algoId (str, optional): 策略订单ID。默认为空。
359
- algoClOrdId (str, optional): 客户自定义策略订单ID。默认为空。
360
- cxlOnFail (str, optional): 订单修改失败后是否自动撤销。默认为空。
361
- reqId (str, optional): 请求ID。默认为空。
362
- newSz (str, optional): 新的订单数量。默认为空。
363
- newTpTriggerPx (str, optional): 新的止盈触发价。默认为空。
364
- newTpOrdPx (str, optional): 新的止盈委托价。默认为空。
365
- newSlTriggerPx (str, optional): 新的止损触发价。默认为空。
366
- newSlOrdPx (str, optional): 新的止损委托价。默认为空。
367
- newTpTriggerPxType (str, optional): 新的止盈触发价类型。默认为空。
368
- newSlTriggerPxType (str, optional): 新的止损触发价类型。默认为空。
369
- newTriggerPx (str, optional): 新的触发价格。默认为空。
370
- newOrdPx (str, optional): 新的委托价格。默认为空。
371
- newTriggerPxType (str, optional): 新的触发价格类型。默认为空。
372
- attachAlgoOrds (list, optional): 关联的策略订单列表。默认为空。
373
- Returns:
374
- dict: API请求结果。
375
- """
376
113
  params = {'instId':instId,'algoId':algoId,'algoClOrdId':algoClOrdId,'cxlOnFail':cxlOnFail,
377
114
  'reqId':reqId,'newSz':newSz,'newTpTriggerPx':newTpTriggerPx,'newTpOrdPx':newTpOrdPx,
378
115
  'newSlTriggerPx':newSlTriggerPx,'newSlOrdPx':newSlOrdPx,'newTpTriggerPxType':newTpTriggerPxType,
@@ -380,250 +117,81 @@ class TradeAPI(Client):
380
117
  'attachAlgoOrds':attachAlgoOrds}
381
118
  return self._request_with_params(POST, AMEND_ALGOS, params)
382
119
 
383
- # Cancel Advance Algos 撤销高级策略订单
120
+ # Cancel Advance Algos
384
121
  def cancel_advance_algos(self, params):
385
- """
386
- 撤销高级策略订单。
387
-
388
- Args:
389
- params (dict): 撤销高级策略订单的参数。
390
- Returns:
391
- dict: API请求结果。
392
- """
393
122
  return self._request_with_params(POST, Cancel_Advance_Algos, params)
394
123
 
395
- # Get Algo Order List 获取策略订单列表
124
+ # Get Algo Order List
396
125
  def order_algos_list(self, ordType, algoId='', instType='', instId='', after='', before='', limit='',algoClOrdId=''):
397
- """
398
- 获取策略订单列表。
399
-
400
- Args:
401
- ordType (str): 订单类型。
402
- algoId (str, optional): 策略订单ID。默认为空。
403
- instType (str, optional): 产品类型。默认为空。
404
- instId (str, optional): 产品ID。默认为空。
405
- after (str, optional): 查询ID的起始点。默认为空。
406
- before (str, optional): 查询ID的结束点。默认为空。
407
- limit (str, optional): 返回结果数量。默认为空。
408
- algoClOrdId (str, optional): 客户自定义策略订单ID。默认为空。
409
- Returns:
410
- dict: API请求结果。
411
- """
412
126
  params = {'ordType': ordType, 'algoId': algoId, 'instType': instType, 'instId': instId, 'after': after,
413
127
  'before': before, 'limit': limit,'algoClOrdId':algoClOrdId}
414
128
  return self._request_with_params(GET, ORDERS_ALGO_OENDING, params)
415
129
 
416
- # Get Algo Order History 获取策略订单历史
130
+ # Get Algo Order History
417
131
  def order_algos_history(self, ordType, state='', algoId='', instType='', instId='', after='', before='', limit=''):
418
- """
419
- 获取策略订单历史。
420
-
421
- Args:
422
- ordType (str): 订单类型。
423
- state (str, optional): 订单状态。默认为空。
424
- algoId (str, optional): 策略订单ID。默认为空。
425
- instType (str, optional): 产品类型。默认为空。
426
- instId (str, optional): 产品ID。默认为空。
427
- after (str, optional): 查询ID的起始点。默认为空。
428
- before (str, optional): 查询ID的结束点。默认为空。
429
- limit (str, optional): 返回结果数量。默认为空。
430
- Returns:
431
- dict: API请求结果。
432
- """
433
132
  params = {'ordType': ordType, 'state': state, 'algoId': algoId, 'instType': instType, 'instId': instId,
434
133
  'after': after, 'before': before, 'limit': limit}
435
134
  return self._request_with_params(GET, ORDERS_ALGO_HISTORY, params)
436
135
 
437
- # Get Transaction Details History 获取成交明细历史
136
+ # Get Transaction Details History
438
137
  def get_fills_history(self, instType, uly='', instId='', ordId='', after='', before='', limit='',subType=''):
439
- """
440
- 获取成交明细历史。
441
-
442
- Args:
443
- instType (str): 产品类型。
444
- uly (str, optional): 标的。默认为空。
445
- instId (str, optional): 产品ID。默认为空。
446
- ordId (str, optional): 订单ID。默认为空。
447
- after (str, optional): 查询ID的起始点。默认为空。
448
- before (str, optional): 查询ID的结束点。默认为空。
449
- limit (str, optional): 返回结果数量。默认为空。
450
- subType (str, optional): 交易类型。默认为空。
451
- Returns:
452
- dict: API请求结果。
453
- """
454
138
  params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordId': ordId, 'after': after, 'before': before,
455
139
  'limit': limit,'subType':subType}
456
140
  return self._request_with_params(GET, ORDERS_FILLS_HISTORY, params)
457
141
 
458
142
  def easy_convert_currency_list(self, source = ''):
459
- """
460
- 获取闪兑币种列表。
461
-
462
- Args:
463
- source (str, optional): 来源。默认为空。
464
- Returns:
465
- dict: API请求结果。
466
- """
467
143
  params = {'source':source}
468
144
  return self._request_with_params(GET, EASY_CONVERT_CURRENCY_LIST, params)
469
145
 
470
146
  def easy_convert(self, fromCcy = '', toCcy = '', source = ''):
471
- """
472
- 执行闪兑。
473
-
474
- Args:
475
- fromCcy (str, optional): 源币种。默认为空。
476
- toCcy (str, optional): 目标币种。默认为空。
477
- source (str, optional): 来源。默认为空。
478
- Returns:
479
- dict: API请求结果。
480
- """
481
147
  params = {'fromCcy':fromCcy, 'toCcy':toCcy, 'source':source}
482
148
  return self._request_with_params(POST, EASY_CONVERT, params)
483
149
 
484
150
  def easy_convert_history(self, after = '', before = '', limit = ''):
485
- """
486
- 获取闪兑历史记录。
487
-
488
- Args:
489
- after (str, optional): 查询ID的起始点。默认为空。
490
- before (str, optional): 查询ID的结束点。默认为空。
491
- limit (str, optional): 返回结果数量。默认为空。
492
- Returns:
493
- dict: API请求结果。
494
- """
495
151
  params = {'after':after, 'before':before, 'limit':limit}
496
152
  return self._request_with_params(GET, EASY_CONVERT_HISTORY, params)
497
153
 
498
154
  def one_click_repay_currency_list(self, debtType = ''):
499
- """
500
- 获取一键还币币种列表。
501
-
502
- Args:
503
- debtType (str, optional): 负债类型。默认为空。
504
- Returns:
505
- dict: API请求结果。
506
- """
507
155
  params = {'debtType':debtType}
508
156
  return self._request_with_params(GET, ONE_CLICK_REPAY_CURRENCY_LIST, params)
509
157
 
510
158
  def one_click_repay(self, debtCcy = '', repayCcy = ''):
511
- """
512
- 执行一键还币。
513
-
514
- Args:
515
- debtCcy (str, optional): 负债币种。默认为空。
516
- repayCcy (str, optional): 还币币种。默认为空。
517
- Returns:
518
- dict: API请求结果。
519
- """
520
159
  params = {'debtCcy':debtCcy, 'repayCcy':repayCcy}
521
160
  return self._request_with_params(POST, ONE_CLICK_REPAY, params)
522
161
 
523
162
  def one_click_repay_history(self, after = '', before = '', limit = ''):
524
- """
525
- 获取一键还币历史记录。
526
-
527
- Args:
528
- after (str, optional): 查询ID的起始点。默认为空。
529
- before (str, optional): 查询ID的结束点。默认为空。
530
- limit (str, optional): 返回结果数量。默认为空。
531
- Returns:
532
- dict: API请求结果。
533
- """
534
163
  params = {'after':after, 'before':before, 'limit':limit}
535
164
  return self._request_with_params(GET, ONE_CLICK_REPAY_HISTORY, params)
536
165
 
537
- # GET /api/v5/trade/order-algo 获取策略订单信息
166
+ # GET /api/v5/trade/order-algo
538
167
  def get_order_algo(self, algoId = '', algoClOrdId = ''):
539
- """
540
- 获取策略订单信息。
541
-
542
- Args:
543
- algoId (str, optional): 策略订单ID。默认为空。
544
- algoClOrdId (str, optional): 客户自定义策略订单ID。默认为空。
545
- Returns:
546
- dict: API请求结果。
547
- """
548
168
  params = {'algoId':algoId, 'algoClOrdId':algoClOrdId}
549
169
  return self._request_with_params(GET, GET_ORDER_ALGO, params)
550
170
 
551
- # POST /api/v5/trade/mass-cancel 批量撤销订单
171
+ # POST /api/v5/trade/mass-cancel
552
172
  def mass_cancel(self,instType= '',instFamily = '',lockInterval = ''):
553
- """
554
- 批量撤销订单。
555
-
556
- Args:
557
- instType (str, optional): 产品类型。默认为空。
558
- instFamily (str, optional): 产品族。默认为空。
559
- lockInterval (str, optional): 锁定时间间隔。默认为空。
560
- Returns:
561
- dict: API请求结果。
562
- """
563
173
  params = {'instType':instType, 'instFamily':instFamily, 'lockInterval':lockInterval}
564
174
  return self._request_with_params(POST, MASS_CANCEL, params)
565
175
 
566
176
  def cancel_all_after(self,timeOut= '', tag = ''):
567
- """
568
- 取消所有订单在指定时间后。
569
-
570
- Args:
571
- timeOut (str, optional): 超时时间(秒)。默认为空。
572
- tag (str, optional): 订单标签。默认为空。
573
- Returns:
574
- dict: API请求结果。
575
- """
576
177
  params = {'timeOut': timeOut, 'tag': tag}
577
178
  return self._request_with_params(POST, CANCEL_ALL_AFTER, params)
578
179
 
579
- # POST / api / v5 / trade / fills - archive 成交明细归档
180
+ # POST / api / v5 / trade / fills - archive
580
181
  def fills_archive(self,year, quarter):
581
- """
582
- 获取成交明细归档。
583
-
584
- Args:
585
- year (int): 年份。
586
- quarter (int): 季度。
587
- Returns:
588
- dict: API请求结果。
589
- """
590
182
  params = {'year': year, 'quarter':quarter}
591
183
  return self._request_with_params(POST, FILLS_ARCHIVE, params)
592
184
 
593
- # GET / api / v5 / trade / fills - archive 获取成交明细归档
185
+ # GET / api / v5 / trade / fills - archive
594
186
  def fills_archives(self,year, quarter):
595
- """
596
- 获取成交明细归档。
597
-
598
- Args:
599
- year (int): 年份。
600
- quarter (int): 季度。
601
- Returns:
602
- dict: API请求结果。
603
- """
604
187
  params = {'year': year, 'quarter':quarter}
605
188
  return self._request_with_params(GET, FILLS_ARCHIVES, params)
606
189
 
607
- # POST /api/v5/trade/order-precheck 订单预检查
190
+ # POST /api/v5/trade/order-precheck
608
191
  def order_precheck(self,instid = '', tdMode = '', side = '', posSide = '', ordType = '', sz = '', px = '',
609
192
  reduceOnly = '', tgtCcy = '', attachAlgoOrds = []):
610
- """
611
- 订单预检查。
612
-
613
- Args:
614
- instid (str, optional): 产品ID。默认为空。
615
- tdMode (str, optional): 交易模式。默认为空。
616
- side (str, optional): 交易方向。默认为空。
617
- posSide (str, optional): 持仓方向。默认为空。
618
- ordType (str, optional): 订单类型。默认为空。
619
- sz (str, optional): 订单数量。默认为空。
620
- px (str, optional): 委托价格。默认为空。
621
- reduceOnly (str, optional): 是否只减仓。默认为空。
622
- tgtCcy (str, optional): 交易币种。默认为空。
623
- attachAlgoOrds (list, optional): 关联的策略订单列表。默认为空。
624
- Returns:
625
- dict: API请求结果。
626
- """
627
193
  params = {'instid': instid, 'tdMode':tdMode, 'side':side, 'posSide':posSide, 'ordType':ordType,
628
194
  'sz':sz, 'px':px, 'reduceOnly':reduceOnly, 'tgtCcy':tgtCcy, 'attachAlgoOrds':attachAlgoOrds}
629
- return self._request_with_params(POST, ORDER_PRECHECK, params)
195
+ return self._request_with_params(POST, ORDER_PRECHECK, params)
196
+
197
+