Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,50 @@ SmartAPI is a set of REST-like APIs that expose many capabilities required to bu

String response = smartConnect.candleData(requestObejct);
}

/** Logout user. */

/** Market Data FULL*/
public void getMarketData(SmartConnect smartConnect) {

JSONObject payload = new JSONObject();
payload.put("mode", "FULL");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is 3 modes. LTP("LTP"),
OHLC("OHLC"),
FULL("FULL");

why did you cover FULL only? What about the rest?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the confusion. I demonstrated the "FULL" mode in the code snippet for simplicity. However, users can easily modify the code to request data in "LTP" or "OHLC" modes by changing the value within the payload JSON object. For "LTP" mode, they should replace the value with "LTP," and for "OHLC" mode, they should use "OHLC" instead.
For EG:
payload.put("mode", "FULL");
payload.put("mode", "LTP");
payload.put("mode", "OHLC");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should mention this in comment section

JSONObject exchangeTokens = new JSONObject();
JSONArray nseTokens = new JSONArray();
nseTokens.put("3045");
exchangeTokens.put("NSE", nseTokens);
payload.put("exchangeTokens", exchangeTokens);
JSONObject response = smartConnect.marketData(payload);

}

/** Market Data OHLC*/
public void getMarketData(SmartConnect smartConnect) {

JSONObject payload = new JSONObject();
payload.put("mode", "OHLC");
JSONObject exchangeTokens = new JSONObject();
JSONArray nseTokens = new JSONArray();
nseTokens.put("3045");
exchangeTokens.put("NSE", nseTokens);
payload.put("exchangeTokens", exchangeTokens);
JSONObject response = smartConnect.marketData(payload);

}

/** Market Data LTP*/
public void getMarketData(SmartConnect smartConnect) {

JSONObject payload = new JSONObject();
payload.put("mode", "LTP");
JSONObject exchangeTokens = new JSONObject();
JSONArray nseTokens = new JSONArray();
nseTokens.put("3045");
exchangeTokens.put("NSE", nseTokens);
payload.put("exchangeTokens", exchangeTokens);
JSONObject response = smartConnect.marketData(payload);

}

/** Logout user. */
public void logout(SmartConnect smartConnect) throws SmartAPIException, IOException {
/** Logout user and kill the session. */
JSONObject jsonObject = smartConnect.logout();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/angelbroking/smartapi/Routes.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Routes() {
put("api.gtt.details", "/rest/secure/angelbroking/gtt/v1/ruleDetails");
put("api.gtt.list", "/rest/secure/angelbroking/gtt/v1/ruleList");
put("api.candle.data", "/rest/secure/angelbroking/historical/v1/getCandleData");

put("api.market.data", "/rest/secure/angelbroking/market/v1/quote");
}
};
}
Expand Down
Loading