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 <noreply@anthropic.com>
This commit is contained in:
parent
489408cf21
commit
d4e06d9211
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user