88from tigeropen .common .consts import OrderStatus
99
1010
11- def market_order (account , contract , action , quantity ):
11+ def market_order (account , contract , action , quantity , user_id = None ):
1212 """
1313 市价单
1414 :param account:
@@ -17,10 +17,10 @@ def market_order(account, contract, action, quantity):
1717 :param quantity:
1818 :return:
1919 """
20- return Order (account , contract , action , 'MKT' , quantity )
20+ return Order (account , contract , action , 'MKT' , quantity , user_id = user_id )
2121
2222
23- def limit_order (account , contract , action , quantity , limit_price ):
23+ def limit_order (account , contract , action , quantity , limit_price , user_id = None ):
2424 """
2525 限价单
2626 :param account:
@@ -30,10 +30,10 @@ def limit_order(account, contract, action, quantity, limit_price):
3030 :param limit_price: 限价的价格
3131 :return:
3232 """
33- return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price )
33+ return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price , user_id = user_id )
3434
3535
36- def stop_order (account , contract , action , quantity , aux_price ):
36+ def stop_order (account , contract , action , quantity , aux_price , user_id = None ):
3737 """
3838 止损单
3939 :param account:
@@ -43,10 +43,10 @@ def stop_order(account, contract, action, quantity, aux_price):
4343 :param aux_price: 触发止损单的价格
4444 :return:
4545 """
46- return Order (account , contract , action , 'STP' , quantity , aux_price = aux_price )
46+ return Order (account , contract , action , 'STP' , quantity , aux_price = aux_price , user_id = user_id )
4747
4848
49- def stop_limit_order (account , contract , action , quantity , limit_price , aux_price ):
49+ def stop_limit_order (account , contract , action , quantity , limit_price , aux_price , user_id = None ):
5050 """
5151 限价止损单
5252 :param account:
@@ -57,10 +57,11 @@ 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 )
60+ return Order (account , contract , action , 'STP_LMT' , quantity , limit_price = limit_price , aux_price = aux_price ,
61+ user_id = user_id )
6162
6263
63- def trail_order (account , contract , action , quantity , trailing_percent = None , aux_price = None ):
64+ def trail_order (account , contract , action , quantity , trailing_percent = None , aux_price = None , user_id = None ):
6465 """
6566 移动止损单
6667 :param account:
@@ -71,7 +72,8 @@ def trail_order(account, contract, action, quantity, trailing_percent=None, aux_
7172 :param aux_price: 价差 aux_price 和 trailing_percent 两者互斥
7273 :return:
7374 """
74- return Order (account , contract , action , 'TRAIL' , quantity , trailing_percent = trailing_percent , aux_price = aux_price )
75+ return Order (account , contract , action , 'TRAIL' , quantity , trailing_percent = trailing_percent , aux_price = aux_price ,
76+ user_id = user_id )
7577
7678
7779def order_leg (leg_type , price , time_in_force = 'DAY' , outside_rth = None ):
@@ -85,7 +87,7 @@ def order_leg(leg_type, price, time_in_force='DAY', outside_rth=None):
8587 return OrderLeg (leg_type = leg_type , price = price , time_in_force = time_in_force , outside_rth = outside_rth )
8688
8789
88- def limit_order_with_legs (account , contract , action , quantity , limit_price , order_legs = None ):
90+ def limit_order_with_legs (account , contract , action , quantity , limit_price , order_legs = None , user_id = None ):
8991 """
9092 限价单 + 附加订单(仅环球账户支持)
9193 :param account:
@@ -98,7 +100,8 @@ def limit_order_with_legs(account, contract, action, quantity, limit_price, orde
98100 """
99101 if order_legs and len (order_legs ) > 2 :
100102 raise Exception ('2 order legs at most' )
101- return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price , order_legs = order_legs )
103+ return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price , order_legs = order_legs ,
104+ user_id = user_id )
102105
103106
104107def algo_order_params (start_time = None , end_time = None , no_take_liq = None , allow_past_end_time = None , participation_rate = None ):
@@ -115,7 +118,7 @@ def algo_order_params(start_time=None, end_time=None, no_take_liq=None, allow_pa
115118 allow_past_end_time = allow_past_end_time , participation_rate = participation_rate )
116119
117120
118- def algo_order (account , contract , action , quantity , strategy , algo_params = None , limit_price = None ):
121+ def algo_order (account , contract , action , quantity , strategy , algo_params = None , limit_price = None , user_id = None ):
119122 """
120123 算法订单
121124 :param account:
@@ -128,7 +131,7 @@ def algo_order(account, contract, action, quantity, strategy, algo_params=None,
128131 :return:
129132 """
130133 return Order (account , contract , action , order_type = strategy , quantity = quantity , algo_params = algo_params ,
131- limit_price = limit_price , outside_rth = False )
134+ limit_price = limit_price , outside_rth = False , user_id = user_id )
132135
133136
134137def get_order_status (value ):
0 commit comments