How to get ATM strike to actual option symbol with CE/PE and with expire selection ?

Asked by Sejpalsinh Jadeja · SOLVED
1 reply 504 views Jump to solution Reply
Sejpalsinh Jadeja Original Post
AlgoDelta Team

I have already implemented dynamic strike selection (ATM/ITM/OTM) and also handled strike gap while working in my Super trend algo.

Now I am stuck at the next step — I have something like:

  • NIFTY
  • 19900 strike
  • CE

But I don’t know how to convert this into the actual tradable symbol or instrument token from the broker.

How do I get this properly for order placement?

Posted Apr 24
Reply

    1 Reply

    Support AlgoDelta
    Support AlgoDelta AlgoDelta Support ·

    So, you can find it from the instrument list provided by broker.

    Root idea is that broker gives the full instrument data (CSV/list).

    We can filter it based on symbol, Strick, expire, option type (CE/PE).

    So, the logic is simple we will select the most common Strick gap.

    Below is the code you can refer:

    def find_option(instruments, name, strike, option_type):
        filtered = []
        for ins in instruments:
            if (
                ins["name"] == name and
                ins["instrument_type"] == option_type and
                ins["strike"] == strike
            ):
                filtered.append(ins)
        if not filtered:
            return None
        # pick nearest expiry
        filtered.sort(key=lambda x: x["expiry"])
        return filtered[0]
    
    # Sample instrument data
    instruments = [
        {"name": "NIFTY", "strike": 19900, "instrument_type": "CE", "expiry": "2026-04-30", "token": 111},
        {"name": "NIFTY", "strike": 19900, "instrument_type": "CE", "expiry": "2026-05-07", "token": 222},
    ]
    
    result = find_option(instruments, "NIFTY", 19900, "CE")
    
    print(result)
    Verified Solution
    • Ok, got your point and I get the ATM Strick properly. Thanks for the code. – Sejpalsinh Jadeja Team Jun 16
    Markdown supported · ```json for code blocks · paste or drop screenshots

    Be specific and kind. Never share API keys, passwords or personal account details.

    Welcome to the community

    Log in or create your account in under a minute.

    1. 1Mobile
    2. 2E-mail
    3. 3Password
    +91

    Have a password?

    By continuing you agree to the community guidelines. We’ll send a one-time code by SMS.