OrderContingency
QuantConnect.Orders.OrderContingency
OrderContingency(
id: int, count: int, links: List[ContingencyLink]
)
OrderContingency(count: int, links: List[ContingencyLink])
Bases: Object
The contingency of an order: the set of contingent orders it belongs to (OCO, OTO, OUO and any composition of them, like brackets) and the links defining how this order relates to the rest of the set
Signature descriptions:
-
Creates the contingency of the first order of a new set of contingent orders, the rest are created through with_links
-
Creates the contingency of the first order of a new set of contingent orders, the rest are created through with_links. The set id is assigned once the orders are added into the algorithm
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
Optional[int]
|
The unique id of the set of contingent orders |
None
|
count
|
int
|
The total order count in the set |
required |
links
|
List[ContingencyLink]
|
The links of this order to the rest of the set |
required |
id
id: int
The unique id of the set of contingent orders this order belongs to
count
count: int
The total order count in the set of contingent orders
order_ids
order_ids: HashSet[int]
The ids of the orders in the set
symbols
symbols: IReadOnlySet[Symbol]
The different symbols of the orders in the set. Allows a brokerage model to validate a single order knowing about the rest of the set. Only available at submission time
directions
directions: IReadOnlySet[OrderDirection]
The different directions of the orders in the set. Allows a brokerage model to validate a single order knowing about the rest of the set. Only available at submission time
order_types
order_types: IReadOnlySet[OrderType]
The different order types of the orders in the set. Allows a brokerage model to validate a single order knowing about the rest of the set. Only available at submission time
links
links: Sequence[ContingencyLink]
The links of this order to the rest of the set: the role it plays in each contingency
is_waiting_for_trigger
is_waiting_for_trigger: bool
True if this is a contingent child order still open and held, waiting for its parent order to fill
clone
clone() -> OrderContingency
Creates a copy of this instance: the set is shared, the links are cloned
get_units
Groups the orders into units, preserving their order: each order on its own except for the legs of a combo order which go together
relate
relate(type: ContingencyType, members: List[Order]) -> None
Helper for brokerages to rebuild the contingencies of their open orders: relates the orders to each other as siblings, One Cancels Other or One Updates Other, joining them into a single set of contingent orders
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
ContingencyType
|
The type of the relation |
required |
members
|
List[Order]
|
The orders to relate, all the legs for combo orders |
required |
to_string
to_string() -> str
Returns a string that represents the current object
trigger
Helper for brokerages to rebuild the contingencies of their open orders: relates the parent order to the orders it triggers once it completely fills (One Triggers Other), joining them into a single set of contingent orders
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
List[Order]
|
The parent order, all the legs for a combo order |
required |
children
|
List[Order]
|
The orders to trigger, all the legs for combo orders |
required |
with_links
with_links(
links: List[ContingencyLink],
) -> OrderContingency
Creates the contingency of another order of the same set of contingent orders: it shares the set with this instance, with the given links of its own
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
List[ContingencyLink]
|
The links of the other order to the rest of the set |
required |