not able to place fno orders on nifty50 index
-
import pyotp from SmartApi import SmartConnect from logzero import logger apikey="z1IPZzY0" username="M52500299" pwd="1233" smartApi=SmartConnect(apikey) try: token = "4TZ63NU76235CQV3KFW6HB7A2Y" totp = pyotp.TOTP(token).now() except Exception as e: logger.error("Invalid Token: The provided token is not valid.") raise e data = smartApi.generateSession(username, pwd, totp) if data['status'] == False: logger.error(data) else: # login api call # logger.info(f"You Credentials: {data}") authToken = data['data']['jwtToken'] refreshToken = data['data']['refreshToken'] # fetch the feedtoken feedToken = smartApi.getfeedToken() # fetch User Profile res = smartApi.getProfile(refreshToken) smartApi.generateToken(refreshToken) res=res['data']['exchanges'] #place order try: orderparams = { "variety": "NORMAL", "tradingsymbol": "NIFTY31OCT24400PE", "symboltoken": "99926000", "transactiontype": "BUY", "exchange": "NFO", "ordertype": "MARKET", "producttype": "INTRADAY", "duration": "DAY", "price": "19500", "squareoff": "0", "stoploss": "0", "quantity": "25" } # Method 1: Place an order and return the order ID orderid = smartApi.placeOrder(orderparams) logger.info(f"PlaceOrder : {orderid}") # Method 2: Place an order and return the full response response = smartApi.placeOrderFullResponse(orderparams) logger.info(f"PlaceOrder : {response}") except Exception as e: logger.exception(f"Order placement failed: {e}")
for this code im getting this error
[I 241028 13:21:49 smartConnect:121] in pool
[E 241028 13:21:52 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/placeOrder. Error: Failed to get symbol details. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/placeOrder, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': '00:50:56:c0:00:08', 'Accept': 'application/json', 'X-PrivateKey': 'z1IPZzY0', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'variety': 'NORMAL', 'tradingsymbol': 'NIFTY31OCT24400PE', 'symboltoken': '99926000', 'transactiontype': 'BUY', 'exchange': 'NFO', 'ordertype': 'MARKET', 'producttype': 'INTRADAY', 'duration': 'DAY', 'price': '19500', 'squareoff': '0', 'stoploss': '0', 'quantity': '25'}, Response: {'message': 'Failed to get symbol details', 'errorcode': 'AB1018', 'status': False, 'data': None}
[E 241028 13:21:52 smartConnect:336] API request failed: {'message': 'Failed to get symbol details', 'errorcode': 'AB1018', 'status': False, 'data': None}
[I 241028 13:21:52 angleone:56] PlaceOrder : None
[E 241028 13:21:52 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/placeOrder. Error: Failed to get symbol details. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/placeOrder, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': '00:50:56:c0:00:08', 'Accept': 'application/json', 'X-PrivateKey': 'z1IPZzY0', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'variety': 'NORMAL', 'tradingsymbol': 'NIFTY31OCT24400PE', 'symboltoken': '99926000', 'transactiontype': 'BUY', 'exchange': 'NFO', 'ordertype': 'MARKET', 'producttype': 'INTRADAY', 'duration': 'DAY', 'price': '19500', 'squareoff': '0', 'stoploss': '0', 'quantity': '25'}, Response: {'message': 'Failed to get symbol details', 'errorcode': 'AB1018', 'status': False, 'data': None}
[E 241028 13:21:53 smartConnect:352] API request failed: {'message': 'Failed to get symbol details', 'errorcode': 'AB1018', 'status': False, 'data': None}
[I 241028 13:21:53 angleone:59] PlaceOrder : None -
@meet-panchal said in not able to place fno orders on nifty50 index:
99926000
Hello Meet, the symbol token in your code is for Nifty 50, but to place the order, you would need to use symbol token of the specific option contract that you want to trade in.
This is the reason that the system is giving an error.