修改委託價格
modify_price
先使用 make_modify_price_obj 建立 ModifyPriceObj 物件
| 參數 | 類別 | 說明 |
|---|---|---|
| order | OrderResult | 預計修改的委託單 |
| price | string | 修改後的價格 |
| price_type | PriceType | 修改後的價格旗標 |
caution
當 price 欄位有填入值時,price_type 需為 std::nullopt ; 當 price_type 欄位有填入值時,price 需為 std::nullopt
將回傳的物件放入 modify_price 的方法中
輸入參數
| 參數 | 類別 | 說明 |
|---|---|---|
| account | Account | 帳號 |
| modify_obj | ModifyPriceObj | 修改價格的物件 |
| unblock | bool (optional) (default = false) | 是否採用非阻塞 |
Result 回傳
| 參數 | 類別 | 說明 |
|---|---|---|
| is_success | bool | 是否成功 |
| data | OrderResult | 回傳修改資訊 |
| message | string | 當 is_success = False 回傳錯誤訊息 |
修改資訊 OrderResult 欄位
Return type : Object
| 參數 | 類別 | 說明 |
|---|---|---|
| function_type | int | 功能別 : 0 新單 、 10 新單執行 、 15 改價 、 20 改量 、 30 刪單 、 90 失敗 |
| date | string | 交易日期 |
| seq_no | string | 委託單流水序號 |
| branch_no | string | 分公司代號 |
| account | string | 帳號 |
| order_no | string | 委託書號 |
| asset_type | int | 資產類別 : 0 證券 |
| market | string | 市場類型 : TAIEX 上市股票 、 TAISDAQ 上櫃股票 、 TAIEMG 興櫃股票 |
| market_type | MarketType | 盤別種類 : COMMON 整股 、 FIXING 定盤 、 INTRADAY_ODD 盤中零股 、 ODD 盤後零股 、 EMG 興櫃 、 EMG_ODD 興櫃零股 |
| stock_no | string | 股票代號 |
| buy_sell | BSAction | 買賣別 : BUY 買 、 SELL 賣 |
| pric_type | PriceType | 有效委託價格別 : LIMIT 限價 、 LIMIT_UP 漲停 、 LIMIT_DOWN 跌停 、 MARKET 市價 、 REFERENCE 參考價 |
| price | double | 價格 |
| quantity | int | 原始委託股數 |
| time_in_force | TimeInForce | 委託條件別 : ROD ROD 、 FOK FOK 、 IOC IOC |
| order_type | OrderType | 委託單類型 : STOCK 現股 、 MARGIN 融資 、 SHORT 融券 、 DAY_TRADE 現股當沖 、 SBL 借券 |
| is_pre_order | bool | 是否為預約單 |
| status | int | 委託單狀態 : 0 預約單 、 4 系統將委託送往後台 、 9 連線逾時 、10 委託成功 、 30 未成交刪單成功 、 40 部分成交,剩餘取消 、 50 完全成交 、 90 失敗 |
| after_price_type | PriceType | 有效委託價格別 : LIMIT 限價 、 LIMIT_UP 漲停 、 LIMIT_DOWN 跌停 、 MARKET 市價 、 REFERENCE 參考價 |
| after_price | double | 有效委託價格 |
| unit | int | 單位數 |
| after_qty | int | 有效委託股數(包含已成交部分) |
| filled_qty | int | 成交股數 |
| filled_money | int | 成交價金 |
| before_qty | int | 改單前有效量 |
| before_price | double | 改單前有效價 |
| user_def | string | 自訂欄位 |
| last_time | string | 最後異動時間 |
| details | list | 委託歷程 (查詢 order_result_detail or order_history 才有值) |
| error_message | string | 錯誤訊息 |
請求範例
// 先取得欲調整的委託單
auto order_results_response = sdk->stock->get_order_results(account);
auto target_order = order_results_response.data.value()[0];
auto modify_price_obj = sdk->stock->make_modify_price_obj(target_order, "41.1", std::nullopt);
auto modify_price_response = sdk->stock->modify_price(account, modify_price_obj, std::nullopt);
// 搭配自定義 .cpp & hpp Output
if (!modify_price_response.is_success) {
std::cout << "Modify Price failed. Message: "
<< (modify_price_response.message.has_value() ? modify_price_response.message.value() : "No message")
<< std::endl;
return 0;
}
if (modify_price_response.data.has_value()) {
const fubon::OrderResult& data = modify_price_response.data.value();
std::cout << "Modify Price Success" << std::endl;
std::cout << data << std::endl;
}
else {
std::cout << "Order succeeded but no data returned." << std::endl;
}
回傳範例
// 搭配自定義 .cpp & hpp Output
{
is_success = True,
message = ,
data = OrderResult {
function_type = 15, // 功能別 (int)
date = 2023/11/22, // 交易日期 (string)
seq_no = 00000308866, // 委託單流水序號 (string)
branch_no = 6460, // 分公司代號 (string)
account = 26, // 帳號 (string)
order_no = x0011, // 委託書號 (string)
asset_type = 0, // 資產類別 (int)
market = TAIEX, // 市場類型 (string)
market_type = COMMON, // 盤別種類 (MarketType)
stock_no = 1101, // 股票代號 (string)
buy_sell = SELL, // 買賣別 (BsAction)
price_type = LIMIT, // 原始委託價格別 (PriceType)
price = 41.2, // 價格 (double)
quantity = 5000, // 原始委託股數 (int)
time_in_force = ROD, // 委託條件別 (TimeInForce)
order_type = STOCK, // 委託單類型 (OrderType)
is_pre_order = false, // 是否為預約單 (bool)
status = 10, // 委託單狀態 (int)
after_price_type = LIMIT, // 有效委託價格別 (PriceType)
after_price = 41.1, // 有效委託價格 (double)
unit = 1000, // 單位數 (int)
after_qty = 2000, // 有效委託股數 (int)
filled_qty = 0, // 成交股數 (int)
filled_money = 0, // 成交價金 (int)
before_qty = , // 改單前有效量 (int)
before_price = 41.3, // 改單前有效價 (double)
user_def = 12345678, // 自訂欄位 (string)
last_time = 10:56:57.713, // 最後異動時間 (string)
details = , // 委託歷程 (list)
error_message = // 錯誤訊息 (string)
}
}