Skip to main content

Multi-Condition Order with TP/SL

multi_condition

TP/SL Notes
  • TP/SL settings only trigger order placement and do not guarantee execution. Please adjust based on market conditions.
  • Make sure the TP/SL order type is compatible with the applicable trading rules (e.g., margin trading, margin buy/sell, etc.).
info

TP/SL will only start after the parent order is fully filled.

Input Parameters

ParameterTypeDescription
accountAccountTrading account
start_datestringCondition monitoring start time
end_datestringCondition monitoring end time
stop_signStopSignStop condition: FULL = until fully filled, PARTIAL = until partially filled, UNTIL_END = until validity ends
MultiConditionCondition ListTrigger condition(s)
ConditionOrder ObjectConditionOrder ObjectOrder request payload
TPSLObjectTpslWrapperTP/SL configuration

Result

ParameterTypeDescription
is_successboolWhether the request succeeded
dataObjectReturned information for the condition order
messagestring ? (optional)Error message when isSuccess = false

ConditionOrderResult Fields (Order Info)

Return type: Object

ParameterTypeDescription
guidstringCondition order ID

Request Example

// Define the conditions
Condition condition = Condition{
TradingType::REFERENCE,
"2881",
TriggerContent::MATCHED_PRICE,
"66",
Operator::LESS_THAN,
};

Condition condition2 = Condition{
TradingType::REFERENCE,
"2881",
TriggerContent::TOTAL_QUANTITY,
"1000",
Operator::GREATER_THAN,
};

std::vector<Condition> conditions;
conditions.push_back(condition);
conditions.push_back(condition2);


ConditionOrder order = ConditionOrder{
BsAction::BUY,
"2330",
"1000",
1000,
ConditionMarketType::COMMON,
ConditionPriceType::LIMIT,
TimeInForce::ROD,
ConditionOrderType::STOCK,
};


TpslOrder tp = TpslOrder{
TimeInForce::ROD,
ConditionPriceType::LIMIT,
ConditionOrderType::STOCK,
"85",
"85",
};

TpslOrder sl = TpslOrder{
TimeInForce::ROD,
ConditionPriceType::LIMIT,
ConditionOrderType::STOCK,
"60",
"60",
};

TPSLWrapper tpsl = TPSLWrapper{
StopSign::FULL,
tp,
sl,
"20250605",
false
};


auto send_condition_order = sdk->stock->multi_condition(target_account, "20250605", "20250605", StopSign::FULL, conditions, order, tpsl);

if (!send_condition_order.is_success) {
std::cout << "get order result failed reason: "
<< (send_condition_order.message.has_value() ? send_condition_order.message.value() : "No message")
<< std::endl;
}
else {
if (send_condition_order.data.has_value()) {
const auto& send = send_condition_order.data.value();
std::cout << send << std::endl;
}
else {
std::cout << "Order result success but no data returned." << std::endl;
}
}

Response Example

{
isSuccess = true,
message = ,
data = ConditionOrderResult {
guid = 44150047-8977-40b1-953c-ce2XXXXXX
}
}