Junk & Legacy Code Analysis
After reviewing all files in backend/nseeod/, the following functions and classes
were identified as junk, duplicated, incomplete, or out of scope for the EOD pipeline.
Summary
| Severity | Count | Description |
|---|---|---|
| 🔴 Bug | 2 | Duplicate function definitions that silently overwrite each other |
| 🟡 Dead Code | 6 | Functions defined but never called in the main flow |
| 🟠 Debug Code | 3 | Debug utilities with breakpoint() / print with emoji |
| ✅ Moved | 1 | ut_Classes.py moved to backend/nseieod/ (intraday package) |
🔴 Bugs — Duplicate Definitions
save_task() defined twice in utils.py
# Line 164 — first definition (INSIDE add_nse_site_task context)
def save_task(typ, notes, pending, conn):
...
# Line 401 — second definition (OVERWRITES the first silently)
def save_task(typ, notes, pending, conn):
... # identical implementation
Impact: Python silently uses the last definition. Both are identical so no functional bug currently, but this is confusing and a maintenance hazard.
Action: Delete lines 401–415 (second definition).
getnsebhavzip() defined twice in utils.py
# Line 110 — first definition (equity context)
def getnsebhavzip(url, mtargetfolder, parent):
...
print(f"[utils] Fetching ZIP from {url}")
# Line 532 — second definition (F&O context, OVERWRITES first)
def getnsebhavzip(url, mtargetfolder, parent):
...
print(f"[utils] Fetching F&O ZIP from {url}")
Impact: The first definition (equity log message) is always shadowed by the second. Equity downloads show "F&O ZIP" in logs — misleading. No functional bug since logic is identical.
Action: Remove the first definition (lines 110–132). Rename the remaining one's log message to be neutral (remove "F&O" from the message).
🟡 Dead Code — Functions Not Called in Main Flow
checkindexbhav(mdate, mpath, conn, parent) in utils.py
Debug function that reads an index CSV and merges with Indexinfo.csv, writing
output to merge.csv. Uses deprecated inplace=True on .fillna() (pandas warning).
Never called from any active code path.
Action: Delete or move to check_bhav.py.
NseMuhuratDates(conn) in utils.py
Takes a conn parameter that is never used inside the function body
(uses pgs.read_sql directly). Misleading signature.
Action: Remove the unused conn parameter.
clean_float(val) in utils.py
def clean_float(val):
if val == int(val):
return int(val)
return val
Not called anywhere in the codebase.
Action: Delete.
NseEodIndexUpdater.initasks() in EquityBhav.py
def initasks(self):
pass
# self.pending = {'2023-05-30': ...} # commented out
Empty method with commented-out test data. No purpose.
Action: Delete.
NseEodDelValDownloader.initasks() in EquityBhav.py
Same — empty pass method. No purpose.
Action: Delete.
NseEodIndexUpdater.pendingjobs() and NseEodDelValDownloader.pendingjobs() in EquityBhav.py
def pendingjobs(self):
a = pgs.getsqlValue("select json_object_keys(taskobj) from tasks where typ=" + str(self.typ))
print(len(a))
Just prints the count of pending tasks to console. Not wired to any API or UI.
Action: Delete or replace with a proper return value if needed.
🟠 Debug Code — Contains breakpoint() or Emoji
Restore_Missingdates.check() — moved to nseieod
def check(self):
...
if len(df) > 0:
print(f"Preparing for Restore Missing Dates from {self.dpath}")
breakpoint() # ← STOPS EXECUTION IN PRODUCTION
# TODO: need to write code here
Has a breakpoint() call and a TODO. Incomplete implementation.
Also has hardcoded Windows path: D:\kss\stock\IBCOneminustes\...
Status: ✅ File moved to backend/nseieod/ut_Classes.py. Still has open breakpoint() calls — implement or remove before production use.
Restore_Missingdates.__getEodfile() — moved to nseieod
def __getEodfile(self):
...
breakpoint() # ← another debug breakpoint
Status: ✅ File moved to backend/nseieod/ut_Classes.py. breakpoint() still present — incomplete research code.
check_bhav.py — emoji in print statements
print(f"\n🔍 Checking FO Bhav for {date_str}")
print("❌ FO bhav file not found")
print(f"⚠️ Missing masid mapping: {missing}")
On Windows (cp1252), emoji in print() raises UnicodeEncodeError.
check_bhav.py is a standalone debug utility, not part of the API — but still risky.
Action: Replace emoji with ASCII equivalents in case it's run on Windows.
✅ Resolved — ut_Classes.py moved to nseieod
ut_Classes.py belonged to intraday data analysis, not EOD bhav copy processing.
It has been moved to backend/nseieod/ut_Classes.py.
| Class | Purpose | Status |
|---|---|---|
Resu_Holidays | Removes a holiday when trading happened on that day | Moved ✅ |
Restore_Missingdates | Restores missing intraday data from a GitHub archive | Moved ✅ — breakpoint() calls still need removal |
FillingMissingTimes | Linear/pattern interpolation for 1-min missing bars | Moved ✅ |
Cleaned up on move:
- Removed unused
from numpy.ma.core import filled - Removed unused
from selenium.webdriver.support.expected_conditions import ...
Remaining work in nseieod/ut_Classes.py:
- Remove two
breakpoint()calls fromRestore_Missingdatesbefore production use - Resolve hardcoded Windows path
D:\kss\stock\IBCOneminustes\...in__init__
Recommended Priority Order
- Fix now — Remove duplicate
save_task()andgetnsebhavzip()(🔴 bugs) - Fix soon — Remove
breakpoint()calls fromut_Classes.py(production safety) - Clean up — Delete
initasks(),pendingjobs(),clean_float(),checkindexbhav() Refactor — Move✅ Done — moved tout_Classes.pyout of thenseeodpackagenseieod- Minor — Fix
NseMuhuratDates(conn)unused parameter