Update app.py
Browse files
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 |
-
|
| 176 |
-
if clean_inst.startswith(
|
| 177 |
-
remainder = clean_inst[len(
|
| 178 |
-
|
|
|
|
|
|
|
| 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
|