βœ–

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

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

  • Author
    Posts
    • πŸ“ Question Details

      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?

    • 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)
Viewing 1 reply thread
×

Start a Discussion

Get help from the AlgoDelta community.

×

Welcome Back!

Enter your email to sign in or create an account. No passwords needed.

⏳

Pending Approval

⚠️

Delete This?

Are you sure you want to delete this? This action is permanent and cannot be undone.

Scroll to Top