99from tigeropen .common .consts import OrderStatus , OrderType
1010
1111
12- def market_order (account , contract , action , quantity ):
12+ def market_order (account , contract , action , quantity , time_in_force = 'DAY' ):
1313 """
1414 市价单
1515 :param account:
@@ -18,10 +18,10 @@ def market_order(account, contract, action, quantity):
1818 :param quantity:
1919 :return:
2020 """
21- return Order (account , contract , action , 'MKT' , quantity )
21+ return Order (account , contract , action , 'MKT' , quantity , time_in_force = time_in_force )
2222
2323
24- def market_order_by_amount (account , contract , action , amount ):
24+ def market_order_by_amount (account , contract , action , amount , time_in_force = 'DAY' ):
2525 """
2626 按金额的市价单(用于基金)
2727 :param account:
@@ -30,10 +30,10 @@ def market_order_by_amount(account, contract, action, amount):
3030 :param amount:
3131 :return:
3232 """
33- return Order (account , contract , action , 'MKT' , total_cash_amount = amount )
33+ return Order (account , contract , action , 'MKT' , total_cash_amount = amount , time_in_force = time_in_force )
3434
3535
36- def limit_order (account , contract , action , quantity , limit_price ):
36+ def limit_order (account , contract , action , quantity , limit_price , time_in_force = 'DAY' ):
3737 """
3838 限价单
3939 :param account:
@@ -43,10 +43,10 @@ def limit_order(account, contract, action, quantity, limit_price):
4343 :param limit_price: 限价的价格
4444 :return:
4545 """
46- return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price )
46+ return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price , time_in_force = time_in_force )
4747
4848
49- def stop_order (account , contract , action , quantity , aux_price ):
49+ def stop_order (account , contract , action , quantity , aux_price , time_in_force = 'DAY' ):
5050 """
5151 止损单
5252 :param account:
@@ -56,10 +56,10 @@ def stop_order(account, contract, action, quantity, aux_price):
5656 :param aux_price: 触发止损单的价格
5757 :return:
5858 """
59- return Order (account , contract , action , 'STP' , quantity , aux_price = aux_price )
59+ return Order (account , contract , action , 'STP' , quantity , aux_price = aux_price , time_in_force = time_in_force )
6060
6161
62- def stop_limit_order (account , contract , action , quantity , limit_price , aux_price ):
62+ def stop_limit_order (account , contract , action , quantity , limit_price , aux_price , time_in_force = 'DAY' ):
6363 """
6464 限价止损单
6565 :param account:
@@ -70,10 +70,11 @@ def stop_limit_order(account, contract, action, quantity, limit_price, aux_price
7070 :param aux_price: 触发止损单的价格
7171 :return:
7272 """
73- return Order (account , contract , action , 'STP_LMT' , quantity , limit_price = limit_price , aux_price = aux_price )
73+ return Order (account , contract , action , 'STP_LMT' , quantity , limit_price = limit_price , aux_price = aux_price ,
74+ time_in_force = time_in_force )
7475
7576
76- def trail_order (account , contract , action , quantity , trailing_percent = None , aux_price = None ):
77+ def trail_order (account , contract , action , quantity , trailing_percent = None , aux_price = None , time_in_force = 'DAY' ):
7778 """
7879 移动止损单
7980 :param account:
@@ -84,7 +85,8 @@ def trail_order(account, contract, action, quantity, trailing_percent=None, aux_
8485 :param aux_price: 价差 aux_price 和 trailing_percent 两者互斥
8586 :return:
8687 """
87- return Order (account , contract , action , 'TRAIL' , quantity , trailing_percent = trailing_percent , aux_price = aux_price )
88+ return Order (account , contract , action , 'TRAIL' , quantity , trailing_percent = trailing_percent ,
89+ aux_price = aux_price , time_in_force = time_in_force )
8890
8991
9092def auction_limit_order (account , contract , action , quantity , limit_price , time_in_force = 'DAY' ):
@@ -135,7 +137,7 @@ def order_leg(leg_type, price=None, time_in_force='DAY', outside_rth=None, limit
135137 quantity = quantity )
136138
137139
138- def limit_order_with_legs (account , contract , action , quantity , limit_price , order_legs = None ):
140+ def limit_order_with_legs (account , contract , action , quantity , limit_price , order_legs = None , time_in_force = 'DAY' ):
139141 """
140142 限价单 + 附加订单(仅环球账户支持)
141143 :param account:
@@ -148,7 +150,8 @@ def limit_order_with_legs(account, contract, action, quantity, limit_price, orde
148150 """
149151 if order_legs and len (order_legs ) > 2 :
150152 raise Exception ('2 order legs at most' )
151- return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price , order_legs = order_legs )
153+ return Order (account , contract , action , 'LMT' , quantity , limit_price = limit_price , order_legs = order_legs ,
154+ time_in_force = time_in_force )
152155
153156
154157def algo_order_params (start_time = None , end_time = None , no_take_liq = None , allow_past_end_time = None ,
@@ -166,7 +169,7 @@ def algo_order_params(start_time=None, end_time=None, no_take_liq=None, allow_pa
166169 allow_past_end_time = allow_past_end_time , participation_rate = participation_rate )
167170
168171
169- def algo_order (account , contract , action , quantity , strategy , algo_params = None , limit_price = None ):
172+ def algo_order (account , contract , action , quantity , strategy , algo_params = None , limit_price = None , time_in_force = 'DAY' ):
170173 """
171174 算法订单
172175 :param account:
@@ -179,7 +182,7 @@ def algo_order(account, contract, action, quantity, strategy, algo_params=None,
179182 :return:
180183 """
181184 return Order (account , contract , action , order_type = strategy , quantity = quantity , algo_params = algo_params ,
182- limit_price = limit_price , outside_rth = False )
185+ limit_price = limit_price , outside_rth = False , time_in_force = time_in_force )
183186
184187
185188def contract_leg (symbol = None , sec_type = None , expiry = None , strike = None , put_call = None , action = None ,
0 commit comments