Skip to main content

Websocket Notification Examples(Co-lo Version)

info

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

caution

This document is for demostration only. It may not include all possible scenarios.

Single Order Functions

New Single Order

Non-async (unblock=False)

  1. 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,
      }
      }
  2. 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)

  1. 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,
      }
      }
  2. 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

info

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

  1. 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,
      }
      }
  2. 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.

      info

      In 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

  1. 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: 42,
      unit: 1000,
      after_qty: 5000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: None,
      before_price: 42,
      user_def: "Test47",
      last_time: "10:50:55.480",
      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: 43,
      unit: 1000,
      after_qty: 5000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: None,
      before_price: 42,
      user_def: "Test47",
      last_time: "10:50:55.481",
      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: 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:50:55.479",
      details: None,
      error_message: None,
      }
      }
  2. Fail to change the price

    • Notification(1 message):

      The notification with status=19 means that the request failed.

      info

      In this case, the request is rejected directly by the system, so there is NO status=4 notification.

      ==Order Change Notification==
      Code [154]證券改價限價格格和原價格相同==>[00098000025]
      內容 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: 43,
      unit: 1000,
      after_qty: 5000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: None,
      before_price: None,
      user_def: "Test47",
      last_time: "10:51:31.697",
      details: None,
      error_message: "證券改價限價格格和原價格相同==>[00098000025]",
      }
      ========
    • Function Return:

      Request failed, order detail is not provided.

      Result {
      is_success: False,
      message: 證券改價限價格格和原價格相同==>[00098000025],
      data: None
      }

Change Order Quantity

info

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

  1. Quantity change successfully

    • Notification(2 messages):

      Here we have function_type=20 for changing the quantity.

      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: 20,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 5000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 5000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:53:11.924",
      details: None,
      error_message: None,
      }
      ========
      ==Order Change Notification==
      Code None
      內容 OrderResult {
      function_type: 20,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 3000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 5000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:53:11.925",
      details: None,
      error_message: None,
      }
      ========
    • Function Return:

      Result {
      is_success: True,
      message: None,
      data: OrderResult {
      function_type: 20,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 3000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 5000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:53:11.926",
      details: None,
      error_message: None,
      }
      }
  2. Fail to change the quantity

    • Notification(1 message):

      Here we have function_type=20 for changing the quantity.

      The notification with status=29 means that the request failed (request rejected by the system directly, no status=4 notification).

      ==Order Change Notification==
      Code [164]證券減量使用剩餘數量大於有效單位數量==>[00098000025]
      內容 OrderResult {
      function_type: 20,
      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: 29,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 3000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: None,
      before_price: None,
      user_def: "Test47",
      last_time: "10:53:48.940",
      details: None,
      error_message: "證券減量使用剩餘數量大於有效單位數量==>[00098000025]",
      }
      ========
    • Function Return:

      Request failed, order detail is not provided.

      Result {
      is_success: False,
      message: 證券減量使用剩餘數量大於有效單位數量==>[00098000025],
      data: None
      }

Async

  1. Quantity change successfully

    • Notification(2 messages):

      function_type=20 for changing the quantity.

      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: 20,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 3000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 3000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:54:17.774",
      details: None,
      error_message: None,
      }
      ========
      ==Order Change Notification==
      Code None
      內容 OrderResult {
      function_type: 20,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 2000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 3000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:54:17.775",
      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: 20,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 3000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 3000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:54:17.773",
      details: None,
      error_message: None,
      }
      }
  2. Fail to change the quantity

    • Notification(1 message):

      function_type=20 for changing the quantity.

      The notification with status=29 means that the request failed. (Request rejected by the system directly, no status=4 notification)

      ==Order Change Notification==
      Code [164]證券減量使用剩餘數量大於有效單位數量==>[00098000025]
      內容 OrderResult {
      function_type: 20,
      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: 29,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 2000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: None,
      before_price: None,
      user_def: "Test47",
      last_time: "10:54:54.455",
      details: None,
      error_message: "證券減量使用剩餘數量大於有效單位數量==>[00098000025]",
      }
      ========
    • Function Return:

      Request failed, order detail is not provided.

      response: Result {
      is_success: False,
      message: 證券減量使用剩餘數量大於有效單位數量==>[00098000025],
      data: None
      }

Delete Order

caution

If the order is partially filled, the final order status would be 40, otherwise it would be 30

info

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

  1. Cancel successfully

    • Notification(2 messages):

      function_type 30 for canceling an order.

      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=30 (40 if partially filled) to confirm the cancelation succeed.

      ==Order Change Notification==
      Code None
      內容 OrderResult {
      function_type: 30,
      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: None,
      after_price: 43,
      unit: 1000,
      after_qty: 2000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 2000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:55:39.567",
      details: None,
      error_message: None,
      }
      ========
      ==Order Change Notification==
      Code None
      內容 OrderResult {
      function_type: 30,
      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: 30,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 0,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 2000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:55:39.568",
      details: None,
      error_message: None,
      }
      ========
    • Function Return:

      Result {
      is_success: True,
      message: None,
      data: OrderResult {
      function_type: 30,
      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: 30,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 0,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 2000,
      before_price: None,
      user_def: "Test47",
      last_time: "10:55:39.569",
      details: None,
      error_message: None,
      }
      }
  2. Fail to cancel

    • Notification(1 message):

      function_type 30 for canceling an order.

      The notification with status=39 means that the request failed (request rejected by the system directly, no status=4 notification).

      ==Order Change Notification==
      Code [115]證券委託目前狀態部分成交單已不允許取消交易
      內容 OrderResult {
      function_type: 30,
      date: "2024/10/17",
      seq_no: "00090000080",
      branch_no: "20603",
      account: "9809789",
      order_no: "KQ00A",
      asset_type: 1,
      market: None,
      market_type: UnSupported,
      stock_no: "1102",
      buy_sell: None,
      price_type: None,
      price: None,
      quantity: None,
      time_in_force: None,
      order_type: None,
      is_pre_order: false,
      status: 39,
      after_price_type: None,
      after_price: None,
      unit: None,
      after_qty: None,
      filled_qty: None,
      filled_money: None,
      before_qty: None,
      before_price: None,
      user_def: None,
      last_time: "10:59:25.982",
      details: None,
      error_message: "證券委託目前狀態部分成交單已不允許取消交易",
      }
      ========
    • Function Return:

      Request failed, order detail is not provided.

      Result {
      is_success: False,
      message: 證券委託目前狀態部分成交單已不允許取消交易,
      data: None
      }

Async

  1. Cancel successfully

    • Notification(2 messages):

      function_type 30 for canceling an order.

      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=30 (40 if partially filled) to confirm the cancelation succeed.

      ==Order Change Notification==
      Code None
      內容 OrderResult {
      function_type: 30,
      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: 4,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 5000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 5000,
      before_price: None,
      user_def: "Test45",
      last_time: "11:00:06.415",
      details: None,
      error_message: None,
      }
      ========
      ==Order Change Notification==
      Code None
      內容 OrderResult {
      function_type: 30,
      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: 30,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 0,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 5000,
      before_price: None,
      user_def: "Test45",
      last_time: "11:00:06.416",
      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: 30,
      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: 4,
      after_price_type: None,
      after_price: 43,
      unit: 1000,
      after_qty: 5000,
      filled_qty: 0,
      filled_money: 0,
      before_qty: 5000,
      before_price: None,
      user_def: "Test45",
      last_time: "11:00:06.414",
      details: None,
      error_message: None,
      }
      }
  2. Fail to cancel

    • Notification(1 message):

      function_type 30 for canceling an order.

      The notification with status=39 means that the request failed (request rejected by the system directly, no status=4 notification).

      ==Order Change Notification==
      Code [115]證券委託目前狀態取消單已不允許取消交易
      內容 OrderResult {
      function_type: 30,
      date: "2024/10/17",
      seq_no: "00098000023",
      branch_no: "20603",
      account: "9809789",
      order_no: "KQ008",
      asset_type: 1,
      market: None,
      market_type: UnSupported,
      stock_no: "1102",
      buy_sell: None,
      price_type: None,
      price: None,
      quantity: None,
      time_in_force: None,
      order_type: None,
      is_pre_order: false,
      status: 39,
      after_price_type: None,
      after_price: None,
      unit: None,
      after_qty: None,
      filled_qty: None,
      filled_money: None,
      before_qty: None,
      before_price: None,
      user_def: None,
      last_time: "11:00:35.797",
      details: None,
      error_message: "證券委託目前狀態取消單已不允許取消交易",
      }
      ========
    • Function Return:

      Request failed, order detail is not provided.

      Result {
      is_success: False,
      message: 證券委託目前狀態取消單已不允許取消交易,
      data: None
      }

Batch Orders

When a batch orders request is placed, the system will execute the order requests with threading.

In the examples below, we will use the following orders to showcase the notifications.

[Order {
buy_sell: Buy,
symbol: "1102",
price: "42",
quantity: 2000,
market_type: Common,
price_type: Limit,
time_in_force: ROD,
order_type: Stock,
user_def: "batch1",
},
Order {
buy_sell: Buy,
symbol: "1101",
price: "32",
quantity: 1000,
market_type: Common,
price_type: Limit,
time_in_force: ROD,
order_type: Stock,
user_def: "batch2",
},
Order {
buy_sell: Buy,
symbol: "2330",
price: None,
quantity: 1000,
market_type: Common,
price_type: Market,
time_in_force: ROD,
order_type: Stock,
user_def: "batch3",
}]

Batch New Orders

  • Notification(6 messages):

    Notifications include three with status=8 (the system backend is ready to send out the request) and another three status=10 (successful confirmation).

    ==New Order Notification==
    Code None
    內容 OrderResult {
    function_type: 0,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: None,
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: true,
    status: 8,
    after_price_type: Limit,
    after_price: 42,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 42,
    user_def: "batch1",
    last_time: "16:21:19",
    details: None,
    error_message: None,
    }
    ========
    ==New Order Notification==
    Code None
    內容 OrderResult {
    function_type: 0,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: None,
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: true,
    status: 8,
    after_price_type: Limit,
    after_price: 32,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 32,
    user_def: "batch2",
    last_time: "16:21:19",
    details: None,
    error_message: None,
    }
    ========
    ==New Order Notification==
    Code None
    內容 OrderResult {
    function_type: 0,
    date: "2024/10/18",
    seq_no: "00098000012",
    branch_no: "20706",
    account: "9809268",
    order_no: None,
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "2330",
    buy_sell: Buy,
    price_type: Market,
    price: None,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: true,
    status: 8,
    after_price_type: Market,
    after_price: None,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: None,
    user_def: "batch3",
    last_time: "16:21:19",
    details: None,
    error_message: None,
    }
    ========
    ==New Order Notification==
    Code None
    內容 OrderResult {
    function_type: 10,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 10,
    after_price_type: Limit,
    after_price: 32,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 32,
    user_def: "batch2",
    last_time: "16:21:18.962",
    details: None,
    error_message: None,
    }
    ========
    ==New Order Notification==
    Code None
    內容 OrderResult {
    function_type: 10,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 10,
    after_price_type: Limit,
    after_price: 42,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 42,
    user_def: "batch1",
    last_time: "16:21:18.963",
    details: None,
    error_message: None,
    }
    ========
    ==New Order Notification==
    Code None
    內容 OrderResult {
    function_type: 10,
    date: "2024/10/18",
    seq_no: "00098000012",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0007",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "2330",
    buy_sell: Buy,
    price_type: Market,
    price: 0,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 10,
    after_price_type: Market,
    after_price: 0,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 0,
    user_def: "batch3",
    last_time: "16:21:19",
    details: None,
    error_message: None,
    }
    ========
  • Function Return:

    For batch new orders, all returned data has status=4. There would not be order_no in the data (because the orders have not be confirmed by the stock exchange yet), the seq_no can be used for a later reference.

    Result {
    is_success: True,
    message: None,
    data: [OrderResult {
    function_type: 0,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: None,
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: true,
    status: 4,
    after_price_type: Limit,
    after_price: 42,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 42,
    user_def: "batch1",
    last_time: "16:21:18.999",
    details: None,
    error_message: None,
    }, OrderResult {
    function_type: 0,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: None,
    asset_type: None,
    market: None,
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: true,
    status: 4,
    after_price_type: Limit,
    after_price: 32,
    unit: None,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: 32,
    user_def: "batch2",
    last_time: "16:21:18.999",
    details: None,
    error_message: None,
    }, OrderResult {
    function_type: 0,
    date: "2024/10/18",
    seq_no: "00098000012",
    branch_no: "20706",
    account: "9809268",
    order_no: None,
    asset_type: None,
    market: None,
    market_type: Common,
    stock_no: "2330",
    buy_sell: Buy,
    price_type: Market,
    price: None,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: true,
    status: 4,
    after_price_type: Market,
    after_price: None,
    unit: None,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 0,
    before_price: None,
    user_def: "batch3",
    last_time: "16:21:18.999",
    details: None,
    error_message: None,
    }]
    }

Batch Change Order Price

IMPORTANT. The request list cannot contain orders with the market price type, otherwise the whole request will be rejected.

  • Notification(4 messages. We exclude the order with the market price type.):

    Two messages for ACK (status=4), another two messages of confirmation (status=10).

    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 15,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: Limit,
    after_price: 32,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: None,
    before_price: 32,
    user_def: "batch2",
    last_time: "16:23:11.710",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 15,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: Limit,
    after_price: 42,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: None,
    before_price: 42,
    user_def: "batch1",
    last_time: "16:23:11.710",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 15,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 10,
    after_price_type: Limit,
    after_price: 33,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: None,
    before_price: 32,
    user_def: "batch2",
    last_time: "16:23:11.673",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 15,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 10,
    after_price_type: Limit,
    after_price: 43,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: None,
    before_price: 42,
    user_def: "batch1",
    last_time: "16:23:11.683",
    details: None,
    error_message: None,
    }
    ========
  • Function Return:

    All returned data of batch requests has status=4.

    Result {
    is_success: True,
    message: None,
    data: [OrderResult {
    function_type: 15,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: Limit,
    after_price: 33,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: None,
    before_price: 32,
    user_def: "batch2",
    last_time: "16:23:11.708",
    details: None,
    error_message: None,
    }, OrderResult {
    function_type: 15,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: Limit,
    after_price: 43,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: None,
    before_price: 42,
    user_def: "batch1",
    last_time: "16:23:11.708",
    details: None,
    error_message: None,
    }]
    }

Batch Change Order Quantity and Cancelation

Here we reduce some of the orders to quanitty 0, which is the same as deleting the order.

  • Notification(6 messages):

    Three messages of ACK (status=4);Quantity modification function_type=20, success status=10; Order cancelation function_type=30, cancel successfully status=30

    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 30,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: None,
    after_price: 33,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 1000,
    before_price: None,
    user_def: "batch2",
    last_time: "16:24:16.494",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 30,
    date: "2024/10/18",
    seq_no: "00098000012",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0007",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "2330",
    buy_sell: Buy,
    price_type: Market,
    price: 0,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: None,
    after_price: 0,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 1000,
    before_price: None,
    user_def: "batch3",
    last_time: "16:24:16.494",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 20,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: None,
    after_price: 43,
    unit: 1000,
    after_qty: 2000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 2000,
    before_price: None,
    user_def: "batch1",
    last_time: "16:24:16.494",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 20,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 10,
    after_price_type: None,
    after_price: 43,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 2000,
    before_price: None,
    user_def: "batch1",
    last_time: "16:24:16.554",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 30,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 30,
    after_price_type: None,
    after_price: 33,
    unit: 1000,
    after_qty: 0,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 1000,
    before_price: None,
    user_def: "batch2",
    last_time: "16:24:16.558",
    details: None,
    error_message: None,
    }
    ========
    ==Order Change Notification==
    Code None
    內容 OrderResult {
    function_type: 30,
    date: "2024/10/18",
    seq_no: "00098000012",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0007",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "2330",
    buy_sell: Buy,
    price_type: Market,
    price: 0,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 30,
    after_price_type: None,
    after_price: 0,
    unit: 1000,
    after_qty: 0,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 1000,
    before_price: None,
    user_def: "batch3",
    last_time: "16:24:16.558",
    details: None,
    error_message: None,
    }
    ========
  • Function Return:

    Batch requests always have status=4.

    Result {
    is_success: True,
    message: None,
    data: [OrderResult {
    function_type: 30,
    date: "2024/10/18",
    seq_no: "00098000012",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0007",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "2330",
    buy_sell: Buy,
    price_type: Market,
    price: 0,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: None,
    after_price: 0,
    unit: 1000,
    after_qty: 0,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 1000,
    before_price: None,
    user_def: "batch3",
    last_time: "16:24:16.492",
    details: None,
    error_message: None,
    }, OrderResult {
    function_type: 30,
    date: "2024/10/18",
    seq_no: "00098000011",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0006",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1101",
    buy_sell: Buy,
    price_type: Limit,
    price: 32,
    quantity: 1000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: None,
    after_price: 33,
    unit: 1000,
    after_qty: 0,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 1000,
    before_price: None,
    user_def: "batch2",
    last_time: "16:24:16.492",
    details: None,
    error_message: None,
    }, OrderResult {
    function_type: 20,
    date: "2024/10/18",
    seq_no: "00098000010",
    branch_no: "20706",
    account: "9809268",
    order_no: "x0005",
    asset_type: 0,
    market: "TAIEX",
    market_type: Common,
    stock_no: "1102",
    buy_sell: Buy,
    price_type: Limit,
    price: 42,
    quantity: 2000,
    time_in_force: ROD,
    order_type: Stock,
    is_pre_order: false,
    status: 4,
    after_price_type: None,
    after_price: 43,
    unit: 1000,
    after_qty: 1000,
    filled_qty: 0,
    filled_money: 0,
    before_qty: 2000,
    before_price: None,
    user_def: "batch1",
    last_time: "16:24:16.492",
    details: None,
    error_message: None,
    }]
    }

Order Filled Notification

Order filled notification includes order_no and seq_no for reference.

==Order Filled Notification==
Code None
FilledData {
date: "2024/10/17",
branch_no: "20603",
account: "9809789",
order_no: "KQ00B",
stock_no: "1102",
buy_sell: Sell,
order_type: Stock,
seq_no: "00090000081",
filled_no: "00000000002",
filled_avg_price: 45.0,
filled_qty: 2000,
filled_price: 45.0,
filled_time: "10:57:49.331",
user_def: None,
}
========