fix: pass equity_symbol to execution so Alpha Shield uses JUNIORBEES
_try_execute_sip_paper and _try_execute_sip_live were hardcoding NIFTYBEES.NS regardless of strategy. Added equity_symbol/gold_symbol params to try_execute_sip and propagated from runner using _EQUITY_SYM (_GOLD_SYM). Also fixed JUNIORBEES check in state accounting helpers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6215910c9c
commit
489408cf21
@ -88,7 +88,7 @@ def _apply_filled_orders_to_state(state, orders):
|
||||
if filled_qty <= 0:
|
||||
continue
|
||||
symbol = (order.get("symbol") or "").upper()
|
||||
if symbol.startswith("NIFTYBEES"):
|
||||
if symbol.startswith("NIFTYBEES") or symbol.startswith("JUNIORBEES"):
|
||||
nifty_filled += filled_qty
|
||||
elif symbol.startswith("GOLDBEES"):
|
||||
gold_filled += filled_qty
|
||||
@ -284,7 +284,7 @@ def _apply_fill_delta_to_state(state: dict, order_details: dict):
|
||||
|
||||
nifty_units = 0.0
|
||||
gold_units = 0.0
|
||||
if symbol.startswith("NIFTYBEES"):
|
||||
if symbol.startswith("NIFTYBEES") or symbol.startswith("JUNIORBEES"):
|
||||
state["nifty_units"] += delta_qty
|
||||
nifty_units = delta_qty
|
||||
elif symbol.startswith("GOLDBEES"):
|
||||
@ -646,6 +646,8 @@ def _try_execute_sip_paper(
|
||||
gd_w,
|
||||
broker: Broker | None,
|
||||
mode: str | None,
|
||||
equity_symbol: str = "NIFTYBEES.NS",
|
||||
gold_symbol: str = "GOLDBEES.NS",
|
||||
):
|
||||
def _op(cur, _conn):
|
||||
now_ts = _normalize_now(now)
|
||||
@ -692,7 +694,7 @@ def _try_execute_sip_paper(
|
||||
|
||||
orders = [
|
||||
broker.place_order(
|
||||
"NIFTYBEES.NS",
|
||||
equity_symbol,
|
||||
"BUY",
|
||||
nifty_qty,
|
||||
sp_price_val,
|
||||
@ -700,7 +702,7 @@ def _try_execute_sip_paper(
|
||||
logical_time=logical_time,
|
||||
),
|
||||
broker.place_order(
|
||||
"GOLDBEES.NS",
|
||||
gold_symbol,
|
||||
"BUY",
|
||||
gold_qty,
|
||||
gd_price_val,
|
||||
@ -864,6 +866,8 @@ def _try_execute_sip_live(
|
||||
gd_w,
|
||||
broker: Broker | None,
|
||||
mode: str | None,
|
||||
equity_symbol: str = "NIFTYBEES.NS",
|
||||
gold_symbol: str = "GOLDBEES.NS",
|
||||
):
|
||||
now_ts = _normalize_now(now)
|
||||
if not market_open or broker is None:
|
||||
@ -911,7 +915,7 @@ def _try_execute_sip_live(
|
||||
if nifty_qty > 0:
|
||||
orders.append(
|
||||
broker.place_order(
|
||||
"NIFTYBEES.NS",
|
||||
equity_symbol,
|
||||
"BUY",
|
||||
nifty_qty,
|
||||
sp_price_val,
|
||||
@ -923,7 +927,7 @@ def _try_execute_sip_live(
|
||||
if gold_qty > 0:
|
||||
orders.append(
|
||||
broker.place_order(
|
||||
"GOLDBEES.NS",
|
||||
gold_symbol,
|
||||
"BUY",
|
||||
gold_qty,
|
||||
gd_price_val,
|
||||
@ -984,6 +988,8 @@ def try_execute_sip(
|
||||
gd_w,
|
||||
broker: Broker | None = None,
|
||||
mode: str | None = "LIVE",
|
||||
equity_symbol: str = "NIFTYBEES.NS",
|
||||
gold_symbol: str = "GOLDBEES.NS",
|
||||
):
|
||||
if broker is None:
|
||||
return load_state(mode=mode), False
|
||||
@ -999,6 +1005,8 @@ def try_execute_sip(
|
||||
gd_w,
|
||||
broker,
|
||||
mode,
|
||||
equity_symbol=equity_symbol,
|
||||
gold_symbol=gold_symbol,
|
||||
)
|
||||
return _try_execute_sip_paper(
|
||||
now,
|
||||
@ -1011,5 +1019,7 @@ def try_execute_sip(
|
||||
gd_w,
|
||||
broker,
|
||||
mode,
|
||||
equity_symbol=equity_symbol,
|
||||
gold_symbol=gold_symbol,
|
||||
)
|
||||
|
||||
|
||||
@ -644,6 +644,8 @@ def _engine_loop(config, stop_event: threading.Event):
|
||||
gd_w=gd_w,
|
||||
broker=broker,
|
||||
mode=mode,
|
||||
equity_symbol=_EQUITY_SYM,
|
||||
gold_symbol=_GOLD_SYM,
|
||||
)
|
||||
log_event(
|
||||
event="DEBUG_AFTER_TRY_EXECUTE",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user