OrderSizing
QuantConnect.Orders.OrderSizing
Bases: Object
Provides methods for computing a maximum order size.
get_unordered_quantity
get_unordered_quantity(
algorithm: IAlgorithm, target: IPortfolioTarget
) -> float
get_unordered_quantity(
algorithm: IAlgorithm,
target: IPortfolioTarget,
security: Security,
account_for_fees: bool = False,
) -> float
Gets the remaining quantity to be ordered to reach the specified target quantity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algorithm
|
IAlgorithm
|
The algorithm instance |
required |
target
|
IPortfolioTarget
|
The portfolio target |
required |
security
|
Optional[Security]
|
The target security |
None
|
account_for_fees
|
Optional[bool]
|
True for taking into account the fee's in the order quantity. |
False
|
Returns:
| Type | Description |
|---|---|
float
|
The signed remaining quantity to be ordered. |
adjust_by_lot_size
adjust_by_lot_size(
security: Security, quantity: float
) -> float
Adjusts the provided order quantity to respect the securities lot size. If the quantity is missing 1M part of the lot size it will be rounded up since we suppose it's due to floating point error, this is required to avoid diff between Py and C#
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security instance |
required |
quantity
|
float
|
The desired quantity to adjust, can be signed |
required |
Returns:
| Type | Description |
|---|---|
float
|
The signed adjusted quantity. |
get_order_size_for_maximum_value
get_order_size_for_maximum_value(
security: Security,
maximum_order_value_in_account_currency: float,
desired_order_size: float,
) -> float
Adjust the provided order size to respect the maximum total order value
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security object |
required |
maximum_order_value_in_account_currency
|
float
|
The maximum order value in units of the account currency |
required |
desired_order_size
|
float
|
The desired order size to adjust |
required |
Returns:
| Type | Description |
|---|---|
float
|
The signed adjusted order size. |
get_order_size_for_percent_volume
get_order_size_for_percent_volume(
security: Security,
maximum_percent_current_volume: float,
desired_order_size: float,
) -> float
Adjust the provided order size to respect maximum order size based on a percentage of current volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
security
|
Security
|
The security object |
required |
maximum_percent_current_volume
|
float
|
The maximum percentage of the current bar's volume |
required |
desired_order_size
|
float
|
The desired order size to adjust |
required |
Returns:
| Type | Description |
|---|---|
float
|
The signed adjusted order size. |