Skip to content

Commit c68b2ae

Browse files
committed
modify trade_client method param, remove secret_key
1 parent 4277667 commit c68b2ae

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

tigeropen/common/util/order_utils.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from tigeropen.common.consts import OrderStatus
99

1010

11-
def market_order(account, contract, action, quantity, secret_key=None):
11+
def market_order(account, contract, action, quantity):
1212
"""
1313
市价单
1414
:param account:
@@ -17,10 +17,10 @@ def market_order(account, contract, action, quantity, secret_key=None):
1717
:param quantity:
1818
:return:
1919
"""
20-
return Order(account, contract, action, 'MKT', quantity, secret_key=secret_key)
20+
return Order(account, contract, action, 'MKT', quantity)
2121

2222

23-
def limit_order(account, contract, action, quantity, limit_price, secret_key=None):
23+
def limit_order(account, contract, action, quantity, limit_price):
2424
"""
2525
限价单
2626
:param account:
@@ -30,10 +30,10 @@ def limit_order(account, contract, action, quantity, limit_price, secret_key=Non
3030
:param limit_price: 限价的价格
3131
:return:
3232
"""
33-
return Order(account, contract, action, 'LMT', quantity, limit_price=limit_price, secret_key=secret_key)
33+
return Order(account, contract, action, 'LMT', quantity, limit_price=limit_price)
3434

3535

36-
def stop_order(account, contract, action, quantity, aux_price, secret_key=None):
36+
def stop_order(account, contract, action, quantity, aux_price):
3737
"""
3838
止损单
3939
:param account:
@@ -43,10 +43,10 @@ def stop_order(account, contract, action, quantity, aux_price, secret_key=None):
4343
:param aux_price: 触发止损单的价格
4444
:return:
4545
"""
46-
return Order(account, contract, action, 'STP', quantity, aux_price=aux_price, secret_key=secret_key)
46+
return Order(account, contract, action, 'STP', quantity, aux_price=aux_price)
4747

4848

49-
def stop_limit_order(account, contract, action, quantity, limit_price, aux_price, secret_key=None):
49+
def stop_limit_order(account, contract, action, quantity, limit_price, aux_price):
5050
"""
5151
限价止损单
5252
:param account:
@@ -57,11 +57,10 @@ def stop_limit_order(account, contract, action, quantity, limit_price, aux_price
5757
:param aux_price: 触发止损单的价格
5858
:return:
5959
"""
60-
return Order(account, contract, action, 'STP_LMT', quantity, limit_price=limit_price, aux_price=aux_price,
61-
secret_key=secret_key)
60+
return Order(account, contract, action, 'STP_LMT', quantity, limit_price=limit_price, aux_price=aux_price)
6261

6362

64-
def trail_order(account, contract, action, quantity, trailing_percent=None, aux_price=None, secret_key=None):
63+
def trail_order(account, contract, action, quantity, trailing_percent=None, aux_price=None):
6564
"""
6665
移动止损单
6766
:param account:
@@ -72,8 +71,7 @@ def trail_order(account, contract, action, quantity, trailing_percent=None, aux_
7271
:param aux_price: 价差 aux_price 和 trailing_percent 两者互斥
7372
:return:
7473
"""
75-
return Order(account, contract, action, 'TRAIL', quantity, trailing_percent=trailing_percent, aux_price=aux_price,
76-
secret_key=secret_key)
74+
return Order(account, contract, action, 'TRAIL', quantity, trailing_percent=trailing_percent, aux_price=aux_price)
7775

7876

7977
def order_leg(leg_type, price, time_in_force='DAY', outside_rth=None):
@@ -87,7 +85,7 @@ def order_leg(leg_type, price, time_in_force='DAY', outside_rth=None):
8785
return OrderLeg(leg_type=leg_type, price=price, time_in_force=time_in_force, outside_rth=outside_rth)
8886

8987

90-
def limit_order_with_legs(account, contract, action, quantity, limit_price, order_legs=None, secret_key=None):
88+
def limit_order_with_legs(account, contract, action, quantity, limit_price, order_legs=None):
9189
"""
9290
限价单 + 附加订单(仅环球账户支持)
9391
:param account:
@@ -100,8 +98,7 @@ def limit_order_with_legs(account, contract, action, quantity, limit_price, orde
10098
"""
10199
if order_legs and len(order_legs) > 2:
102100
raise Exception('2 order legs at most')
103-
return Order(account, contract, action, 'LMT', quantity, limit_price=limit_price, order_legs=order_legs,
104-
secret_key=secret_key)
101+
return Order(account, contract, action, 'LMT', quantity, limit_price=limit_price, order_legs=order_legs)
105102

106103

107104
def algo_order_params(start_time=None, end_time=None, no_take_liq=None, allow_past_end_time=None, participation_rate=None):
@@ -118,7 +115,7 @@ def algo_order_params(start_time=None, end_time=None, no_take_liq=None, allow_pa
118115
allow_past_end_time=allow_past_end_time, participation_rate=participation_rate)
119116

120117

121-
def algo_order(account, contract, action, quantity, strategy, algo_params=None, limit_price=None, secret_key=None):
118+
def algo_order(account, contract, action, quantity, strategy, algo_params=None, limit_price=None):
122119
"""
123120
算法订单
124121
:param account:
@@ -131,7 +128,7 @@ def algo_order(account, contract, action, quantity, strategy, algo_params=None,
131128
:return:
132129
"""
133130
return Order(account, contract, action, order_type=strategy, quantity=quantity, algo_params=algo_params,
134-
limit_price=limit_price, outside_rth=False, secret_key=secret_key)
131+
limit_price=limit_price, outside_rth=False)
135132

136133

137134
def get_order_status(value):

tigeropen/trade/trade_client.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_contract(self, symbol, sec_type=SecurityType.STK, currency=None, exchang
153153
return None
154154

155155
def get_positions(self, account=None, sec_type=SecurityType.STK, currency=Currency.ALL, market=Market.ALL,
156-
symbol=None, sub_accounts=None, secret_key=None):
156+
symbol=None, sub_accounts=None):
157157
"""
158158
获取持仓数据
159159
:param account:
@@ -174,7 +174,7 @@ def get_positions(self, account=None, sec_type=SecurityType.STK, currency=Curren
174174
"""
175175
params = PositionParams()
176176
params.account = account if account else self._account
177-
params.secret_key = secret_key if secret_key else self._secret_key
177+
params.secret_key = self._secret_key
178178
if sec_type:
179179
params.sec_type = sec_type.value
180180
params.sub_accounts = sub_accounts
@@ -196,7 +196,7 @@ def get_positions(self, account=None, sec_type=SecurityType.STK, currency=Curren
196196

197197
return None
198198

199-
def get_assets(self, account=None, sub_accounts=None, segment=False, market_value=False, secret_key=None):
199+
def get_assets(self, account=None, sub_accounts=None, segment=False, market_value=False):
200200
"""
201201
获取账户资产信息
202202
:param account:
@@ -229,7 +229,7 @@ def get_assets(self, account=None, sub_accounts=None, segment=False, market_valu
229229
"""
230230
params = AssetParams()
231231
params.account = account if account else self._account
232-
params.secret_key = secret_key if secret_key else self._secret_key
232+
params.secret_key = self._secret_key
233233
params.sub_accounts = sub_accounts
234234
params.segment = segment
235235
params.market_value = market_value
@@ -247,7 +247,7 @@ def get_assets(self, account=None, sub_accounts=None, segment=False, market_valu
247247
return None
248248

249249
def get_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None, end_time=None,
250-
limit=100, is_brief=False, states=None, secret_key=None):
250+
limit=100, is_brief=False, states=None):
251251
"""
252252
获取订单列表
253253
:param account:
@@ -264,7 +264,7 @@ def get_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None
264264
"""
265265
params = OrdersParams()
266266
params.account = account if account else self._account
267-
params.secret_key = secret_key if secret_key else self._secret_key
267+
params.secret_key = self._secret_key
268268
if sec_type:
269269
params.sec_type = sec_type.value
270270
params.market = market.value
@@ -286,14 +286,14 @@ def get_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None
286286
return None
287287

288288
def get_open_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None,
289-
end_time=None, parent_id=None, secret_key=None):
289+
end_time=None, parent_id=None):
290290
"""
291291
获取待成交订单列表. 参数同 get_orders
292292
:param parent_id: 主订单 order_id
293293
"""
294294
params = OrdersParams()
295295
params.account = account if account else self._account
296-
params.secret_key = secret_key if secret_key else self._secret_key
296+
params.secret_key = self._secret_key
297297
if sec_type:
298298
params.sec_type = sec_type.value
299299
params.market = market.value
@@ -313,13 +313,13 @@ def get_open_orders(self, account=None, sec_type=None, market=Market.ALL, symbol
313313
return None
314314

315315
def get_cancelled_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None,
316-
end_time=None, secret_key=None):
316+
end_time=None):
317317
"""
318318
获取已撤销订单列表. 参数同 get_orders
319319
"""
320320
params = OrdersParams()
321321
params.account = account if account else self._account
322-
params.secret_key = secret_key if secret_key else self._secret_key
322+
params.secret_key = self._secret_key
323323
if sec_type:
324324
params.sec_type = sec_type.value
325325
params.market = market.value
@@ -338,13 +338,13 @@ def get_cancelled_orders(self, account=None, sec_type=None, market=Market.ALL, s
338338
return None
339339

340340
def get_filled_orders(self, account=None, sec_type=None, market=Market.ALL, symbol=None, start_time=None,
341-
end_time=None, secret_key=None):
341+
end_time=None):
342342
"""
343343
获取已成交订单列表. 参数同 get_orders
344344
"""
345345
params = OrdersParams()
346346
params.account = account if account else self._account
347-
params.secret_key = secret_key if secret_key else self._secret_key
347+
params.secret_key = self._secret_key
348348
if sec_type:
349349
params.sec_type = sec_type.value
350350
params.market = market.value
@@ -362,7 +362,7 @@ def get_filled_orders(self, account=None, sec_type=None, market=Market.ALL, symb
362362
raise ApiException(response.code, response.message)
363363
return None
364364

365-
def get_order(self, account=None, id=None, order_id=None, is_brief=False, secret_key=None):
365+
def get_order(self, account=None, id=None, order_id=None, is_brief=False):
366366
"""
367367
获取指定订单
368368
:param account:
@@ -373,7 +373,7 @@ def get_order(self, account=None, id=None, order_id=None, is_brief=False, secret
373373
"""
374374
params = OrderParams()
375375
params.account = account if account else self._account
376-
params.secret_key = secret_key if secret_key else self._secret_key
376+
params.secret_key = self._secret_key
377377
params.id = id
378378
params.order_id = order_id
379379
params.is_brief = is_brief
@@ -390,7 +390,7 @@ def get_order(self, account=None, id=None, order_id=None, is_brief=False, secret
390390

391391
def create_order(self, account, contract, action, order_type, quantity, limit_price=None, aux_price=None,
392392
trail_stop_price=None, trailing_percent=None, percent_offset=None, time_in_force=None,
393-
outside_rth=None, order_legs=None, algo_params=None, secret_key=None):
393+
outside_rth=None, order_legs=None, algo_params=None):
394394
"""
395395
创建订单对象.
396396
:param account:
@@ -407,11 +407,10 @@ def create_order(self, account, contract, action, order_type, quantity, limit_pr
407407
:param outside_rth: 是否允许盘前盘后交易(美股专属)
408408
:param order_legs: 附加订单
409409
:param algo_params: 算法订单参数
410-
:param secret_key: 机构密钥
411410
"""
412411
params = AccountsParams()
413412
params.account = account if account else self._account
414-
params.secret_key = secret_key if secret_key else self._secret_key
413+
params.secret_key = self._secret_key
415414
request = OpenApiRequest(ORDER_NO, biz_model=params)
416415
response_content = self.__fetch_data(request)
417416
if response_content:
@@ -560,7 +559,7 @@ def modify_order(self, order, quantity=None, limit_price=None, aux_price=None,
560559

561560
return False
562561

563-
def cancel_order(self, account=None, id=None, order_id=None, secret_key=None):
562+
def cancel_order(self, account=None, id=None, order_id=None):
564563
"""
565564
取消订单
566565
:param account:
@@ -570,7 +569,7 @@ def cancel_order(self, account=None, id=None, order_id=None, secret_key=None):
570569
"""
571570
params = CancelOrderParams()
572571
params.account = account if account else self._account
573-
params.secret_key = secret_key if secret_key else self._secret_key
572+
params.secret_key = self._secret_key
574573
params.order_id = order_id
575574
params.id = id
576575
request = OpenApiRequest(CANCEL_ORDER, biz_model=params)

0 commit comments

Comments
 (0)