Skip to content

Data Format ​

WebSocket crypto trade event push uses Protobuf binary encoding. Each push message corresponds to a ReportMsg structure. The client should first distinguish the report type by the report_type field, then parse the relevant sub-report fields such as new_rpt, cancel_rpt, fill_rpt, or expire_rpt.

Note

Trade event pushes are transmitted as Protobuf binary frames, not JSON text. The authentication response (code/msg) is JSON. Clients must allow receiving binary frames (e.g., skip_utf8_validation=True).

INFO

Numeric fields in trade events (such as price and quantity) are transmitted as strings to avoid floating-point precision issues. Time fields use microsecond timestamps (Unix microseconds). Handle types according to field descriptions when parsing, and ignore unknown fields to maintain forward compatibility.

Proto Definition ​

proto
message Order {
    optional string order_id      = 1;  // Order ID
    optional uint32 side          = 2;  // Trade direction: 1=BUY, 2=SELL
    optional string coin          = 3;  // Base asset of the trading pair, e.g. BTC, ETH
    optional string currency      = 4;  // Quote asset of the trading pair, e.g. USD
    optional string price         = 5;  // Order price
    optional string order_qty     = 6;  // Order quantity
    optional uint32 ord_type      = 7;  // Order type: 1=Limit, 2=Market, 3=TAKE_PROFIT_LIMIT, 4=TAKE_PROFIT_MARKET, 5=STOP_LOSS_LIMIT, 6=STOP_LOSS_MARKET
    optional uint32 time_in_force = 8;  // Time in force: 2=TIF_GTC, 3=TIF_IOC
    optional int64 create_time    = 11; // Order creation timestamp, microseconds
    optional bool is_close        = 12; // Whether the order has reached a terminal state
    optional string cum_qty       = 13; // Cumulative filled quantity
    optional string avg_px        = 14; // Average fill price
}

// Order placement report
message OrderNewRpt {
    optional int32 result    = 1; // 0 = success, non-0 = failure
    optional string err_msg  = 2; // Error message
    optional string order_id = 3; // Order ID
}

// Order cancellation report
message OrderCancelRpt {
    optional int32 result    = 1; // 0 = success, non-0 = failure
    optional string err_msg  = 2; // Error message
    optional string order_id = 3; // Order ID
}

// Fill report
message OrderFillRpt {
    optional string order_id    = 1;  // Order ID
    optional string fill_id     = 2;  // Fill ID
    optional string last_px     = 3;  // Fill price for this event
    optional string last_qty    = 4;  // Fill quantity for this event
    optional string leave_qty   = 5;  // Remaining unfilled quantity
    optional uint32 fill_status = 6;  // Fill status: 1=partial fill, 2=full fill
    optional string last_amount = 9;  // Fill amount for this event
    optional string biz_flow_id = 10; // Unique business flow ID
}

// Order expiry report
message OrderExpireRpt {
    optional string order_id = 1; // Order ID
}

// Trade report
message ReportMsg {
    optional string report_id          = 1;  // Unique event ID (UUID), for client-side idempotency
    optional Order order               = 4;  // Order information
    optional uint32 report_type        = 6;  // Report type: 1=placement, 3=cancellation, 4=fill, 5=expiry
    optional OrderNewRpt new_rpt       = 7;  // Order placement result report
    optional OrderCancelRpt cancel_rpt = 9;  // Order cancellation result report
    optional OrderFillRpt fill_rpt     = 10; // Fill report
    optional OrderExpireRpt expire_rpt = 11; // Order expiry report
}

ReportMsg Top-Level Fields ​

FieldTypeDescription
report_idstringUnique event ID (UUID). Can be used for client-side idempotency.
orderOrderOrder information snapshot. See Order Fields.
report_typeuint32Report type. See report type descriptions below.
new_rptOrderNewRptOrder placement result report. Only present when report_type=1. See OrderNewRpt Fields.
cancel_rptOrderCancelRptOrder cancellation result report. Only present when report_type=3. See OrderCancelRpt Fields.
fill_rptOrderFillRptFill report. Only present when report_type=4. See OrderFillRpt Fields.
expire_rptOrderExpireRptOrder expiry report. Only present when report_type=5. See OrderExpireRpt Fields.

Report Types ​

Possible values for the report_type field:

ValueDescription
1Order placement report. Use new_rpt.result to determine success (0) or failure (non-0). On success, order.is_close = false; on failure, order.is_close = true.
3Order cancellation report. Use cancel_rpt.result to determine success (0) or failure (non-0). On successful cancellation, order.is_close = true.
4Fill report. Use fill_rpt.fill_status to distinguish partial fill (1) from full fill (2). On full fill, order.is_close = true.
5Order expiry report. The order was cancelled by the system due to expiry. order.is_close = true.

Order Fields ​

Each push message carries a snapshot of the current order information.

Key Field: is_close

is_close = true means the order has reached a terminal state — no further push events will be received for this order. is_close = false means the order is still active; fill or cancellation events may follow.

FieldTypeDescription
order_idstringOrder ID, unchanged throughout the order lifecycle.
sideuint32Trade direction. 1=BUY, 2=SELL.
coinstringBase asset of the trading pair, e.g. BTC, ETH.
currencystringQuote asset of the trading pair, e.g. USD.
pricestringOrder price. May be empty for market orders.
order_qtystringOrder quantity.
ord_typeuint32Order type. 1=Limit, 2=Market, 3=TAKE_PROFIT_LIMIT, 4=TAKE_PROFIT_MARKET, 5=STOP_LOSS_LIMIT, 6=STOP_LOSS_MARKET.
time_in_forceuint32Time in force. 2=TIF_GTC, 3=TIF_IOC.
create_timeint64Order creation time, Unix microsecond timestamp.
is_closebooltrue indicates the order has reached a terminal state — no further events will be pushed for this order.
cum_qtystringCumulative filled quantity.
avg_pxstringAverage fill price. "0" if no fills yet.

OrderNewRpt Fields ​

Only present when report_type=1.

FieldTypeDescription
resultint320 = placement succeeded; non-0 = placement failed.
err_msgstringFailure reason. Empty when result=0.
order_idstringOrder ID.

OrderCancelRpt Fields ​

Only present when report_type=3.

FieldTypeDescription
resultint320 = cancellation succeeded; non-0 = cancellation failed.
err_msgstringFailure reason. Empty when result=0.
order_idstringOrder ID.

OrderFillRpt Fields ​

Only present when report_type=4.

FieldTypeDescription
order_idstringOrder ID.
fill_idstringFill ID. Can be used for idempotency deduplication.
last_pxstringFill price for this event.
last_qtystringFill quantity for this event.
leave_qtystringRemaining unfilled quantity.
fill_statusuint32Fill status. 1=partial fill, 2=full fill.
last_amountstringFill amount for this event.
biz_flow_idstringUnique business flow ID.

OrderExpireRpt Fields ​

Only present when report_type=5.

FieldTypeDescription
order_idstringOrder ID.

Compatibility Recommendations ​

  • Dispatch by report_type: Different report types carry different sub-report fields. Use switch/match for handling.
  • Ignore unknown fields: The server may add new fields; clients should maintain forward compatibility.
  • Handle unknown report_type values: Log and skip them to avoid errors from newly added report types.
  • Parse numeric fields as strings: Price, quantity, and similar fields are strings — convert to Decimal or float as needed for precision.
  • Microsecond timestamps: create_time is a Unix microsecond timestamp — be careful not to confuse it with millisecond timestamps.