Skip to content

Realtime Order Updates (WebSocket)

This section documents Nubra's WebSocket stream for real-time order and trade updates in the REST API. It is language-agnostic and does not require the Python SDK.

WebSocket Endpoint

Use the WebSocket URL that matches your environment:

  • PROD: wss://api.nubra.io/ws
  • UAT: wss://uatapi.nubra.io/ws

REST Base URL (for auth)

Use the matching REST base URL for authentication and session management:

  • PROD: https://api.nubra.io
  • UAT: https://uatapi.nubra.io

Authentication

Order updates are pushed only for authenticated sessions. Use the same session token as the REST API login flow. If you receive the text message Invalid Token over the WebSocket, re-authenticate and reconnect.

Auth/Subscribe Message (Order Updates)

Send this text message once after connecting:

subscribe <session_token> notifications notification

Stream Behavior

  • After the auth/subscribe message is sent, the server pushes order and trade updates for the authenticated user.
  • The stream currently emits two order-related payload types:
  • Order (legacy/ongoing support)
  • Executions (current execution-oriented payload)

Message Envelope

WebSocket binary payloads are protobuf Any messages. The server sends an outer Any whose value contains another Any. The inner Any has a type_url ending with one of:

  • Order
  • Executions

The inner Any.value is the corresponding protobuf payload.

message Any {
  string type_url = 1;
  bytes value = 2;
}

Payload A: Order (Proto)

message Order {
  ExchangeType exch = 1;
  int64 order_id = 2;
  uint32 user_id = 3;
  uint32 zanskar_id = 4;
  int64 basket_id = 5;
  int64 ref_id = 6;
  OrderSide side = 7;
  OrderType order_type = 8;
  OrderStatus order_status = 9;
  uint32 order_qty = 11;
  int64 order_price = 12;
  int64 order_time = 13;
  uint32 filled_qty = 14;
  int64 avg_price = 15;
  int64 ack_time = 16;
  int64 filled_time = 17;
  int64 cancel_time = 18;
  int64 reject_time = 19;
  int64 last_modified = 20;
  int32 leg_size = 21;
  OrderDeliveryType order_delivery_type = 22;
  string update_msg = 23;
  string client_code = 24;
  int64 exchange_order_id = 25;
  string display_name = 26;
  int32 lot_size = 27;
  string stock_name = 28;
  string asset = 29;
  string derivative_type = 30;
  sint32 trigger_price = 31;
  uint32 algo_duration = 32;
  StrategyType strategy_type = 33;
  uint32 max_prate = 34;
  OrderResponseType response_type = 35;
  OrderType order_type_v2 = 36;
  PriceType price_type = 37;
  ValidityType validity_type = 38;
  AlgoParams algo_params = 39;
  string asset_type = 40;
  int64 trade_qty = 41;
  int64 trade_price = 42;
  bool is_sor = 43;
  string tag = 44;
  OrderRequestType request_type = 45;
  int64 order_expiry_date = 46;
  MetaInfo meta_info = 47;
}

Payload B: Executions (Proto)

message Executions {
  int64 id = 1;
  OrderResponseType response_type = 2;
  zanskarsecurities.oms.OrderDeliveryType delivery_type = 3;
  ExecutionType execution_type = 4;
  zanskarsecurities.oms.OrderSide side = 5;
  zanskarsecurities.oms.PriceType price_type = 6;
  int64 qty = 7;
  ExecutionStatus execution_status = 9;
  int64 last_modified_time = 10;
  int64 creation_time = 11;
  string display_name = 12;
  OrderParams order_params = 13;
  BasktParams basket_params = 14;
  int64 ltp = 15;
  string update_msg = 16;
  zanskarsecurities.oms.ExchangeType exch = 17;
  bool is_sor = 18;
  string tag = 19;
  zanskarsecurities.oms.OrderRequestType request_type = 20;
}

Nested Messages for Executions (Proto)

message OrderParams {
  int64 order_price = 1;
  int64 avg_fill_price = 2;
  uint32 filled_qty = 3;
  uint32 zanskar_id = 4;
  int64 ref_id = 5;
  string stock_name = 6;
  string asset_type = 7;
  string derivative_type = 8;
  zanskarsecurities.oms.AlgoParams algo_params = 9;
  int64 exchange_order_id = 10;
  int64 trade_qty = 11;
  int64 trade_price = 12;
  zanskarsecurities.oms.ValidityType validity_type = 13;
  string asset = 14;
  int64 lot_size = 15;
  int64 order_expiry_date = 16;
  int32 expiry = 17;
  OptionType option_type = 18;
  int64 strike_price = 19;
  zanskarsecurities.oms.OrderSide side = 20;
  string display_name = 21;
  int32 qty = 22;
  zanskarsecurities.oms.MetaInfo meta_info = 23;
}

message BasktParams {
  int64 basket_strategy = 1;
  int64 entry_price = 2;
  int64 exit_price = 3;
  int64 stoploss_price = 4;
  int64 momentum_trigger_price = 5;
  int64 start_time = 6;
  int64 end_time = 7;
  repeated OrderParams order_params = 8;
  string basket_type_name = 9;
  zanskarsecurities.oms.AlgoParams algo_params = 10;
  int64 filled_entry_price = 11;
  int64 filled_exit_price = 12;
}

Shared/Related Enums (Proto)

enum OrderResponseType {
  ORDER_RESPONSE_INVALID = 0;
  ORDER_ACCEPTED = 1;
  ORDER_REJECTED = 2;
  ORDER_FILLED = 3;
  ORDER_TRIGGERED = 4;
  ORDER_CANCELLED = 5;
  BASKET_FILLED = 6;
}

enum ExecutionType {
  EXECUTION_TYPE_INVALID = 0;
  EXECUTION_TYPE_FLEXI = 1;
  EXECUTION_TYPE_STOPLOSS = 2;
  EXECUTION_TYPE_VWAP = 3;
  EXECUTION_TYPE_TWAP = 4;
  EXECUTION_TYPE_CLOSE = 5;
  EXECUTION_TYPE_SCALING = 6;
  EXECUTION_TYPE_REGULAR = 7;
  EXECUTION_TYPE_ICEBERG = 8;
  EXECUTION_TYPE_TRAILING_SL = 9;
}

enum ExecutionStatus {
  EXECUTION_STATUS_INVALID = 0;
  EXECUTION_STATUS_PENDING = 1;
  EXECUTION_STATUS_SENT = 2;
  EXECUTION_STATUS_OPEN = 3;
  EXECUTION_STATUS_REJECTED = 4;
  EXECUTION_STATUS_CANCELLED = 5;
  EXECUTION_STATUS_FILLED = 6;
  EXECUTION_STATUS_TRIGGERED = 7;
  EXECUTION_STATUS_CLOSED = 8;
  EXECUTION_STATUS_LIVE = 9;
}

enum OptionType {
  INVALID = 0;
  CALL = 1;
  PUT = 2;
}

OMS Enums (Proto)

enum OrderSide {
  ORDER_SIDE_INVALID = 0;
  ORDER_SIDE_BUY = 1;
  ORDER_SIDE_SELL = 2;
}

enum OrderType {
  ORDER_TYPE_INVALID = 0;
  ORDER_TYPE_LIMIT = 1; // Deprecated
  ORDER_TYPE_MARKET = 2; // Deprecated
  ORDER_TYPE_STOPLOSS = 3;
  ORDER_TYPE_VWAP = 4;
  ORDER_TYPE_TWAP = 5;
  ORDER_TYPE_CLOSE = 6;
  ORDER_TYPE_SCALING = 7;
  ORDER_TYPE_REGULAR = 8;
  ORDER_TYPE_ICEBERG = 9;
}

enum OrderStatus {
  ORDER_STATUS_INVALID = 0;
  ORDER_STATUS_PENDING = 1;
  ORDER_STATUS_SENT = 2;
  ORDER_STATUS_OPEN = 3;
  ORDER_STATUS_REJECTED = 4;
  ORDER_STATUS_CANCELLED = 5;
  ORDER_STATUS_FILLED = 6;
  ORDER_STATUS_TRIGGERED = 7;
}

enum OrderDeliveryType {
  ORDER_DELIVERY_TYPE_INVALID = 0;
  ORDER_DELIVERY_TYPE_CNC = 1;
  ORDER_DELIVERY_TYPE_IDAY = 2;
}

enum StrategyType {
  STRATEGY_TYPE_INVALID = 0;
  STRATEGY_TYPE_LIMIT = 1;
  STRATEGY_TYPE_MARKET = 2;
  STRATEGY_TYPE_IOC = 3;
  STRATEGY_TYPE_ICEBERG = 4;
  STRATEGY_TYPE_STOPLOSS = 5;
  STRATEGY_TYPE_VWAP = 6;
  STRATEGY_TYPE_TWAP = 7;
  STRATEGY_TYPE_CLOSE = 8;
  STRATEGY_TYPE_SCALING = 9;
}

enum PriceType {
  PRICE_TYPE_INVALID = 0;
  PRICE_TYPE_LIMIT = 1;
  PRICE_TYPE_MARKET = 2;
}

enum ValidityType {
  VALIDITY_TYPE_INVALID = 0;
  VALIDITY_TYPE_DAY = 1;
  VALIDITY_TYPE_IOC = 2;
}

enum BenchmarkType {
  BENCHMARK_TYPE_INVALID = 0;
  BENCHMARK_TYPE_VWAP = 1;
  BENCHMARK_TYPE_ARRIVAL = 2;
  BENCHMARK_TYPE_MANUAL = 3;
}

enum OrderRequestType {
  ORDER_REQUEST_INVALID = 0;
  ORDER_REQUEST_NEW = 1;
  ORDER_REQUEST_MOD = 2;
  ORDER_REQUEST_CANCEL = 3;
}

OMS Messages (Proto)

message AlgoParams {
  uint32 min_prate = 1;
  uint32 max_prate = 2;
  uint32 algo_duration = 3;
  BenchmarkType benchmark_type = 4;
  int64 benchmark_price = 5;
  int64 cleanup_price = 6;
  int64 trigger_price = 7;
  uint32 leg_size = 8;
  string algo_id = 9;
  bool count_odt_volume = 10;
  double cleanup_max_prate = 11;
  int64 start_time = 12;
  int64 end_time = 13;
  uint64 trailing_sl_delta = 14;
  float min_prate_float = 15;
  float max_prate_float = 16;
}

message MetaInfo {
  uint64 trailing_sl_limit_price = 1;
  uint64 trailing_sl_trigger_price = 2;
  int64 parent_order_id = 3;
  int64 response_id = 4;
}

Notes

  • For execution updates, decode based on inner.type_url:
  • ...Order -> parse as Order
  • ...Executions -> parse as Executions
  • Trade-level values are carried in:
  • Order.trade_qty / Order.trade_price
  • Executions.order_params.trade_qty / Executions.order_params.trade_price
  • response_type captures server response classification (ORDER_ACCEPTED, ORDER_REJECTED, etc).
  • Field and enum spellings above are protocol identifiers and must be used exactly as defined.

Example JSON (MessageToDict output)

{
  "id": 123456789,
  "response_type": "ORDER_ACCEPTED",
  "delivery_type": "ORDER_DELIVERY_TYPE_IDAY",
  "execution_type": "EXECUTION_TYPE_REGULAR",
  "side": "ORDER_SIDE_BUY",
  "price_type": "PRICE_TYPE_LIMIT",
  "qty": 100,
  "execution_status": "EXECUTION_STATUS_OPEN",
  "exch": "EXCH_NSE",
  "display_name": "RELIANCE",
  "order_params": {
    "order_price": 250000,
    "filled_qty": 0,
    "trade_qty": 0,
    "trade_price": 0,
    "display_name": "RELIANCE"
  },
  "tag": "order_test",
  "request_type": "ORDER_REQUEST_NEW"
}
NEO Assistant