topsecrettraders commited on
Commit
6481e77
·
verified ·
1 Parent(s): 691a1b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -168,14 +168,15 @@ async def fetch_series(
168
 
169
  # Robust Python Logic for Strike Pricing mapping
170
  strike_map = {}
171
- prefix = f"{root}{expiry}"
172
  for inst in instruments:
173
  if inst.endswith('CE') or inst.endswith('PE'):
174
  clean_inst = inst.split(":")[-1]
175
- # Safest: remove Root+Expiry then search
176
- if clean_inst.startswith(prefix):
177
- remainder = clean_inst[len(prefix):]
178
- match = re.search(r'^(\d+(?:\.\d+)?)(CE|PE)$', remainder)
 
 
179
  if match:
180
  strike_map[inst] = float(match.group(1))
181
  continue
 
168
 
169
  # Robust Python Logic for Strike Pricing mapping
170
  strike_map = {}
 
171
  for inst in instruments:
172
  if inst.endswith('CE') or inst.endswith('PE'):
173
  clean_inst = inst.split(":")[-1]
174
+
175
+ if clean_inst.startswith(root):
176
+ remainder = clean_inst[len(root):]
177
+ # Fyers date codes are always 5-6 characters (e.g. 26310 or 26MAR).
178
+ # By skipping the first 5 chars, we isolate the true strike perfectly.
179
+ match = re.search(r'(\d+(?:\.\d+)?)(?:CE|PE)$', remainder[5:])
180
  if match:
181
  strike_map[inst] = float(match.group(1))
182
  continue