How to fetch open price for different strike price in nifty in upstox Api in Java

I am building an algo trading android app for my personal use in java Android Studio. I have build websocket connection with upstox api to get live market data. Now please tell me how can can i get live data of different strike price in nifty. I am only able to fetch live data in nifty.

I am getting data by using this method —>

`private JsonObject constructSubscriptionRequest() {
JsonObject dataObject = new JsonObject();
dataObject.addProperty(“mode”, “full”);

    JsonArray instrumentKeys = new Gson().toJsonTree(Arrays.asList("NSE_INDEX|NIFTY 50")).getAsJsonArray();
    dataObject.add("instrumentKeys", instrumentKeys);

    JsonObject mainObject = new JsonObject();
    mainObject.addProperty("guid", "someguid");
    mainObject.addProperty("method", "sub");
    mainObject.add("data", dataObject);

    return mainObject;
}`

Here you can see I have enter NSE_INDEX|NIFTY 50 to fetch live data of nifty. Now help me how can I get data from nifty different strike price of nearest weekly expiry, for example:- i want 21 nov expiry nifty 23500 call data. Help me out in this. Also tell me how can i fetch day open price of 23500

Hi @Sourabh,
You’ll need to retrieve the instrument key from our Instrument JSON file.

For example, here is an object representing the 21 Nov Nifty 23500 CE:

{
  "weekly": true,
  "segment": "NSE_FO",
  "name": "NIFTY",
  "exchange": "NSE",
  "expiry": 1732213799000,
  "instrument_type": "CE",
  "asset_symbol": "NIFTY",
  "underlying_symbol": "NIFTY",
  "instrument_key": "NSE_FO|43309",
  "lot_size": 25,
  "freeze_quantity": 1800.0,
  "exchange_token": "43309",
  "minimum_lot": 25,
  "asset_key": "NSE_INDEX|Nifty 50",
  "underlying_key": "NSE_INDEX|Nifty 50",
  "tick_size": 5.0,
  "asset_type": "INDEX",
  "underlying_type": "INDEX",
  "trading_symbol": "NIFTY 23500 CE 21 NOV 24",
  "strike_price": 23500.0,
  "qty_multiplier": 1.0
}

In this case, the instrument key is NSE_FO|43309. Replace NSE_INDEX|Nifty 50 in your code with this key to fetch the feed for this instrument.

Thank you!

Thank you for your reply @Ketan , I have used the key as you suggested but I also want open price for the strike price. And it is not available in the response I am getting. How can I fetch day open price for 23500 ce. I think upstox has forget to add the open price in the response we get from server. Can you check it for me. Weather they have or not.

@Sourabh, you can retrieve the open price for any instrument using the Market Quote OHLC API. Set the interval to 1d to obtain the 1-day OHLC data.

Thank you!

Thanks brother @Ketan , i cant tell how much i needed that i my algo. Thanks again! Now i can build my algo for placing buy order and sell order.

3 Likes