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