Skip to main content

Portfolio Stream Feed

The Order update stream feed communicates all order updates when connected over the websocket. No request object is required for this. The communication will start immediately after the connection is successfully established.

Integration involves connecting to the provided endpoint using the wss: protocol through a WebSocket client, which is configured to automatically redirect to the authorized WebSocket endpoint upon authentication. Therefore, the client's configuration must be adjusted to support this automatic redirection. For example, in a Node.js client, you should enable the followRedirects setting to facilitate seamless handling of redirection.

info

The order update WebSocket ensures that you receive updates on your order regardless of the platform used to place it. Whether you place an order through the Upstox mobile app or via the web application, you will still receive the order updates through the API WebSocket, and the same applies in reverse.

Header Parameters

NameRequiredTypeDescription
AuthorizationtruestringRequires the format Bearer access_token where access_token is obtained from the Token API.
AccepttruestringDefines the content format the client expects, which should be set to */*.

Query Parameters

NameRequiredTypeDescription
update_typesfalsestringIdentifiers, separated by commas, specify the types of updates to receive. By default, updates on orders are transmitted via the socket. To subscribe to updates on orders, holdings, and positions, use this parameter by entering the desired values, separated by commas.
Possible values: order, position, holding

Sample URL with update_types: wss://api.upstox.com/v2/feed/portfolio-stream-feed?update_types=order%2Cposition%2Cholding
Responses

This API does not provide a typical JSON response. Instead, upon successful authentication, it automatically redirects the client to the appropriate websocket endpoint where order updates can be received in real-time. Users are expected to handle data streams as per the websocket protocol once the redirection is complete.

Following is a sample of an order update message received on the socket.

Message Structure


{
"update_type": "order",
"user_id": "******",
"userId": "******",
"exchange": "NSE",
"instrument_token": "NSE_EQ|INE848E01016",
"instrument_key": "NSE_EQ|INE848E01016",
"trading_symbol": "NHPC-EQ",
"tradingsymbol": "NHPC-EQ",
"product": "D",
"order_type": "MARKET",
"average_price": 0,
"price": 0,
"trigger_price": 0,
"quantity": 1,
"disclosed_quantity": 0,
"pending_quantity": 1,
"transaction_type": "BUY",
"order_ref_id": "57744821658411",
"exchange_order_id": "",
"parent_order_id": null,
"validity": "DAY",
"status": "put order req received",
"is_amo": false,
"variety": "SIMPLE",
"tag": null,
"exchange_timestamp": null,
"status_message": "",
"order_id": "240221025997024",
"order_request_id": "1",
"order_timestamp": "2024-02-21 14:40:02",
"filled_quantity": 0,
"guid": null,
"placed_by": "******",
"status_message_raw": null
}
NameTypeDescription
update_typestringSignifies the type of update received.
Possible values: order, position, holding
exchangestringExchange to which the order is associated. Valid exchanges can be found in the Exchange Appendix
productstringSignifies if the order was either Intraday, Delivery or CO.
Possible values: I, D, CO, MTF.
pricefloatPrice at which the order was placed
quantityint32Quantity with which the order was placed
statusstringIndicates the current status of the order. Valid order statuses can be found in the Order Status Appendix
tagstringTag to uniquely identify an order
instrument_tokenstringKey of the instrument. For the regex pattern applicable to this field, see the Field Pattern Appendix.
instrument_keystringKey of the instrument. For the regex pattern applicable to this field, see the Field Pattern Appendix.
placed_bystringUniquely identifies the user (commonly referred as UCC)
trading_symbolstringShows the trading symbol of the instrument
order_typestringType of order. It can be one of the following MARKET refers to market order LIMIT refers to Limit Order SL refers to Stop Loss Limit SL-M refers to Stop Loss Market.
Possible values: MARKET, LIMIT, SL, SL-M.
validitystringIt can be one of the following - DAY(default), IOC.
Possible values: DAY, IOC.
trigger_pricefloatIf the order was a stop loss order then the trigger price set is mentioned here
disclosed_quantityint32The quantity that should be disclosed in the market depth
transaction_typestringIndicates whether its a buy or sell order.
Possible values: BUY, SELL.
average_pricefloatAverage price at which the qty got traded
filled_quantityint32The total quantity traded from this particular order
pending_quantityint32Pending quantity to be filled
status_messagestringIndicates the reason when any order is rejected, not modified or cancelled
status_message_rawstringDescription of the order's status as received from RMS
exchange_order_idstringUnique order ID assigned by the exchange for the order placed
parent_order_idstringIn case the order is part of the second of a CO, the parent order ID is indicated here
order_idstringUnique order ID assigned internally for the order placed
varietystringOrder complexity
order_timestampstringUser readable timestamp at which the order was placed
exchange_timestampstringUser readable time at which the order was placed or updated
is_amobooleanSignifies if the order is an After Market Order
order_request_idstringApart from 1st order it shows the count of how many requests were sent
order_ref_idstringUniquely identifies an order for internal usage.

Heartbeat

If there is no data to stream over an open WebSocket connection, the API automatically sends a standard ping frame periodically to maintain the connection's aliveness. Most standard WebSocket client libraries across various programming languages handle this automatically by responding with a pong frame, requiring no manual intervention.

Notice of Deprecation

The lowercase field (tradingsymbol) is deprecated and will be removed in future versions. Use the snake_case versions for consistency.

Loading...