Skip to main content

A single conditional order includes stop loss and profit stop

single_condition

Notes on stop loss and profit
  • The stop loss and profit setting is only to trigger the order, and does not guarantee that the transaction will be completed. It needs to be adjusted according to the market conditions.
  • Please confirm that the stop loss and profit order type setting must comply with the appropriate trading rules (such as credit trading, asset buying and selling, etc.)
info

The stop loss and stop profit part will not be activated until the main order is fully executed.

Input parameters

ParametersCategoryDescription
accountAccountaccount
start_datestringConditional start monitoring time
end_datestringCondition end monitoring time
stop_signStopSignConditional stop conditions: FULL until all transactions are completed, PARTIAL until partial transactions are completed, UNTIL_END until the end of the validity period
conditionConditionTrigger condition
ConditionOrder ObjectConditionOrder ObjectOrder details
TPSLObjectTpslWrapperStop loss and stop profit conditions

Result return

ParametersCategoryDescription
is_successboolWhether it was successful
dataObjectConditional order return information
messagestring ? (optional)Return error message when isSuccess = false

Order information ConditionOrderResult field

Return type : Object

ParametersCategoryDescription
guidstringcondition order number

Request example

//Design condition content
Condition condition = Condition{
TradingType::REFERENCE,
"2881",
TriggerContent::MATCHED_PRICE,
"66",
Operator::LESS_THAN,
};

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->single_condition(target_account, "20250605", "20250605", StopSign::FULL, condition, 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;
}
}

Return example

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