Not able to place Order

jitendra
I am trying to place order but not getting the order id and the order is not getting placed. I am using the following code:
$kite = new KiteConnect($api_key);
$order_id = $kite->placeOrder([
"api_key" => $api_key,
"access_token" => $access_token,
"tradingsymbol" => $tradingSymbol,
"exchange" => $exchange,
"quantity" => $quantity,
"transaction_type" => $transactionType,
"order_type" => $orderType,
"price" => $price,
"validity" => "DAY",
"product" => "NRML"
], "regular");
echo "
Order id is ".$order_id;
  • sujith
    Do you mean the order is getting rejected?
    You can check status message to know the rejection reason.
  • jitendra
    Hi Sujith, I am not getting any status message [order ID or status]. Infact, I can not see my order when I am logging in to my account. When I am placing a manual order from kite then I can see that order in the kite. But this is not happening when I am using API. Where am I going wrong???
  • sujith
    Can you paste the error message here?
  • jitendra
    I am trying to print the response but not getting anything.
    $order_id = $kite->placeOrder("regular", [
    "api_key" => $api_key,
    "access_token" => $access_token,
    "tradingsymbol" => "INFY",
    "exchange" => "NSE",
    "quantity" => 1,
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "NRML"
    ])["order_id"];

    echo "Order id is ".$order_id; //NOT GETTING ANYTHING
    print_r($order_id); //NOT GETTING ANYTHING
  • sujith
    Try running in debug mode and check logs.
  • raja1sttarde
    if you have successfully gotten to $kite;
    print_r($kite);

    you'll see key, token etc values are already present. not needed for placeOrder().
    If you trace the placeOrder() function to _request() function you'll see;
    if ($this->api_key && $this->access_token) {$request_headers[] = "Authorization: token " . $this->api_key . ":" . $this->access_token;}
    also the added ["order_id"] is not required.

    run the example in kiteconnect.php, as is, and you should get a response order ID.

    // Place order.
    $o = $kite->placeOrder("regular", [
    "tradingsymbol" => "INFY",
    "exchange" => "NSE",
    "quantity" => 1,
    "transaction_type" => "BUY",
    "order_type" => "MARKET",
    "product" => "NRML"
    ]);

    echo "Order id is ".$o->order_id;
    I ran the example as is and got a response.

    $var = @$kite->getOrders();

    if(!empty($var))print_r($var);
    status=> "REJECTED"
    status_message=> "RMS:Blocked for EQUITY nse_cm NRML Remarks: Equity orders are not allowed in NRML product type block type: ALL"


    I didn't know about the debugging. It is a class property, I found it at line 161 on my kiteconnect.php

    public $debug = null;//set true to see debug messages

    private function _request(...)
    {
    ....
    if($this->debug) {
    print("Request: " . $method . " " . $url . "\n");
    var_dump($params);
    }
    }
  • sujith
    sujith edited November 26
    @raja1sttarde,
    Possible products for equity are CNC and MIS.
    NRML is for F&O instruments only.
  • raja1sttarde
    @sujith Thanks for clarifying the status message. The message makes sense now.
    To clarify, MIS is possible for F&O, yes?
    Thanks!
  • sujith
    Yes, MIS is one of the possible products for F&O instruments.
Sign In or Register to comment.