Is KiteConnect thread safe?

khushisoni894
Placing order and modifying trigger - are these two thread safe in java kite connect API? I need to be able to place multiple orders concurrently in multiple threads and modify their triggers in the same way. I cannot do so sequentially, as if I do so when market is volatile, orders subsequent to the first will suffer huge delay.
  • khushisoni894
    FYI. In my situation, it is the same kind of order placed multiple times concurrently. Quantity may be different, rest everything, such as symbol, type, buysell, trigger, variety etc will be same.
  • sujith
    Hi @khushisoni894,
    Kite Connect doesn't have any threading concept. It only provides a bunch of APIs, threading can be implemented from the application level. You can place orders from multiple threads but make sure you don't hit API rate limit(5 requests/sec only for placing order and rest are 3 requests/sec).
  • khushisoni894
    I have implemented threading in my own application. Question is...placeOrder method in class KiteConnect and any other subsequent method(s) that the placeOrder method might be using to send order to Zerodha Server....are these methods thread safe? If I invoke multiple placeOrder calls concurrently in multiple threads, is there going to be an issue? I am aware of API rate restriction.
  • sujith
    sujith edited July 2017
    @khushisoni894,
    If you are using a single KiteConnect object in your application, do the initial token fetch on one thread and after that, you can call it from any thread.
    It is safe as each request object is created locally while making the request.
    You can place orders from multiple threads as long as you don't hit API rate limit.
Sign In or Register to comment.