@meet-panchal i was able to crack it using the master list.
correct format is SENSEX 25 2 18 76000CE
SENSEX DD M
Thanks u
@meet-panchal i was able to crack it using the master list.
correct format is SENSEX 25 2 18 76000CE
SENSEX DD M
Thanks u
@admin i was able to decode using the master list, you are right.
Thanks
@meet-panchal hey can you help me out with the correct format i tried many thing it didnt work?
..
def get_option_symbol():
"""Finds the nearest SENSEX Call Option (CE) for the appropriate expiry."""
try:
# Fetch the spot price for SENSEX
spot = smart_api.ltpData("BSE", "SENSEX", "99919000")
nifty_spot = spot['data']['ltp']
# Calculate the nearest strike price (rounded to the nearest 100)
strike = round(nifty_spot / 100) * 100
# Get today's date and determine the expiry date
today = datetime.datetime.now()
expiry_date = datetime.datetime.strptime(get_next_expiry_date(), "%d%b%y")
# Format the expiry date in the correct "YYMNDD" format
expiry_str = expiry_date.strftime("%y") + expiry_date.strftime("%b").upper()[0] + expiry_date.strftime("%d").zfill(2)
# Construct the symbol in the correct format with no spaces
symbol = f"SENSEX{expiry_str}{strike}CE"
print(f"Searching for symbol: {symbol}") # Print the symbol being searched
# Search for the symbol on BSE
scrip_info = smart_api.searchScrip("BFO", symbol)
if scrip_info and 'data' in scrip_info:
token = scrip_info['data'][0]['symboltoken']
ltp = smart_api.ltpData("BFO", symbol, token)
if ltp and 'data' in ltp:
return {'symbol': symbol, 'token': token, 'premium': ltp['data']['ltp']}
else:
print(f"⚠️ LTP data not found for {symbol}, skipping.")
return None # Skip if no LTP data
else:
print(f"⚠️ No matching scrip found for {symbol}")
return None
except Exception as e:
print(f"🚨 Option fetch error: {str(e)}")
return None
Re: sensex symbol name is wrong
https://smartapi.angelbroking.com/topic/4871/sensex-symbol-name-is-wrong/4?_=1739357182047
can some help to fix this issue ?
def get_option_symbol():
"""Finds the nearest SENSEX Call Option (CE) for the appropriate expiry."""
try:
# Fetch the spot price for SENSEX
spot = smart_api.ltpData("BSE", "SENSEX", "99919000")
sensex_spot = spot['data']['ltp']
# Calculate the nearest strike price (rounded to the nearest 100)
strike = round(sensex_spot / 100) * 100
# Get today's date and determine the expiry date
today = datetime.datetime.now()
expiry_date = datetime.datetime.strptime(get_next_expiry_date(), "%d%b%y")
# Format the expiry date in the correct "YYMNDD" format
expiry_str = expiry_date.strftime("%y") + expiry_date.strftime("%b").upper()[0] + expiry_date.strftime("%d").zfill(2)
# Construct the symbol in the correct format with no spaces
symbol = f"SENSEX{expiry_str}{strike}CE"
print(f"Searching for symbol: {symbol}") # Print the symbol being searched
# Search for the symbol on BSE
scrip_info = smart_api.searchScrip("BFO", symbol)
if scrip_info and 'data' in scrip_info:
token = scrip_info['data'][0]['symboltoken']
ltp = smart_api.ltpData("BFO", symbol, token)
if ltp and 'data' in ltp:
return {'symbol': symbol, 'token': token, 'premium': ltp['data']['ltp']}
else:
print(f"⚠️ LTP data not found for {symbol}, skipping.")
return None # Skip if no LTP data
else:
print(f"⚠️ No matching scrip found for {symbol}")
return None
i tried many symbol format provided in the above link but still not working
typical output
[I 250212 16:19:09 smartConnect:124] in pool
✅ Successfully logged in!
🔍 Checking Entry Condition:
🔹 Current Candle Close: 76238.33 > super_trend: 76034.532? True
🔹 Current Candle Close: 76238.33 > EMA: 76110.50785751663? True
🔹 Supertrend value for current candle: 76034.532
Searching for symbol: SENSEX25F1876200CE
[I 250212 16:19:11 smartConnect:499] Search successful. No matching trading symbols found for the given query.
🚨 Option fetch error: list index out of range
🛑 Manual interruption!
can some one please help?