KITE API V3 Buy Sell Order placing

sachinstlko09
Is there any kind of limit by placing an order by $kite->Placeorder ? Please mention if exist.

In my case after placing one order another order can not be placed in the same instance.
  • sujith
    Can you paste the error you are getting with complete stacktrace?
  • sachinstlko09
    Not getting the error or unable to capture; but after placing one order, immediately placing another order, second order can not be placed.
  • rakeshr
    @sachinstlko09
    You might be exceeding rate limit, check rate limit here.
  • sachinstlko09
    @sujith Now find one new case on order placing by using $kite->placeOrder function; nothing is return. Order is placed correctly and reflected at the zerodha order listing as a complete; but order id is not returned and even after that none script is working.

    Please response ASAP.
  • sujith
    Can you paste the code here?
  • sachinstlko09
    sachinstlko09 edited July 2019
    Using Kite Connect PHP Version 3.0 kiteconnect.php

    For some case two order can be placed simultaneously.
    1)   $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "SBIN",
    "exchange" => "NSE",
    "quantity" => "1",
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "MIS"
    ])["order_id"];

    2) $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "SBIN",
    "exchange" => "NSE",
    "quantity" => "1",
    "transaction_type" => "SELL",
    "order_type" => "MARKET",
    "product" => "MIS"
    ])["order_id"];
    After placing first order, order is placed correctly at zerodha but no order id is returned and also the second order is not placed i.e. not replicated at the zerodha.
  • sujith
    This seems fine. I don't think this is the issue here. It must be something else. Can you paste the complete code here?
  • sachinstlko09
    include "kiteconnect.php";
    $kite = new KiteConnect($api_key);
    $kite->setAccessToken($access_token);
    $historical_data = $kite->getHistoricalData($instrument_token, $interval, $from, $to);
    $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "SBIN",
    "exchange" => "NSE",
    "quantity" => "1",
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "MIS"
    ])["order_id"];

    $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "SBIN",
    "exchange" => "NSE",
    "quantity" => "1",
    "transaction_type" => "SELL",
    "order_type" => "MARKET",
    "product" => "MIS"
    ])["order_id"];
  • rakeshr
    @sachinstlko09
    The error was because you were trying to use Json object as array in $order_id.You need to first convert Json object to array and then retrieve order_id. As below:
    $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "SBIN",
    "exchange" => "NSE",
    "quantity" => "1",
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "MIS"
    ]);
    $order_id = json_decode(json_encode($order_id), True)['order_id'];
    echo "SBIN Order id is ".$order_id;
    // Place order.
    $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "INFY",
    "exchange" => "NSE",
    "quantity" => 1,
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "CNC"
    ]);
    $order_id = json_decode(json_encode($order_id), True)['order_id'];
    echo "INFY Order id is ".$order_id;
  • sachinstlko09
    @rakeshr Thanks, I will try the same. Can you please also suggest why next order placing creates issue.
  • rakeshr
    @sachinstlko09
    Next order execution was skipped because of error occurrence in the above line of fetching order_id. You can go through the above code.
  • sachinstlko09
    @rakeshr by adding the suggested line , still the code break issue exist.

    $order_id = $kite->placeOrder("regular", [
    "tradingsymbol" => "SBIN",
    "exchange" => "NSE",
    "quantity" => "1",
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "MIS"
    ]);
    $order_id = json_decode(json_encode($order_id), True)['order_id'];

    Nothing work after placing the order.
  • rakeshr
    @sachinstlko09
    What is the error/exception you are getting? Can you paste error output here?
  • sachinstlko09
    No error is coming; only after placing the order, code is break . Even a basic print command is not working.
  • sujith
    @sachinstlko09,
    This forum is dedicated only for Kite Connect related queries. We don't provide support for programming.
This discussion has been closed.