not able to place a stock option order

amitbatra03
hi, i am able to place a stock order and get order id using following code:-
$order = $kite->placeOrder("regular", [
"tradingsymbol" => "INFY",
"exchange" => "NSE",
"quantity" => 1,
"transaction_type" => "BUY",
"order_type" => "LIMIT",
"product" => "CNC",
"price"=> 1840
But when i use same code to place a stock option order i.e as follows:-
$order = $kite->placeOrder("regular", [
"tradingsymbol" => "INFY252271840CE", //Stock Name +Year of Expiry(numerical) +Month of expiry(numerical) + Day of expiry(numerical) + Strike and Option type(or FUT for futures)
"exchange" => "NSE",
"quantity" => 400,
"transaction_type" => "BUY",
"order_type" => "LIMIT",
"product" => "CNC",
"price"=> 58
]);
it returns
Uncaught KiteConnect\Exception\InputException (400) 'The instrument you are placing an order for has either expired or does not exist.' thrown in C:\xampp\htdocs\vendor\zerodha\phpkiteconnect\src\KiteConnect.php on line 1697
error

i had tried changing"tradingsymbol" to:- INFY25FEB271840CE and INFY FEB 1840 CE. then tried find a solution for this in forum and found :-
Stock Name +Year of Expiry(numerical) +Month of expiry(numerical) + Day of expiry(numerical) + Strike and Option type(or FUT for futures)
this format.

Please help, am i writing the trading symbol wrong or the code to place stock option order is different.
Thank you

  • seth
    It should be INFY25FEB1840CE. Monthly contracts only contain the year and 3-letter month and not the date.
  • sujith
    You don't need to generate symbols at your end. You can use the instruments master and look for the tradingsymbol.
  • amitbatra03
    @seth thank you so much for replying,its working.

    This value, i am putting in by hand. Will you please tell me that when i put "tradingsymbole" value automatically from database . what checks i need to perform, that it takes the 'ATM' "tradingsymbol" from all that data of 'instrument.cvs' dump.
  • seth
    @amitbatra03 Checking instruments.csv to confirm if an option contract exists is a good idea. You can also get the latest data for the underlying stock/future to find the ATM strike price. I play extra safe and also get the 1-minute candles for the contract to check if price and liquidity are as I expect and mostly place limit orders by using that price.
  • sujith
    @amitbatra03,
    The instruments master only contains what are the instruments that are trading for the day. It won't have information about OTM or ATM or ITM instruments.
  • amitbatra03
    @seth thank you, for showing the way.
  • amitbatra03
    @sujith like for example, if we take 'INFY' option, instrument master have strike prices from 'INFY25FEB1480PE/CE' to 'INFY25FEB2280PE/CE'. If the price is within the mentioned range , we have to calculate ATM,OTM or ITM then match it with the strike price given in instrument master, then check our requirement of CE/PE and check it from instrument master, only then we will get our desired "tradingsymbol". Right ?
Sign In or Register to comment.