Error while retrieving open positions

amols
I am trying to retrieve open positions and seeing the following exception...Can somebody help here? This was working yesterday...
Code: (Kite 3.0 Java API client )
kiteConnect.getPositions();

Error:

com.zerodhatech.kiteconnect.kitehttp.exceptions.GeneralException
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(KiteResponseHandler.java:52) ~[classes/:?]
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:20) ~[classes/:?]
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(KiteRequestHandler.java:53) ~[classes/:?]
at com.zerodhatech.kiteconnect.KiteConnect.getPositions(KiteConnect.java:436) ~[classes/:?]
at com.ideas.trading.api.OrdersImpl.getPositions(OrdersImpl.java:40) ~[classes/:?]
at com.ideas.trading.business.commands.ListPositionsCommand.execute(ListPositionsCommand.java:28) [classes/:?]
at com.ideas.trading.business.CommandLineMenu.showPositions(CommandLineMenu.java:139) [classes/:?]
at com.ideas.trading.business.CommandLineMenu.processInput(CommandLineMenu.java:109) [classes/:?]
at com.ideas.trading.business.CommandLineMenu.showMenu(CommandLineMenu.java:87) [classes/:?]
at com.ideas.trading.business.CommandLineMenu.showMenu(CommandLineMenu.java:91) [classes/:?]
at com.ideas.trading.business.CommandLineMenu.showMenu(CommandLineMenu.java:91) [classes/:?]
at com.ideas.trading.business.CommandLineMenu.showMenu(CommandLineMenu.java:91) [classes/:?]
at com.ideas.trading.business.SmartTrader.showCommandLineMenu(SmartTrader.java:57) [classes/:?]
at com.ideas.trading.business.SmartTrader.main(SmartTrader.java:53) [classes/:?]
  • sujith
    sujith edited April 2018
    Can you enable debug logs and paste the complete debug log here?
  • amols
    Hi Sujith
    Here are http log lines.....

    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: <-- 404 Not Found https://api.kite.trade/portfolio/ordermgmt (95ms)
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: Server: nginx
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: Date: Thu, 26 Apr 2018 10:26:20 GMT
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: Content-Type: application/json
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: Content-Length: 90
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: Connection: keep-alive
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO:
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: {"status":"error","message":"Route not found","data":null,"error_type":"GeneralException"}
    Apr 26, 2018 3:56:20 PM okhttp3.internal.platform.Platform log
    INFO: <-- END HTTP (90-byte body)
  • sujith
    The above URL doesn't exist. Can you paste the code here?
  • amols
    Code is from /kite/javakiteconnect/sample/src/Examples.java (branch kite3)

    public Map<String, List<Position>> getPositions() throws KiteException, JSONException, IOException {
    Map<String, List<Position>> positionsMap = new HashMap<>();
    JSONObject response = new KiteRequestHandler(proxy).getRequest(routes.get("portfolio.ordermgmt"), apiKey, accessToken);
    JSONObject allPositions = response.getJSONObject("data");
    positionsMap.put("net", Arrays.asList(gson.fromJson(String.valueOf(allPositions.get("net")), Position[].class)));
    positionsMap.put("day", Arrays.asList(gson.fromJson(String.valueOf(allPositions.get("day")), Position[].class)));
    return positionsMap;
    }
  • amols
    Sorry actual file is kite/javakiteconnect/kiteconnect/src/com/zerodhatech/kiteconnect/KiteConnect.java
  • sujith
    This is not our code, you are trying to access a URL which doesn't exist.
    positions endpoint is https://api.kite.trade/portfolio/positions
  • amols
    You are right, looks like somehow, my dev env pointed to the older version..Thanks for the clarification. It is resolved now.
  • sujith
    yes, it is official Kite Connect client.
Sign In or Register to comment.