Place multiple orders at a time

njawahire
Hi,
We have a use case where we would like to place multiple orders using the java sdk in android.
can you please guide how to do the same.
We have found the sdk call for doing it just for one order at a time
Regards
  • rakeshr
    @njawahire
    If you just want to place multiple order at a time, you may try using publisher basket, check documentation here.
  • njawahire
    njawahire edited July 2019
    @rakeshr I am using Java aar in my android app for calling the API, how can I do it with it??
  • sujith
    You will need to use a webview and invoke it with the publisher. You can refer to the sample here.
  • njawahire
    @sujith can you provide me with a working example because I am getting error when I try to make the request via webview
  • sujith
    I have pointed you to a working example. You need to enable javascript to make it work.
  • njawahire
    njawahire edited July 2019
    when i tried it with the mentioned example i am getting following error printed in webview:
    {
    "status": "error",
    "message": "Invalid orders payload.",
    "data": null,
    "error_type": "InputException"
    }
    the request i am sending is as followed:
    <!-- <form method= "post" id="basket-form" action="https://kite.trade/connect/basket"> --!>
    <!-- <input type="hidden" name="api_key" value=AppConstant.ZERODHA.API_KEY />--!>
    <!-- <input type="hidden" id="basket" name="data" value="" />--!>
    <!-- </form>--!>
    <!-- <script>--!>
    <!-- document.getElementById("basket").value = new Gson().toJson(paramList);--!>
    <!-- document.getElementById("basket-form").submit();--!>
    <!-- </script> --!>
  • sujith
    You seem to be passing invalid order params. Can you paste all the params here?
  • njawahire
    same as the one in the example
  • njawahire
    njawahire edited July 2019
    <--! <form method="post" id="basket-form" action="https://kite.trade/connect/basket"> !-->
    <--! <input type="hidden" name="api_key" value="MY_API_KEY" /> !-->
    <--! <input type="hidden" id="basket" name="data" value="" /> !-->
    <--! </form> !-->

    <--! <script> !-->
    <--! document.getElementById("basket").value = [{ "variety": "regular", "tradingsymbol": "INFY", "exchange": <--! NSE", "transaction_type": "BUY", "order_type": "MARKET", "quantity": 10, "readonly": false }, { "variety": "regular", "tradingsymbol": "NIFTY15DECFUT", "exchange": "NFO", "transaction_type": "SELL", <--! "order_type": "LIMIT", "price": 7845, "quantity": 1, "readonly": false }, { "variety": "bo", "tradingsymbol": "RELIANCE", "exchange": "NSE", "transaction_type": "BUY", "order_type": "LIMIT", "product": "MIS", "price": 915.15, "quantity": 1, "stoploss": 5, "squareoff": 7, "trailing_stoploss": 1.5, "readonly": true }]; !-->
    <--! document.getElementById("basket-form").submit();
    <--! </script> !-->
  • sujith
    You seem to be using an invalid tradingsymbol, the product type is missing, for F&O instruments the exchange value has to be NFO.
    You can refer to the documentation here.
  • njawahire
    njawahire edited August 2019
    @sujith was able to make it work issue was that i was sending quantity as string when it was expecting it as integer.
    Thanks for your help. There is one doubt that after placing the order successfully I am not getting the details in holdings neither in api nor on the console but orders listing does shows the stocks that I have purchased. Is holding section updated next day or something?
  • rakeshr
    @njawahire
    You will be able to see these placed orders same day on Order book.And next day on holdings.
    You can get complete list of orders using retrive order's API, check the documentation here.
  • njawahire
    @rakeshr thanx for the information. Need to ask one more thing, how can I bypass the login flow on https://kite.trade/connect/basket if the user has already logged in once from the https://kite.trade/connect/login?v=3&api_key=xxx
  • sujith
    If a user has already logged in then you will be redirected directly to redirect URL upon opening the login URL. You just need to check the login to kite web option on the login page.
  • YOGESH
    Dear Sujith sir, I am running a algo in python for options.which was running well.but as a I tried to scale up with 10/15 lots I started loosing on slippage.for which I used for loop to fire orders in lots with 10 sec sleep.but for each lot my orders are getting placed two times.can you please help.
  • sujith
    You can run the Kite Connect with debug logs on and see how many requests you are sending.
Sign In or Register to comment.