多條件單包含停損停利
multi_condition
停損利注意事項
- 停損利設定僅為觸發送單,不保證必定成交,需視市場狀況自行調整
- 請確認停損利委託類別設定需符合適合之交易規則(例如信用交易資買資賣等)
info
待主單完全成交後,停損停利部分才會啟動
輸入參數
| 參數 | 類別 | 說明 |
|---|---|---|
| account | Account | 帳號 |
| start_date | string | 條件開始監控時間 |
| end_date | string | 條件結束監控時間 |
| stop_sign | StopSign | 條件停止條件 :FULL 全部成交為止、PARTIAL部分成交為止、UNTIL_END效期結束為止 |
| MultiCondition | Condition List | 觸發條件 |
| ConditionOrder Object | ConditionOrder Object | 委託內容 |
| TPSLObject | TpslWrapper | 停損停利條件 |
Result 回傳
| 參數 | 類別 | 說明 |
|---|---|---|
| is_success | bool | 是否成功 |
| data | Object | 條件單回傳資訊 |
| message | string ? (optional) | 當isSuccess = false 回傳錯誤訊息 |
委託資訊 ConditionOrderResult 欄位
Return type : Object
| 參數 | 類別 | 說明 |
|---|---|---|
| guid | string | 條件單號 |
請求範例
// 設計條件內容
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;
}
}
回傳範例
{
isSuccess = true,
message = ,
data = ConditionOrderResult {
guid = 44150047-8977-40b1-953c-ce2XXXXXX
}
}