From d4e06d92119332afe570ca2dd1acdddca72b1570 Mon Sep 17 00:00:00 2001 From: Thigazhezhilan J Date: Wed, 3 Jun 2026 10:25:12 +0530 Subject: [PATCH] fix: show JUNIORBEES.NS position in paper MTM by fetching unknown LTP market.py's LTP cache only has NIFTYBEES.NS and GOLDBEES.NS. For Alpha Shield, JUNIORBEES.NS was missing from the map so paper_mtm.py was silently dropping it. Now falls back to fetch_live_price for any symbol not in the cached map. Co-Authored-By: Claude Sonnet 4.6 --- backend/paper_mtm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/paper_mtm.py b/backend/paper_mtm.py index f9192f0..cc0f765 100644 --- a/backend/paper_mtm.py +++ b/backend/paper_mtm.py @@ -12,6 +12,7 @@ if str(PROJECT_ROOT) not in sys.path: sys.path.append(str(PROJECT_ROOT)) from indian_paper_trading_strategy.engine.db import engine_context +from indian_paper_trading_strategy.engine.data import fetch_live_price from market import get_ltp from indian_paper_trading_strategy.engine.state import load_state @@ -45,7 +46,10 @@ def paper_mtm(request: Request) -> Dict[str, Any]: avg_price = float(pos.get("avg_price", 0)) ltp = ltp_map.get(symbol) if ltp is None: - continue + try: + ltp = fetch_live_price(symbol, allow_cache=True) + except Exception: + ltp = float(pos.get("last_price") or pos.get("avg_price") or 0) pnl = (ltp - avg_price) * qty positions_value += qty * ltp