How to place an GTT order of banknifty call option market order with stop loss and target price?

arunbritto7
I'm new to Kite Connect API. Need a help to place an GTT order of banknifty call option market order with stop loss and target price? I have tried like this its not working.
 
$formattedSymbol = 'BANKNIFTY2421445700CE';

$quote = $kite->getQuote(['NFO:' . $formattedSymbol]);

$quote = $quote['NFO:' . $formattedSymbol];

$last_traded_price = $quote->last_price;


// Calculate stop-loss and target prices based on percentages
$stop_loss_percentage = 50; // 50 %
$target_percentage = 100; // 100%

$stop_loss_price = $last_traded_price * (1 - ($stop_loss_percentage / 100));
$target_price = $last_traded_price * (1 + ($target_percentage / 100));

// Place GTT order with market order type
$place_GTT = $kite->placeGTT([
"trigger_type" => $kite::GTT_TYPE_SINGLE,
"tradingsymbol" => $formattedSymbol,
"exchange" => "NFO",
"trigger_values" => [$stop_loss_price, $target_price], // Stop-loss and target prices
"orders" => [
[
"transaction_type" => $kite::TRANSACTION_TYPE_BUY,
"quantity" => 1,
"product" => $kite::PRODUCT_CNC,
"order_type" => $kite::ORDER_TYPE_MARKET // Market order type
]
]
]);
This discussion has been closed.