sensex symbol name is wrong


  • i wanted to fetch symbol tokens of sensex options so today was 14th november2024 the day is thursday and technically today is the expiry since tomorrow is holiday so the expiry should be 14nov but in the json file it was
    available for 24nov
    1st occurence
    4c0daec7-dd4c-4274-92e7-ee429fe4eed7-image.png
    2nd occurrence
    a34ec9be-645c-4345-a098-9640e3d6c0de-image.png
    as you can see there was a mistake in the expiry dates
    please look into it @admin
    @admin123 @Moderator_1 @Moderator_2 @Moderator_3


  • @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


  • hey! @manjunathn1988 can you tell me the error you are getting?


  • @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

  • Hi @meet-panchal

    Okay. Glad you resolved. Happy coding.

    Regards, Smart API Team


  • @Moderator_3
    actually i solved it the problem was about how the names of option contracts differ for nifty and banknifty its same but sensex is different i eventually figured it out


  • Hi @meet-panchal,

    Uploaded screenshot again since not getting loaded properly. Pls upload appropriate screenshot.

    Regards, SmartAPI Team