M
I am also getting the same erro :
[E 240925 23:59:46 smartConnect:243] Error occurred while making a POST request to https://apiconnect.angelone.in/rest/secure/angelbroking/order/v1/placeOrder. Error: Failed to get symbol details. URL: https://apiconnect.angelone.in/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': 'd0:39:57:ae:dd:44', 'Accept': 'application/json', 'X-PrivateKey': '68FxgSu3', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'variety': 'NORMAL', 'tradingsymbol': 'APOLLOTYRE31OCT24545CE', 'symboltoken': 77637, 'transactiontype': 'BUY', 'exchange': 'NSE', 'ordertype': 'LIMIT', 'producttype': 'INTRADAY', 'duration': 'DAY', 'price': '20.25', 'squareoff': '21.18', 'stoploss': '15.708499999999999', 'quantity': '1700'}, Response: {'message': 'Failed to get symbol details', 'errorcode': 'AB1018', 'status': False, 'data': None}
[E 240925 23:59:46 smartConnect:336] API request failed: {'message': 'Failed to get symbol details', 'errorcode': 'AB1018', 'status': False, 'data': None}
[I 240925 23:59:46 2665154295:19] PlaceOrder : None
while using this code :
#Place order function with detailed logging
def place_order(smartApi, symbol, token, price, target, stoploss, qntty):
try:
# Ensure all numeric values are converted to standard Python types (int or float)
orderparams = {
"variety": "NORMAL",
"tradingsymbol": symbol,
"symboltoken": token, # Explicitly cast to int
"transactiontype": 'Buy',
"exchange": "NFO",
"ordertype": "LIMIT",
"producttype": "CARRYFORWARD",
"duration": "DAY",
"price": price, # Cast to float if it's a price
"squareoff": target, # Target also needs to be float
"stoploss": stoploss, # Stoploss cast to float
"quantity": qntty # Quantity cast to int
}
orderid = smartApi.placeOrder(orderparams)
logger.info(f"PlaceOrder successful: Order ID: {orderid}, Symbol: {symbol}, Token: {token}, Price: {price}, Target: {target}, Stoploss: {stoploss}, Quantity: {qntty}")
except Exception as e:
logger.error(f"Order placement failed for {symbol}: {e}")