Skip to main content

修改委託單數量

modify_quantity

先使用 make_modify_quantity_obj 建立 ModifyQuantityObj物件

參數類別說明
orderResultOrderResult預計修改的委託單
quantityint修改後的委託量 ( 修改後數量包含此委託單已成交部份 )

將回傳的物件放入 ModifyQuantity 的方法中

輸入參數

參數類別說明
accountAccount帳號
ModifyQuantityObjModifyQuantityObj修改的委託單
unblockbool (optional) (default = false)是否採用非阻塞

Result 回傳

參數類別說明
is_successbool是否成功
dataOrderResult回傳修改資訊
messagestring當is_success = False 回傳錯誤訊息

修改資訊 OrderResult 欄位

Return type : Object

參數類別說明
function_typeint功能別 : 0 新單 、 10 新單執行 、 15 改價 、 20 改量 、 30 刪單 、 90 失敗
datestring交易日期
seq_nostring委託單流水序號
branch_nostring分公司代號
accountstring帳號
order_nostring委託書號
asset_typeint資產類別 : 0 證券
marketstring市場類型 : TAIEX 上市股票 、 TAISDAQ 上櫃股票 、 TAIEMG 興櫃股票
market_typeMarketType盤別種類 : COMMON 整股 、 FIXING 定盤 、 INTRADAY_ODD 盤中零股 、 ODD 盤後零股 、 EMG 興櫃 、 EMG_ODD 興櫃零股
stock_nostring股票代號
buy_sellBSAction買賣別 : BUY 買 、 SELL
pric_typePriceType有效委託價格別 : LIMIT 限價 、 LIMIT_UP 漲停 、 LIMIT_DOWN 跌停 、 MARKET 市價 、 REFERENCE 參考價
pricedouble價格
quantityint原始委託股數
time_in_forceTimeInForce委託條件別 : ROD ROD 、 FOK FOK 、 IOC IOC
order_typeOrderType委託單類型 : STOCK 現股 、 MARGIN 融資 、 SHORT 融券 、 DAY_TRADE 現股當沖 、 SBL借券
is_pre_orderbool是否為預約單
statusint委託單狀態 : 0 預約單 、 4 系統將委託送往後台 、 9 連線逾時 、10 委託成功 、 30未成交刪單成功 、 40部分成交,剩餘取消 、 50 完全成交 、 90 失敗
after_price_typePriceType有效委託價格別 : LIMIT 限價 、 LIMIT_UP 漲停 、 LIMIT_DOWN 跌停 、 MARKET 市價 、 REFERENCE 參考價
after_pricedouble有效委託價格
unitint單位數
after_qtyint有效委託股數(包含已成交部分)
filled_qtyint成交股數
filled_moneyint成交價金
before_qtyint改單前有效量
before_pricedouble改單前有效價
user_defstring自訂欄位
last_timestring最後異動時間
detailslist委託歷程 (查詢order_result_detail or order_history才有值)
error_messagestring錯誤訊息

請求範例


// 先取得欲調整的委託單

auto order_results_response = sdk->stock->get_order_results(target_account);
auto target_order = order_results_response.data.value()[0];


auto modify_quantity_obj = sdk->stock->make_modify_quantity_obj(target_order, 1000); // 只能減量
auto modify_quantity_response = sdk->stock->modify_quantity(target_account, modify_quantity_obj, std::nullopt);

// 搭配自定義 .cpp & hpp Output

if (!modify_quantity_response.is_success) {
std::cout << "Modify Qty failed. Message: "
<< (modify_quantity_response.message.has_value() ? modify_quantity_response.message.value() : "No message")
<< std::endl;
return 0;
}

if (modify_quantity_response.data.has_value()) {
const fubon::OrderResult& data = modify_quantity_response.data.value();
std::cout << "Modify Qty Success" << std::endl;
std::cout << data << std::endl;
}
else {
std::cout << "Order succeeded but no data returned." << std::endl;
}

回傳範例

// 搭配自定義 .cpp & hpp  Output
{
isSuccess = true,
message = ,
data = OrderResult{
functionType = 20, // 功能別 (int)
date = 2024/03/08, // 交易日期 (string)
seqNo = 00000308866, // 委託單流水序號 (string)
branchNo = 6460, // 分公司代號 (string)
account = 26, // 帳號 (string)
orderNo = x0011, // 委託書號 (string)
assetType = 0, // 資產類別 (int)
market = TAIEX, // 市場類型 (string)
marketType = COMMON, // 盤別種類 (MarketType)
stockNo = 1101, // 股票代號 (string)
buySell = SELL, // 買賣別 (string)
priceType = LIMIT, // 原始委託價格別 (string)
price = 41.2, // 價格 (double)
quantity = 5000, // 原始委託股數 (int)
timeInForce = ROD, // 委託條件別 (TimeInForce)
orderType = STOCK, // 委託單類型 (OrderType)
isPreOrder = false, // 是否為預約單 (bool)
status = 10, // 委託單狀態 (int)
afterPriceType = LIMIT, // 有效委託價格別 (PriceType)
afterPrice = 41.3, // 有效委託價格 (double)
unit = 1000, // 單位數 (int)
afterQty = 1000, // 有效委託股數 (int)
filledQty = 0, // 成交股數 (int)
filledMoney = 0, // 成交價金 (int)
beforeQty = 3000, // 改單前有效量 (int)
beforePrice = 41.2, // 改單前有效價 (double)
userDef = 12345678, // 自訂欄位 (string)
lastTime = 12:56:28.966, // 最後異動時間 (string)
details = , // 委託歷程 (list)
errorMessage = // 錯誤訊息 (string)
}
}