Skip to content

Commit 652b48a

Browse files
committed
changes to allow BO exit and get quotes for indices.
1 parent 863ecd5 commit 652b48a

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

dist/kiteconnectjava.jar

184 Bytes
Binary file not shown.

src/main/java/com/rainmatter/kiteconnect/KiteConnect.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,23 @@ public Order cancelOrder(String orderId, String variety) throws KiteException, J
253253
return order;
254254
}
255255

256+
/**
257+
* Cancels special orders like BO, CO
258+
* @param params is map that contains parent_order_id
259+
* @param orderId order id of the order to be cancelled.
260+
* @param variety [variety="regular"]. Order variety can be bo, co, amo, regular.
261+
* @return Order object contains only orderId
262+
* */
263+
public Order cancelOrder(Map<String, Object> params, String orderId, String variety) throws KiteException {
264+
String url = routes.get("orders.cancel").replace(":variety", variety).replace(":order_id", orderId);
265+
params = authorize(params);
266+
267+
JSONObject jsonObject = new KiteRequest().deleteRequest(url, params);
268+
Order order = new Order();
269+
order.parseOrderPlacedResponse(jsonObject);
270+
return order;
271+
}
272+
256273
/**Gets collection of orders from the orderbook..
257274
* @return Order object contains orders which is list of orders.
258275
* */
@@ -399,6 +416,19 @@ public Quote getQuote(String exchange, String tradingSymbol) throws KiteExceptio
399416
return new Quote().parseResponse(kiteRequest.getRequest(routes.get("market.quote").replace(":exchange", exchange).replace(":tradingsymbol", tradingSymbol), authorize(params)));
400417
}
401418

419+
/**
420+
* Retrieves quote for an index
421+
*
422+
* @param exchange Exchange in which instrument is listed. exchange can be NSE, BSE.
423+
* @param tradingSymbol Tradingsymbol of the instrument (ex. NIFTY 50).
424+
* @return Quote object.
425+
*/
426+
public Quote getQuoteIndices(String exchange, String tradingSymbol) throws KiteException, JSONException {
427+
Map<String, Object> params = new HashMap<String, Object>();
428+
KiteRequest kiteRequest = new KiteRequest();
429+
return new Quote().parseIndicesResponse(kiteRequest.getRequest(routes.get("market.quote").replace(":exchange", exchange).replace(":tradingsymbol", tradingSymbol), authorize(params)));
430+
}
431+
402432
/**
403433
* Retrieves buy or sell trigger range for Cover Orders.
404434
* @param exchange

src/main/java/com/rainmatter/models/Quote.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,11 @@ public Quote parseOtherData(JSONObject data, Quote quote) throws JSONException{
7373

7474
return quote;
7575
}
76+
77+
public Quote parseIndicesResponse(JSONObject response) throws JSONException{
78+
GsonBuilder gsonBuilder = new GsonBuilder();
79+
Gson gson = gsonBuilder.create();
80+
Quote quote = gson.fromJson(String.valueOf(response.get("data")), Quote.class);
81+
return quote;
82+
}
7683
}

0 commit comments

Comments
 (0)