Skip to content

WebSocket BasicOrder missing trigger fields present in REST BasicOrderInfo #192

@Niqnil

Description

@Niqnil

The WebSocket BasicOrder struct (used in OrderUpdate) is missing several fields that are present in the REST API's BasicOrderInfo struct. This makes it impossible to identify trigger orders (stop-loss, take-profit) from WebSocket order updates.

Missing Fields

Field REST BasicOrderInfo WebSocket BasicOrder
is_trigger bool ❌ Missing
trigger_px String ❌ Missing
trigger_condition String ❌ Missing
is_position_tpsl bool ❌ Missing
reduce_only bool ❌ Missing
order_type String ❌ Missing
tif String ❌ Missing

Affected Structs

REST (has full info): info/sub_structs.rs

pub struct BasicOrderInfo {
    pub coin: String,
    pub side: String,
    pub limit_px: String,
    pub sz: String,
    pub oid: u64,
    pub timestamp: u64,
    pub trigger_condition: String,
    pub is_trigger: bool,
    pub trigger_px: String,
    pub is_position_tpsl: bool,
    pub reduce_only: bool,
    pub order_type: String,
    pub orig_sz: String,
    pub tif: String,
    pub cloid: Option<String>,
}

WebSocket (incomplete): ws/sub_structs.rs

pub struct BasicOrder {
    pub coin: String,
    pub side: String,
    pub limit_px: String,
    pub sz: String,
    pub oid: u64,
    pub timestamp: u64,
    pub orig_sz: String,
    pub cloid: Option<String>,
}

Use Case

Real-time order management systems subscribe to WebSocket OrderUpdates to track order state without polling. When a trigger order (stop-loss, take-profit) fires or updates, the system needs to identify it as a trigger order to update UI, adjust risk calculations, or correlate with the original placement. Without these fields, the system must either poll REST or maintain duplicate state locally.

Impact

When subscribing to OrderUpdates via WebSocket, consumers cannot:

  1. Distinguish trigger orders from regular limit orders
  2. Know the trigger price or condition
  3. Determine if an order is reduce-only or position TP/SL
  4. Know the time-in-force

This forces consumers to either:

  • Track order state locally (duplicating exchange state)
  • Make REST API calls (query_order_by_oid) for each WebSocket update (defeats the purpose of WebSocket)

Suggested Fix

Add the missing fields to BasicOrder in ws/sub_structs.rs to match BasicOrderInfo:

pub struct BasicOrder {
    pub coin: String,
    pub side: String,
    pub limit_px: String,
    pub sz: String,
    pub oid: u64,
    pub timestamp: u64,
    pub orig_sz: String,
    pub cloid: Option<String>,
    // Add these:
    pub trigger_condition: String,
    pub is_trigger: bool,
    pub trigger_px: String,
    pub is_position_tpsl: bool,
    pub reduce_only: bool,
    pub order_type: String,
    pub tif: String,
}

Environment

  • SDK version: 0.6.0
  • Rust version: 1.95+

Related

This may relate to #189 (Inconsistent API response handling) as it's another case of WebSocket/REST struct divergence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions