Websocket Notification Examples(Co-lo Version)
Co-lo service is a premium service for high-frequency customers. To apply, please contact your broker agent for more information.
The following are examples of websocket notifications for trading requests. The listed cases includes non-async (unblock=False) and async (unblock=True) functions.
(For more information about async and non-async trading functions, please refer to Unblock Order)
This document is for demostration only. It may not include all possible scenarios.
Single Order Functions
New Single Order
Non-async (unblock=False)
-
Order placed successfully
-
Notification(2 messages):
The first notification has status=8, meaning that the sysmtem backend is ready to send to request out. The second notification has status=10, which implies the order is placed successfully.
==New Order Notification==
Code None
內容 OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000023",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: true,
status: 8,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test45",
last_time: "10:44:05.796",
details: None,
error_message: None,
}
==========New Order Notification==
Code None
內容 OrderResult {
function_type: 10,
date: "2024/10/17",
seq_no: "00098000023",
branch_no: "20603",
account: "9809789",
order_no: "KQ008",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 10,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test45",
last_time: "10:44:05.797",
details: None,
error_message: None,
}
======== -
Function Return:
Result {
is_success: True,
message: None,
data: OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000023",
branch_no: "20603",
account: "9809789",
order_no: "KQ008",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 10,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test45",
last_time: "10:44:05.798",
details: None,
error_message: None,
}
}
-
-
Failed
-
Notification(2 messages):
The first notification has status=8, meaning that the sysmtem backend is ready to send to request out. The second notification has status=90, which implies the request failed.
==New Order Notification==
內容 OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000024",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 20,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: true,
status: 8,
after_price_type: Limit,
after_price: 20,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 20,
user_def: "Test97",
last_time: "10:45:04.122",
details: None,
error_message: None,
}
==========New Order Notification==
內容 OrderResult {
function_type: 90,
date: "2024/10/17",
seq_no: "00098000024",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 20,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 90,
after_price_type: Limit,
after_price: 20,
unit: 1000,
after_qty: 0,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 20,
user_def: "Test97",
last_time: "10:45:04.124",
details: None,
error_message: "超過跌停價[5656-後檯]",
}
======== -
Function Return:
Request failed, order detail is not provided.
Result {
is_success: False,
message: 超過跌停價,
data: None
}
-
Async (unblock=True)
-
Order placed successfully
-
Notification(3 messages):
The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=8, meaning that the sysmtem backend is ready to send to request out. In those two nofitication, order_no is not available because the order is not confirmed by the stock exchange yet. However, we have seq_no can be used for later reference.
The last notification has status=10, which means the order is placed successfully.
==New Order Notification==
內容 OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: true,
status: 4,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test47",
last_time: "10:45:44.303",
details: None,
error_message: None,
}
==========New Order Notification==
內容 OrderResult {
function_type: 10,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 8,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test47",
last_time: "10:45:44.305",
details: None,
error_message: None,
}
==========New Order Notification==
內容 OrderResult {
function_type: 10,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: "KQ009",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 10,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test47",
last_time: "10:45:44.305",
details: None,
error_message: None,
}
======== -
Function Return:
Because we use async version of the function, the function returns as soon as ACK (status=4) is available.
Result {
is_success: True,
message: None,
data: OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: true,
status: 4,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 43,
user_def: "Test47",
last_time: "10:45:44.303",
details: None,
error_message: None,
}
}
-
-
Failed
-
Notification(3 messages):
The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=8, meaning that the sysmtem backend is ready to send to request out. In those two nofitication, order_no is not available because the order is not confirmed by the stock exchange yet. However, we have seq_no can be used for later reference.
The last notification has status=90 to implies the order is failed.
==New Order Notification==
內容 OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000026",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 430,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: true,
status: 4,
after_price_type: Limit,
after_price: 430,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 430,
user_def: "Test77",
last_time: "10:46:24.101",
details: None,
error_message: None,
}
==========New Order Notification==
內容 OrderResult {
function_type: 10,
date: "2024/10/17",
seq_no: "00098000026",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 430,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 8,
after_price_type: Limit,
after_price: 430,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 430,
user_def: "Test77",
last_time: "10:46:24.102",
details: None,
error_message: None,
}
==========New Order Notification==
內容 OrderResult {
function_type: 90,
date: "2024/10/17",
seq_no: "00098000026",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 430,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 90,
after_price_type: Limit,
after_price: 430,
unit: 1000,
after_qty: 0,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 430,
user_def: "Test77",
last_time: "10:46:24.103",
details: None,
error_message: "超過漲停價[5655-後檯]",
}
======== -
Function Return:
Because we use async version of the function, the function returns as soon as ACK (status=4) is available.
Result {
is_success: True,
message: None,
data: OrderResult {
function_type: 0,
date: "2024/10/17",
seq_no: "00098000026",
branch_no: "20603",
account: "9809789",
order_no: None,
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 430,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: true,
status: 4,
after_price_type: Limit,
after_price: 430,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: 0,
before_price: 430,
user_def: "Test77",
last_time: "10:46:24.101",
details: None,
error_message: None,
}
}
-
Change Order Price
No matter using async or non-async version of order modification functions, if the system rejects the request directly (for example, when the new price is the same as the current limit order price), there will be no status=4 notification. If the system does send the request to the backend but it is rejected by the backend (for example, when the request succeed or the new price is higher than the upper limit price of the stock), there will be a status=4 notification.
The key difference between async and non-async here is on the function return. Async version returns when ACK (status=4) is available, and non-async version returns when the final confirmation (success/fail) is ready.
Non-async
-
Price change successfully
-
Notification(2 messages):
Here we have function_type=15 for changing the price.
The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed.
==Order Change Notification==
Code None
內容 OrderResult {
function_type: 15,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: "KQ009",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 4,
after_price_type: Limit,
after_price: 43,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: None,
before_price: 43,
user_def: "Test47",
last_time: "10:47:24.816",
details: None,
error_message: None,
}
==========Order Change Notification==
Code None
內容 OrderResult {
function_type: 15,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: "KQ009",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 10,
after_price_type: Limit,
after_price: 42,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: None,
before_price: 43,
user_def: "Test47",
last_time: "10:47:24.817",
details: None,
error_message: None,
}
======== -
Function Return:
Result {
is_success: True,
message: None,
data: OrderResult {
function_type: 15,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: "KQ009",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 10,
after_price_type: Limit,
after_price: 42,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: None,
before_price: 43,
user_def: "Test47",
last_time: "10:47:24.817",
details: None,
error_message: None,
}
}
-
-
Fail to change the price
-
Notification(2 messages):
The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to imply the request failed.
infoIn this case, the request is rejected by the backend, so we have a nofitication with status=4.
==Order Change Notification==
Code None
內容 OrderResult {
function_type: 15,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: "KQ009",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 4,
after_price_type: Limit,
after_price: 42,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: None,
before_price: 42,
user_def: "Test47",
last_time: "10:48:00.682",
details: None,
error_message: None,
}
==========改單主動回報==
Code [DT3_10104]超過漲停價
內容 OrderResult {
function_type: 15,
date: "2024/10/17",
seq_no: "00098000025",
branch_no: "20603",
account: "9809789",
order_no: "KQ009",
asset_type: 0,
market: "TAIEX",
market_type: Common,
stock_no: "1102",
buy_sell: Buy,
price_type: Limit,
price: 43,
quantity: 5000,
time_in_force: ROD,
order_type: Stock,
is_pre_order: false,
status: 19,
after_price_type: Limit,
after_price: 42,
unit: 1000,
after_qty: 5000,
filled_qty: 0,
filled_money: 0,
before_qty: None,
before_price: 42,
user_def: "Test47",
last_time: "10:48:00.683",
details: None,
error_message: "超過漲停價",
}
======== -
Function Return:
Request failed, order detail is not provided.
Result {
is_success: False,
message: 超過漲停價,
data: None
}
-
Async
-
Price change successfully
-
Notification(2 messages):
Here we have function_type=15 for changing the price.
The first message is ACK (acknowledgement, status=4) that implies that the system is executing the request and ready to pass it to the backend. The second message has status=10 to confirm the request succeed.
==Order Change Notification==
Code None
-