Condition
Conditional order configuration structure, used to set trigger conditions and execution prices for conditional orders.
Attributes
| Name | Type | Description |
ConditionType | number | Conditional order type, available values:
|
TpTriggerPrice | number | Take profit trigger price. Used when the conditional order type is TP or OCO, the take profit order is triggered when the market price reaches this price. |
TpOrderPrice | number | Take profit order execution price, i.e., the actual order price after take profit is triggered. A price of -1 indicates execution as a market order. |
SlTriggerPrice | number | Stop loss trigger price. Used when the conditional order type is SL or OCO, the stop loss order is triggered when the market price reaches this price. |
SlOrderPrice | number | Stop loss order execution price, i.e., the actual order price after stop loss is triggered. A price of -1 indicates execution as a market order. |
See Also
Remarks
- OCO orders (ConditionType=
ORDER_CONDITION_TYPE_OCO) set both take profit and stop loss conditions simultaneously. When one condition is triggered, the other is automatically canceled. - TP orders (ConditionType=
ORDER_CONDITION_TYPE_TP) only use the TpTriggerPrice and TpOrderPrice fields. - SL orders (ConditionType=
ORDER_CONDITION_TYPE_SL) only use the SlTriggerPrice and SlOrderPrice fields. - GENERIC orders (ConditionType=
ORDER_CONDITION_TYPE_GENERIC) are generic conditional orders, and the specific fields used depend on the exchange implementation.
Support for conditional order functionality depends on the specific exchange. Some exchanges may not support certain types of conditional orders.
Special usage of Condition structure in C++ language:
In C++ strategies, the Condition structure needs to use the OrderCondition struct type instead of a JSON object.
JavaScript/Python example (using object/dictionary):
javascript
var condition = {
ConditionType: ORDER_CONDITION_TYPE_TP,
TpTriggerPrice: 65000,
TpOrderPrice: 65000
}
C++ example (using OrderCondition struct):
c++
OrderCondition condition = {.ConditionType = ORDER_CONDITION_TYPE_TP, .TpTriggerPrice = 65000, .TpOrderPrice = 65000};
Note: In C++, you should not use the JSON string approach json condition = R"({...})"_json;. Instead, use the OrderCondition struct initialization syntax directly.