BO order with Kite API Ver -3 not getting placed Instead posting as MIS Order

Sushil_NSE
Hi,

I am trying to post BO order with below code but it's posting MIS order instead. Where am i wrong ? Please help on urgent basis -

/***************************** Place Zerodha Order : Start ******************************/

$company_code = "INFY";
$transaction_type="BUY";
$quantity = 2;
$target_profit = 2;
$stop_loss = 2;

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "https://api.kite.trade/orders/regular");
//curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Kite-Version: 3',
"Authorization: token $API_KEY:$ACCESS_TOKEN"
));

// grab URL and pass it to the browser

$data="tradingsymbol=$company_code&exchange=NSE&quantity=$quantity&transaction_type=$transaction_type&order_type=LIMIT&price=1200&squareoff_value=$target_profit&stoploss_value=$stop_loss&variety=bo&validity=DAY&product=MIS";

echo $data;
//$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($ch);

// close cURL resource, and free up system resources
print_r($response);
file_put_contents("order_placed.json",$response);

// Check for errors and display the error message
if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):\n {$error_message}";
}

//echo $response;

curl_close($ch);

$response=file_get_contents("order_placed.json");
$obj = json_decode($response);

$STATUS = $obj->{'status'};;
echo "Command Status : " . $STATUS . "
";
$ORDER_ID = $obj->{'data'}->{'order_id'};
echo "Order ID : " . $ORDER_ID;

/***************************** Place Zerodha Order : End ******************************/
Tagged:
Sign In or Register to comment.