Live Order Update
The orderupdate class is designed to facilitate asynchronous communication with the DhanHQ API via WebSocket. It enables users to subscribe to market data for a list of instruments and receive real-time updates.
:copyright: (c) 2025 by Dhan. :license: see LICENSE for details.
dhanhq.orderupdate
The orderupdate class is designed to facilitate asynchronous communication with the DhanHQ API via WebSocket. It enables users to subscribe to market data for a list of instruments and receive real-time updates.
:copyright: (c) 2025 by Dhan. :license: see LICENSE for details.
Classes
OrderUpdate
OrderUpdate(dhan_context)
A class to manage WebSocket connections for order updates.
Attributes:
Name | Type | Description |
---|---|---|
client_id |
str
|
The client ID for authentication. |
access_token |
str
|
The access token for authentication. |
order_feed_wss |
str
|
The WebSocket URL for order updates. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client_id |
str
|
The client ID for authentication. |
required |
access_token |
str
|
The access token for authentication. |
required |
Functions
connect_order_update
async
connect_order_update()
Connects to the WebSocket and listens for order updates.
This method authenticates the client and processes incoming messages.
connect_to_dhan_websocket_sync
connect_to_dhan_websocket_sync()
Synchronously connects to the WebSocket.
This method runs the asynchronous connect_order_update method in a new event loop.
handle_order_update
handle_order_update(order_update)
Handles incoming order update messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_update |
dict
|
The order update message received from the WebSocket. |
required |