SGX交易状态梳理

1.交易状态

  • Trading Session 适用于 Market, InstrumentType以及InstrumentClass level
  • Instrument Session 适用于标的或合约级别

2.交易状态的确定规则

  1. 确定Trade Session State(简写为TSS) 以及其 优先级别 Priority
  2. 确定Instrument Session State(简写为ISS) 以及其 优先级别 Priority
  3. 比较TSS和ISS的优先级别

具体的逻辑判断见下面的伪代码


3.SGX API 实现

3.1 查询TradingStates

DQ29 Trading State QUERY
该查询请求返回当前使用的市场各级别的交易状态的详细定义
其tradeState结构如下

Struct {
char[20] state_name_s // Trading State Name
UINT16_T state_number_n // Trading State Number
UINT16_T iss_def_warning_interval_n // Warning Interval, Default for ISS
UINT16_T iss_def_num_of_warnings_n // Number of Warnings, Default for ISS
UINT16_T state_type_number_n // State Type Number
UINT8_T continues_matching_c // Matching, Open
UINT8_T trading_end_c // End of Trading
UINT8_T price_quotation_required_c // Price, Quotation Required
UINT8_T market_orders_allowed_c // Market Orders, Allowed
UINT8_T fill_or_kill_allowed_c // Fill or Kill Allowed
UINT8_T fill_and_kill_allowed_c // Fill and Kill Allowed
UINT8_T edited_ob_changes_avail_c // Edited Price Information Available
UINT8_T ob_changes_avail_c // Order Book Changes Available
UINT8_T end_of_clearing_day_c // End of Clearing Day
UINT8_T state_priority_c // State Priority
UINT8_T fill_and_store_c // Fill and Store
UINT8_T all_or_none_c // All Or None
UINT8_T imb_orders_allwd_c // Imbalance orders allowed
UINT8_T mtl_orders_rlot_allwd_c // MTL orders allowed, round lot
UINT8_T allow_hidd_aggr_c // Allow Hidden Orders
UINT8_T best_limit_c // Best Limit
UINT8_T market_bid_c // Market bid
UINT8_T price_stabilization_c // Price Stabilization
UINT8_T short_sell_c // Short sell
UINT8_T allow_cp_mar_c // Allow Centre Point Market Orders
UINT8_T allow_cp_lim_c // Allow Centre Point Limit Orders
UINT8_T allow_undisclosed_qty_c // Allow Undisclosed Quantity Orders
UINT8_T sso_orders_allowed_c // Session State Type Orders, Allowed
UINT8_T stop_orders_allowed_c // Stop Orders, Allowed
UINT8_T good_till_session_c // Good till session
UINT8_T priority_ranking_c // Priority ranking
UINT8_T fix_state_number_c // FIX Trading Session Status
CHAR filler_1_s // Filler
}

其中, state_name 为英文名称表述, state_number为数值型标志符, state_priority 为优先级别

该查询日内应当不会改变, 可系统启动时查询并保存

3.2 TradingState 广播

BI41 Instrument Status Information BROADCAST
该广播包括了TSS和ISS的推送, 根据 state_level字段来区分对应的级别

可以在订阅收到广播后根据state_level来对TSS和ISS进行处理

3.3 合约交易状态查询

UQ15 [Instrument Status QUERY]

该查询可作为BI41的备用方案, 对合约的交易状态进行查询, 来进行交易状态的更新和恢复

需要注意的是依旧需要使用state_level字段来标志查询的级别, 若level为5, 则返回具体合约或标的的ISS, 若level为1, 则返回market级别的TSS.
同时series结构可作为查询筛选项, 其中字段亦可用二进制0来作通配查询


4 总结

  • 首先查询SGX交易状态列表, 存入内存作为字典项.
  • 订阅BI41 的广播, 根据state_level 对TSS和ISS进行更新,
    其中更新时, 应该按照 交易状态的确定规则 来进行
  • 同时, 提供UQ15的状态查询接口, 防止错过广播信号

5 难点

  • DQ29接口中, 查询到的 trading_state 数量较多, 且英文描述不明确, 需要根据实际业务对照trading_state中其他状态字段来进一步确定 交易状态的对应, 再根据实际场景, 对相应的交易状态变化时, 进行业务层面的数据更新或者通知
  • 业务场景上交易日划分的时候, 广播信号的行为逻辑需要另外关注
posted on 2020-08-17 17:46  近天门梦易回  阅读(226)  评论(0)    收藏  举报