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:
- Distinguish trigger orders from regular limit orders
- Know the trigger price or condition
- Determine if an order is reduce-only or position TP/SL
- 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.
The WebSocket
BasicOrderstruct (used inOrderUpdate) is missing several fields that are present in the REST API'sBasicOrderInfostruct. This makes it impossible to identify trigger orders (stop-loss, take-profit) from WebSocket order updates.Missing Fields
BasicOrderInfoBasicOrderis_triggerbooltrigger_pxStringtrigger_conditionStringis_position_tpslboolreduce_onlyboolorder_typeStringtifStringAffected Structs
REST (has full info):
info/sub_structs.rsWebSocket (incomplete):
ws/sub_structs.rsUse Case
Real-time order management systems subscribe to WebSocket
OrderUpdatesto 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
OrderUpdatesvia WebSocket, consumers cannot:This forces consumers to either:
query_order_by_oid) for each WebSocket update (defeats the purpose of WebSocket)Suggested Fix
Add the missing fields to
BasicOrderinws/sub_structs.rsto matchBasicOrderInfo:Environment
Related
This may relate to #189 (Inconsistent API response handling) as it's another case of WebSocket/REST struct divergence.