Skip to main content

Trailing-profit conditional order

trail_profit

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, UntilEnd until the end of the validity period
TrailOrderTrailOrderOrder split conditions
caution

The base price (price) in TrailOrder can only be entered to two decimal places. If it exceeds the price, the system will fail to validate the price.

info

When the current stock price reaches the trigger price (the percentage increase or decrease calculated based on the base price), place an order immediately

Example: If the initial base price is set to 100, and a stop loss/profit order is placed 5% lower, the initial trigger price is 95. If the price does not rise above 100 (that is, the base price is not adjusted), the order will be triggered when the market price is 95.

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
TrailOrder trail = TrailOrder{
"2330",
"1000",
Direction::UP,
5,
BsAction::BUY,
2000,
ConditionPriceType::MATCHED_PRICE,
5,
TimeInForce::ROD,
ConditionOrderType::STOCK
};


auto trail_order = sdk->stock->trail_profit(target_account, "20250606","20250606", StopSign::FULL, trail);

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

Return example


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