OrderFactory
QuantConnect.Orders.OrderFactory
OrderFactory(algorithm: IAlgorithm)
Bases: Object
Creates SubmitOrderRequest for an algorithm to be submitted later, so they can be composed into contingent orders before: an order can trigger others once it fills (SubmitOrderRequest.triggers(SubmitOrderRequest<>)), which can in turn cancel (one_cancels_other(SubmitOrderRequest<>)) or update (one_updates_other(SubmitOrderRequest<>)) each other, see SubmitOrderRequest.bracket. The order id and the contingency set id of the requests are assigned once they are submitted
Creates a new instance for the given algorithm, which provides the time and default order properties of the requests
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
IAlgorithm
|
The algorithm instance |
required |
one_cancels_other
one_cancels_other(
*orders: Union[
SubmitOrderRequest, Iterable[SubmitOrderRequest]
]
) -> List[SubmitOrderRequest]
one_cancels_other(
orders: List[SubmitOrderRequest],
) -> List[SubmitOrderRequest]
Relates the orders so that once one of them fills, even partially, the rest are canceled (One Cancels Other/All)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orders
|
Union[SubmitOrderRequest, Iterable[SubmitOrderRequest]]
|
The orders to relate |
()
|
Returns:
| Type | Description |
|---|---|
List[SubmitOrderRequest]
|
The same orders, so they can be submitted or triggered by another order. |
one_updates_other
one_updates_other(
*orders: Union[
SubmitOrderRequest, Iterable[SubmitOrderRequest]
]
) -> List[SubmitOrderRequest]
one_updates_other(
orders: List[SubmitOrderRequest],
) -> List[SubmitOrderRequest]
Relates the orders so that once one of them partially fills the remaining quantity of the rest is reduced proportionally, and canceled once it completely fills (One Updates Other)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orders
|
Union[SubmitOrderRequest, Iterable[SubmitOrderRequest]]
|
The orders to relate |
()
|
Returns:
| Type | Description |
|---|---|
List[SubmitOrderRequest]
|
The same orders, so they can be submitted or triggered by another order. |
trailing_stop_order
trailing_stop_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
trailing_amount: float,
trailing_as_percentage: bool,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
trailing_stop_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
stop_price: float,
trailing_amount: float,
trailing_as_percentage: bool,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Signature descriptions:
-
Trailing stop order request. The initial stop price is calculated based on the market price at the time the order starts working: once submitted, or once triggered for an order triggered by another
-
Trailing stop order request with an initial stop price
combo_leg_limit_order
combo_leg_limit_order(
legs: List[Leg],
quantity: int,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> List[SubmitOrderRequest]
Combo leg limit order requests, one per leg, each leg with its own limit price
combo_limit_order
combo_limit_order(
legs: List[Leg],
quantity: int,
limit_price: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> List[SubmitOrderRequest]
Combo limit order requests, one per leg, with a single limit price for the combo
combo_market_order
combo_market_order(
legs: List[Leg],
quantity: int,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> List[SubmitOrderRequest]
Combo market order requests, one per leg. The legs are a single unit: composed and submitted together
exercise_option
exercise_option(
option_symbol: Union[
Symbol, str, BaseContract, Security
],
quantity: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Option exercise order request
limit_if_touched_order
limit_if_touched_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
trigger_price: float,
limit_price: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Limit if touched order request
limit_order
limit_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
limit_price: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Limit order request
market_on_close_order
market_on_close_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Market on close order request
market_on_open_order
market_on_open_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Market on open order request
market_order
market_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Market order request
option_strategy_order
option_strategy_order(
strategy: OptionStrategy,
quantity: int,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> List[SubmitOrderRequest]
Option strategy order requests, a combo market order of the strategy legs
stop_limit_order
stop_limit_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
stop_price: float,
limit_price: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Stop limit order request
stop_market_order
stop_market_order(
symbol: Union[Symbol, str, BaseContract, Security],
quantity: float,
stop_price: float,
asynchronous: bool = False,
tag: str = ...,
order_properties: IOrderProperties = None,
) -> SubmitOrderRequest
Stop market order request