☰
Login
Signup
Home
›
PHP client
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.9K
All Categories
0
Incidents
156
Node JS client
40
Go client
793
.Net API client
380
Kite Publisher
537
.Net / VBA / Excel (3rd party)
457
Algorithms and Strategies
996
Java client
1.1K
API clients
404
PHP client
4K
Python client
346
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
General
In this Discussion
May 2018
Sushil_NSE
BO order with Kite API Ver -3 not getting placed Instead posting as MIS Order
Sushil_NSE
May 2018
in
PHP client
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:
php
api client
Sushil_NSE
May 2018
This is resolved . Should use
https://api.kite.trade/orders/bo
instead of
https://api.kite.trade/orders/regular
but no where mentioned in guide.
Sign In
or
Register
to comment.