Request modes available in v2 Websocket Market Stream feed

Upstox team you have done a wonerful job with the websockets.I was looking at the proto file in the Websocket documentation and it seems the details could have been more comprehensive for laypeople like me.

What are the allowed values for mode and method when making websocket request to get MarketFullFeed, OptionChain and Greeks?

The following is from Node JS sample from the official documentation

const data = {
      guid: "someguid",
      method: "sub",
      data: {
        mode: "full",
        instrumentKeys: ["NSE_INDEX|Nifty Bank"]
      }
    }

@mike @vivekchoksi @ushnota

1 Like

@Pi_S - Thanks for your post. Our concerned team memeber is looking into this. We will update you on this soon.

const data = {
guid: “someguid”,
method: “sub”,
data: {
mode: “full”,
instrumentKeys: [“NSE_INDEX|Nifty Bank”]
}
}

Allowed values for method :

sub , change_mode , unsub

Allowed values for mode :

ltpc, full, option_chain

  • ltpc only gives info of last trade price, last traded time, last traded quantity and previous day close price
  • full gives info of last traded prices, along with D5 depth, 1m candle, 30m candle, 1d candle and few additional info
  • option_chain gives info for a particular instrument key about the ltpc, BID, and ASK (D0) and option greeks

Note

  • If the method is sub, then the default mode is ltpc unless specified by the user
  • While changing the mode instrument key is mandatory
  • unsub will unsubscribe instrument key/s with further updates

The base response from proto is as below.

message FeedResponse{
Type type = 1;
map<string, Feed> feeds = 2;
int64 currentTs = 3;
}

  • TYPE will give info about if the packet is initial_feed (after subscribe) or live_feed (continuous incremental updates)
  • Map of feeds where key is instrumentKey and data is of type Feed. Feed can be oneof LTPC, FullFeed or OptionChain

message Feed {
oneof FeedUnion {
LTPC ltpc = 1;
FullFeed ff = 2;
OptionChain oc = 3;
}
}

We will include the mentioned details in the official v2 documentation as well.

1 Like

Hi @Pradeep_Jaiswar,
I know my question is out of topic,
but can you please record the webinar session on “UpLink New Upstox API Demo” which is scheduled for July 14th @4:30 PM IST
As I will be in office so wouldnt be able to join.
Can you please record the session and upload it to the Upstox’s Youtube channel?
it will be very much helpful.

Thanks.

Hi @CE5464,

Don’t worry! If you have registered for the event, you will get the recordings. You can view the same for the next 7 days :slight_smile:

Yes I have already registered for the event.
Thanks @Ushnota :smiley:

1 Like

@Pradeep_Jaiswar , thanks for the details:

Web sockets are very tricky and has got me bogged down completely. Please help with the following:

  1. Can we get stream for multiple instruments? Tried passing Nifty 50 and Bank Nifty was getting data for only one of the two.

  2. Should the instruments be of same segment? I tried Nifty Bank and one of the options.Got data for Nifty Bank only.

  3. What is the ideal Upstox way to go about Websockets.

Get one wss:// url and keep using the same connection throughout while sending sub, unsub when we want to change instruments.

or generate a wss:// authorized url for each each instrument and keep using until needed.

I would appreciate the inputs.

Thanks in advance.

It is advisable to utilize a single web socket and employ subscription (sub) and unsubscription (unsub) methods for handling multiple instruments.

Our web socket has been specifically designed to receive concurrent streams for various instruments across different segments. It’s important to note that the key of the instrument is an array, such as:

instrumentKeys: ["NSE_INDEX|Nifty Bank", "NSE_INDEX|Nifty 50"]

If you can upload your code to GitHub and provide us with the link, we would be able to assist you more effectively. By sharing your code, we can offer prompt guidance for integrating the web socket. We intend to release the implementation code for the web socket on GitHub to facilitate early adoption and integration.

1 Like

@Ushnota
Hi Ushnota,
I couldnt attend the complete webinar…
can you please guide me how to access the webinar recording?

Hi @CE5464 ,

You can access the recording by clicking on the same link you used for attending the webinar!