The official Java Kite Connect client is out

Kailash
Dear all,
The official Kite Connect Java library / SDK is out! You can get it here: https://github.com/rainmattertech/javakiteconnect

Javadoc documentation -- https://kite.trade/docs/javakiteconnect/
  • Dharanikotaarunkumar
    Dharanikotaarunkumar edited October 2016
    :)
  • AutoTrade
    Hi Kailash,

    I am new to auto trading and have few queries on auto trading using KiteConnect and Pi Bridge.

    Can i fire orders directly to the market/exchange through KiteConnect?
    using pi-Bridge, order will go to generated alerts window and stay there till we review the order and place it to the market.

  • Dharanikotaarunkumar
    Hi Kailash ,
    I would like to fully automate simple strategy by using spring , hibernate and kite java api .I just want to run at 9:30 AM and leave the system to trade till 3:20 . does I need to take any approval from exchange as it is fully automated trade .
  • AutoTrade
    Hi Kailash,

    how can i get api_key and secret key. Could you please help me
  • Kailash
    @Dharanikotaarunkumar Yes. If you are going to run automated algorithmic trades, you need approvals. Please e-mail [email protected] to find out more.

    @AutoTrade Signup here https://developers.kite.trade
  • AutoTrade
    Hi Kalash,
    thank you so much for the reply.

    I don't whether i could ask you or not, could you please convert my below strategy to AFL code or Java.

    Green = 100-number of periods since 50 day high/100*100;
    Red = 100-number of periods since 50 day low/100*100
  • Kailash
    @AutoTrade I'm afraid that is outside the scope of this thread or the support we can provide.

    You may start a new thread on the forum and see if someone's able to help out.
  • AutoTrade
    Thank you and sorry for it.

    I am new for this forum :)
  • AutoTrade
    Hi kailash,

    Could you help me in creating new app at https://developers.kite.trade/create.

    i am bit confused with "Redirect URL *:" and "Postback URL (optional):"

    what should i give, i dont have any websites.....would appreciate your help. thanks
  • AutoTrade
    Wonderful help thank you so much sujith and kailash. so then, I will use htts://google.com for redirect URL to get the request token.

    Postback URL is not required?
  • Dharanikotaarunkumar
    @Kailash Thanks alot kailash ,Is there any any plan for conducting webinar on Java API .Can i get sample raw data to test code written for a strategy on historic data of any instrument .
  • sameer
    @Kailash @vivek Please correct my understanding ? Do I need approval to place orders programmatically if I am going to trade individually?

    This is what kite.trade says
    "Zerodha has already obtained necessary approvals for Kite Connect APIs for individuals. You need not seek any additional approvals and can get started with the APIs immediately."

    Is that not approval for placing trades programmatically using kite orders API for individuals ?
  • AutoTrade
    Hi Kailash,

    can you get me the Nithin's webinar video which is done recently on KiteConnect
  • Kailash
    @AutoTrade

    @sameer The regulations differentiate between automated algorithmic trades and programmatic trades using APIs. Please e-mail [email protected] for further clarification.
  • sameer
    I have asked question at tradingqna.com publicly for benefit of everyone ... Please reply there
    http://tradingqna.com/52446/laymans-difference-between-algorithmic-programatic-trade
  • narasimha
    Getting an exception

    com.rainmatter.kitehttp.exceptions.KiteTokenException

    At Usermodel after providing request token & API secrete

    Can any one help me
  • Vivek
    @narasimha Please check if you are using right request token and api secret.
  • narasimha
    narasimha edited October 2016
    @Vivek Is request token that gets appended with login URL where manually login to kite.
    I am using 127.0.0.1 for my testing purpose.
  • sujith
    @narasimha Make sure you are using same client id with which you have registered for App.
  • sujith
    @narasimha After successful login, you will be redirected to registered redirect url. In your case, something like this 127.0.0.1&request_token=o1h586aruoxmysqjqigqmriskehjzivqk
  • ashishsharma04
    I am using Java Kite Connect API and getting java.lang.ClassCastException. It is thrown by the API code.

    For generating access token I'm initializing KiteConnect instance with my API key. Later I'm trying to initialize UserModel with request token and the API secret.

    But the code throws ClassCastException which is unexpected and this is issue with API.
    Below is the code snippet :

    System.out.println("Please enter request token :");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String requestToken = br.readLine().trim();

    KiteConnect kiteConnect = new KiteConnect("oc1g68oja0hpnjcp");
    kiteConnect.setUserId("DR2680");

    UserModel userModel = null;

    try {
    userModel = kiteConnect.requestAccessToken(requestToken, "2ixzxrbons888r46x2ljjuzf1yjf8g47");
    } catch (JSONException | KiteException e) {
    e.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }



    And below is the stack trace :

    Please enter request token :
    0on4r321vsyl99i7pv946t4wzkfvleja
    java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to com.google.gson.JsonArray
    at com.google.gson.JsonObjectDeserializationVisitor.visitArrayField(JsonObjectDeserializationVisitor.java:79)
    at com.google.gson.ObjectNavigator.navigateClassFields(ObjectNavigator.java:154)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:123)
    at com.google.gson.JsonDeserializationContextDefault.fromJsonObject(JsonDeserializationContextDefault.java:73)
    at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:51)
    at com.google.gson.Gson.fromJson(Gson.java:495)
    at com.google.gson.Gson.fromJson(Gson.java:444)
    at com.google.gson.Gson.fromJson(Gson.java:396)
    at com.google.gson.Gson.fromJson(Gson.java:372)
    at com.rainmatter.models.UserModel.parseResponse(UserModel.java:42)
    at com.rainmatter.kiteconnect.KiteConnect.requestAccessToken(KiteConnect.java:172)
    at p1.KiteLoginDemo.main(KiteLoginDemo.java:28)

  • sujith
    sujith edited November 2016
    @ashishsharma04 How are you getting request token?
  • sujith
    @ashishsharma04

    Are you logging in manually?
    You will get request token only after successful login and request token is valid for 3 minutes.
  • ashishsharma04
    @sujith

    I am logging in manually.
    I get the request token in browser address bar as follows:
    https://kite.zerodha.com/:// http://127.0.0.1?status=success&request_token=i2rec0jf1zy45tbk6d7p0vqhztjtmikg

    And three minutes are sufficient to copy request_token and initialize userModel using request token and api secret key.


  • sujith
    @ashishsharma04

    Can you write a private message with your client id and email id with which you have signed up for KiteConnect?
  • sujith
    @ashishsharma04

    DR2680, This client Id doesn't have any app.
  • ashishsharma04
    Yes I do have app.
    Below is the information of the same :


    Kite connect + Publisher — expires on 2016-11-25
    MyApp1
    Active
    API Key
    oc1g68oja0hpnjcp
    API Secret
    2ixzxrbons888r46x2ljjuzf1yjf8g47


    Please let me know email id. I can also post screen shot of the same.
  • sujith
    sujith edited November 2016
    @ashishsharma04

    Make sure you are using latest Java like oracle java 8 or openjdk 8.
    I tried with your api key and secret. It is working fine.
  • sujith
    @ashishsharma04

    Please don't give away, api secret. Others can use it. We have regenerated your api secret. Use new one.
  • sujith
    @ashishsharma04

    You must use same client Id with which you have signed up. Your app doesn't have multi user access.
    Just copy paste code from Test of KiteConnect Java. It is working fine.
  • chintanvhparmar
    Hi Kailash/Kite API Team,
    Thanks for putting together the Java KiteConnect client. I have recently started to use it and found it to be very helpful. Today while trying to test some use cases i came across some scenarios of data inconsistencies in OHLC returned from getQuote method. I have used the getQuote method code and modified ti to return the OHLC data type instead of void. It seems to return appropriate open/high/low/close values for some stocks(eg. VGUARD) but it seems it is not returning correct values for some other stocks(eg.AHLWEST(NSE)). For AHLWEST i get correct Close value 210 currently but the Open value is 0. I would expect the day open value to be returned and not 0. This is affecting the logic i am trying to build using day OHLC values.
    Please check this scenario and share some details on the root cause of this issue and how/when can this be addressed.

    Thanks,
    Chintan Parmar
  • sujith
    sujith edited November 2016
  • chintanvhparmar
    chintanvhparmar edited November 2016
    Hi Sujith,
    Thanks for the quick update. I had checked the zerodha kite site which shows OHLC all same as 210. Looking at the NSE site link you have shared it seems this stock has not traded today which explains why open is 0. Now i understand that anything which has open returned as 0 is not traded and will modify my logic accordingly. Thanks for looking into this.

    Another scenario found for PRAGBOS(BSE),the quote method returned o->4.86, h->5.26, l->4.86, c->5.1 which matches BSE site information but checking the Zerodha Kite chart shows high of 5 instead of 5.26 listed on BSE and returned by API. It seems Kite chart is not accurate for some of these low traded scrips. Is my understanding correct?
This discussion has been closed.