Skip to content

Comprehensive audit: bug fixes, CAGR formula fix, extension UI, project reorg - #3

Open
karmataklu-bot wants to merge 39 commits into
SamirWagle:mainfrom
karmataklu-bot:claude/lucid-wright-686b1d
Open

Comprehensive audit: bug fixes, CAGR formula fix, extension UI, project reorg#3
karmataklu-bot wants to merge 39 commits into
SamirWagle:mainfrom
karmataklu-bot:claude/lucid-wright-686b1d

Conversation

@karmataklu-bot

Copy link
Copy Markdown

Bug fixes

  • CAGR formula fix — right share costs now included in denominator;
    server was returning inflated returns for any stock with rights issues
  • _build_events rewrite — running unit count tracked correctly;
    units_after was null causing TypeError crash in extension popup
    for any stock with corporate actions
  • get_stock_name — uncleaned company names with trailing ( TICKER )
    suffix fixed in find_new_listings_interactive.py
  • Recursive main() replaced with while True loop in
    find_new_listings_interactive.py

Security

  • Path traversal blocked in server — _SYMBOL_RE regex validates
    symbol before any filesystem access

Extension UI

  • Right share badge added to popup.js — previously no branch for
    'right' events, caused blank cell and crash
  • .badge-right CSS added to popup.html

Code quality

  • 4 duplicate functions removed from nepse_cagr_server.py —
    single source of truth via imports from nepse_cagr.py
  • HTTPServer → ThreadingHTTPServer for concurrent requests
  • errno == 48 → errno.EADDRINUSE for cross-platform compatibility
  • Unused imports removed, PEP 8 import order, DAYS_PER_YEAR constant added
  • requirements.txt — 5 unused removed, 2 missing added, version bounds added

Project structure

  • analysis/ — nepse_bull_bear_analyser.py, find_new_listings.py,
    find_new_listings_interactive.py
  • scraper/ — ipo_listing.py, index_history.py, fetch_company_names.py
  • bull3_analysis.py deleted — superseded by --period bull3
  • run_index_history.py deleted — redundant wrapper
  • All sys.path references updated to .parent.parent

Karma Y and others added 30 commits May 4, 2026 10:28
Updated README to reflect new project structure and features.
- Chrome extension (popup, background, analyse UI) for NEPSE CAGR calculation
- Native messaging host (nepse_host.py + wrapper shell script) bridges extension to local Python engine
- nepse_cagr_server.py runs local HTTP server for CAGR calculations
- com.nepse.cagr.json manifest registers native host with Chrome
- CLAUDE.md and SETUP.md document project and setup steps
Updated README to clarify functionality and usage details.
Added a section for the Browser Extension, detailing its architecture, files, and setup instructions for macOS.
- index_history.py: scrapes all 18 NEPSE indices from ShareSansar
  - GET request with numeric index_id (not POST with text name)
  - 30-day chunks (server silently returns 0 rows for >= 31 days)
  - JSON response parsing (not HTML table)
  - Incremental mode: resumes from latest CSV date
  - Query mode: --query --index "X" --date YYYY-MM-DD
- run_index_history.py: CLI entry point mirroring run_daily.py pattern
- data/index/: initial historical data for all 18 sub-indices
…to fix MV3 CSP

Chrome MV3 blocks inline <script> blocks and CDN scripts.
- Extract all JS from analyse.html into analyse.js (external file)
- Download chart.umd.js locally (was blocked from cdnjs CDN)
- Light mode theme toggle now works
- Add topbar-right container to group theme and back buttons
- Implement switchPage function for multi-page navigation
- Back button shows on non-analyse pages, hidden on main page
- Back button navigates back to analyse (main) page
- Add corresponding CSS styling for back-btn
…nflict

- Add asterisk note clarifying NEPSE data based on closing prices
- Remove malformed JavaScript code from HTML merge conflict
- Clean up CAGR page section
Remove height:0 from Estimated (1994-2000) legend item. Height override
prevented dashed border from rendering. Now displays properly as dashed line.
- Add company name/ticker search input field for future filtering capability
- Add "My Predictions — Next Cycle Top" section with 4 key indicators:
  * Buffett Indicator (market cap = GDP) reaching 100%
  * Daily trading volume approaching 35–40 Arab
  * Index crossing 5,000
  * 4-year cycle milestone from Sep 2022 bottom (~Sep 2026)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…ack nav

- Add page-buffett: full blog-style article from PDF (all 5 pages)
- Include Global & Regional Buffett Indicator comparison table (11 markets)
- Wire #buffett-link click → switchPage('buffett') via JS (CSP-safe)
- Fix back button to return to previous page (bullbear → buffett → back = bullbear)
- Add buffett-indicator.pdf to extension and web_accessible_resources in manifest
- Article width set to 749px, minimal dark aesthetic
Karma Y added 9 commits May 12, 2026 14:54
…O research

Features:
- nepse_bull_bear_analyser.py: interactive analysis of all 5 bulls + 4 bears
  * 15% price-based shaving (NEPSE index delta thresholds)
  * Multi-sheet Excel output (full, shaved, analysis)
  * Bull 4 POC: 168 stocks (full), 166 stocks (shaved), analysis metrics
- nepse_cagr.py: extended with end_date parameter and get_all_symbols() helper
  * Enables windowed CAGR calculations for any date range
  * Bulk symbol enumeration from company-wise directory
- nepse_cagr_server.py: updated for new bull/bear analysis support
- Extension UI (analyse.html/js): enhanced for bull run tracking per ticker

IPO Research:
- ipo_listing.py: new script for IPO listing analysis
- fetch_company_names.py: populate company_names.json
- find_new_listings.py: identify recent IPO entries
- IPO research data: performance tracking, 1-year returns analysis
- new_listings_cagr.csv: consolidated IPO metrics

Analysis:
- bull3_analysis.py: legacy single-cycle analysis
- daily_patch.py: utility for daily data reconciliation
- Graphify knowledge graph: codebase architecture mapped

Data:
- company_names.json: ticker-to-name mapping (339 symbols)
- Research/: organized IPO and bull/bear analysis outputs
- graphify-out/: AST-based code graph with wiki

Results:
- Bull 4 median CAGR: 85.64% (full) vs 88.68% (shaved 15%)
- Identified listing artifacts: short-window trades skew mean CAGR
- Median chosen as reliable metric for cycle performance
## Bug fixes
- nepse_cagr_server.py: fix CAGR formula — include right share costs in
  total_invested denominator (was inflating CAGR for stocks with rights)
- nepse_cagr_server.py: fix _build_events — track running unit count so
  units_after is always a valid float; compute cash_rs correctly
- nepse_cagr_server.py: add path traversal protection via _SYMBOL_RE
- nepse_cagr_server.py: fix errno.EADDRINUSE (was macOS-only errno==48)
- nepse_cagr_server.py: use ThreadingHTTPServer instead of HTTPServer
- find_new_listings_interactive.py: fix get_stock_name to strip trailing
  ticker symbol in parentheses e.g. "Bank Ltd ( NABIL )" -> "Bank Ltd"
- ipo_listing.py: fix data_dir path (was .parent.parent.parent, broken)
- index_history.py: clarify 29-day chunk limit comment (ShareSansar bug)
- nepse_host.py: fix bare except -> except (OSError, urllib.error.URLError)
- find_new_listings_interactive.py: fix recursive main() -> while loop

## Code quality
- nepse_cagr.py: add DAYS_PER_YEAR constant, remove unused import os,
  add docstring to calculate_cagr()
- nepse_cagr_server.py: delete 4 duplicate functions, import from
  nepse_cagr.py; add Content-Length guard, silence logs
- ipo_listing.py: move inline imports to top-level (PEP 8)
- requirements.txt: remove unused deps (apscheduler, dotenv, pytz, lxml,
  opencv); add openpyxl, python-dateutil with version pins

## Extension UI
- popup.js: add 'right' share badge branch (was crashing on null pct)
- popup.html: add .badge-right CSS (amber dark/light mode variants)

## Project reorganization
- analysis/: move nepse_bull_bear_analyser.py, find_new_listings.py,
  find_new_listings_interactive.py (all __file__ paths updated)
- scraper/: move index_history.py, fetch_company_names.py
  (paths updated); remove redundant standalone ipo_listing.py
- data/: move company_id_mapping.json from scraper/scraper/data/
- Delete: bull3_analysis.py (superseded by --period bull3),
  daily_patch.py (edits already applied), run_index_history.py (shim)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant