|
4 | 4 |
|
5 | 5 | @author: gaoan |
6 | 6 | """ |
7 | | -from tigeropen.trade.domain.order import Order |
| 7 | +from tigeropen.trade.domain.order import Order, OrderLeg |
8 | 8 | from tigeropen.common.consts import OrderStatus |
9 | 9 |
|
10 | 10 |
|
@@ -74,6 +74,33 @@ def trail_order(account, contract, action, quantity, trailing_percent=None, aux_ |
74 | 74 | return Order(account, contract, action, 'TRAIL', quantity, trailing_percent=trailing_percent, aux_price=aux_price) |
75 | 75 |
|
76 | 76 |
|
| 77 | +def order_leg(leg_type, price, time_in_force='DAY', outside_rth=None): |
| 78 | + """ |
| 79 | + 附加订单 |
| 80 | + :param leg_type: 附加订单类型. PROFIT 止盈单类型, LOSS 止损单类型 |
| 81 | + :param price: 附加订单价格. |
| 82 | + :param time_in_force: 附加订单有效期. 'DAY'(当日有效)和'GTC'(取消前有效 Good-Til-Canceled). |
| 83 | + :param outside_rth: 附加订单是否允许盘前盘后交易(美股专属). True 允许, False 不允许. |
| 84 | + """ |
| 85 | + return OrderLeg(leg_type=leg_type, price=price, time_in_force=time_in_force, outside_rth=outside_rth) |
| 86 | + |
| 87 | + |
| 88 | +def limit_order_with_legs(account, contract, action, quantity, limit_price, order_legs=None): |
| 89 | + """ |
| 90 | + 限价单 + 附加订单(仅环球账户支持) |
| 91 | + :param account: |
| 92 | + :param contract: |
| 93 | + :param action: BUY/SELL |
| 94 | + :param quantity: |
| 95 | + :param limit_price: 限价单价格 |
| 96 | + :param order_legs: 附加订单列表 |
| 97 | + :return: |
| 98 | + """ |
| 99 | + if order_legs and len(order_legs) > 2: |
| 100 | + raise Exception('2 order legs at most') |
| 101 | + return Order(account, contract, action, 'LMT', quantity, limit_price=limit_price, order_legs=order_legs) |
| 102 | + |
| 103 | + |
77 | 104 | def get_order_status(value): |
78 | 105 | """ |
79 | 106 | Invalid(-2), Initial(-1), PendingCancel(3), Cancelled(4), Submitted(5), Filled(6), Inactive(7), PendingSubmit(8) |
|
0 commit comments