OrderException (400) 'Invalid `order_id

Vishwadeep
Vishwadeep edited August 2017 in PHP client
I am facing this problem everywhere
via curl, php
When I try to modify the order this always gives the same error, though sell buy cancel order are working fine

when nothing worked i replaced all variables with constant values but sill no luck.


please suggest


code goes here
----------------------------------------------------------
<?php
date_default_timezone_set("Asia/Kolkata");
$today=date('Y-m-d');
include_once "kiteconnect.php";


$market="MCX";
if(isset($_GET['market'])) $product =strtoupper($_GET['market']); // MCX or NSE by default MCX
$ordertype='LIMIT';
if(isset($_GET['ordertype'])) $ordertype=strtoupper($_GET['ordertype']); // LIMIT or MARKET by default LIMIT
$product='MIS';
if(isset($_GET['product'])) $product =strtoupper($_GET['product']); // MIS or NRML by default MIS

$orderid=$_GET['orderid'];
$price=$_GET['price'];
$lots=$_GET['lots'];
$script=$_GET['expiry'];
$trigger=$_GET['triggerprice'];
$apikey=$_GET['apikey'];
$accesscode=$_GET['accesscode'];

$kite = new KiteConnect($apikey);

try
{
$kite->setAccessToken($accesscode);


$kite->orderModify(170317000517096,null,
[
"tradingsymbol" => "CRUDEOILM17MARFUT",
"exchange" => "MCX",
"quantity" => 1,
"transaction_type" => "SELL",
"price" => 3110,
"trigger_price" => 3112,
"order_type" => "SL", // SL,SL-M, LIMIT, MARKET
"product" => "MIS" // MIS, MARKET
], "regular");

}
catch (Exception $e)
{
throw $e;
}

?>
-------------------------------------------------------






  • sujith
    Hi @Vishwadeep,
    orderModify method accepts only three params and you seem to be passing four params, check out php documentation here.
  • vimalanand
    Hi @sujith ,

    public function orderModify($order_id, $parent_order_id=null, $params, $variety) {
    $params["variety"] = $variety;


    The above code is from kiteconnect.php file I have downloaded recently.

    Lines #292, #293.

    However, in the link you provided, there's no parent_order variable.

  • Vivek
    @Vishwadeep Seems like issue in PHPKiteConnect in this line - https://github.com/rainmattertech/phpkiteconnect/blob/master/kiteconnect.php#L328

    Order id is not sent in $params. We will fix the issue in next release but for now you can send $order_id in params and it should work fine. Something like this
    	$kite->orderModify(170317000517096,null,
    [
    "tradingsymbol" => "CRUDEOILM17MARFUT",
    "exchange" => "MCX",
    "quantity" => 1,
    "transaction_type" => "SELL",
    "price" => 3110,
    "trigger_price" => 3112,
    "order_type" => "SL", // SL,SL-M, LIMIT, MARKET
    "product" => "MIS" // MIS, MARKET
    "order_id" => "170317000517096"
    ], "regular");
    Also note that order_id should be sent as string not integer.
Sign In or Register to comment.