Fix type hint, config handling, and auth header

- Fix return type: Tuple[str, str, dict] → Tuple[str, dict, dict]
  (full_signal is a dict, not a string)
- Use safe config merge to avoid mutating caller's dict
- Fix auth header to use X-API-Key (System R convention)

Co-Authored-By: gemini-code-assist[bot] <noreply@github.com>
This commit is contained in:
ashimnandi-trika 2026-03-08 23:52:41 +05:30
parent 07260ff4fe
commit 0624bf4564
1 changed files with 3 additions and 3 deletions

View File

@ -78,7 +78,7 @@ def call_systemr_pre_trade_gate(
"Content-Type": "application/json",
}
if key:
headers["Authorization"] = f"Bearer {key}"
headers["X-API-Key"] = key
payload = {
"symbol": symbol,
@ -116,7 +116,7 @@ def run_with_systemr_risk_gate(
entry_price: Optional[float] = None,
stop_price: Optional[float] = None,
config: Optional[dict] = None,
) -> Tuple[str, str, dict]:
) -> Tuple[str, dict, dict]:
"""Run TradingAgents and validate the result through System R.
Args:
@ -132,7 +132,7 @@ def run_with_systemr_risk_gate(
Tuple of (final_decision, full_signal, systemr_response).
"""
# 1. Run the standard TradingAgents pipeline
cfg = config or DEFAULT_CONFIG.copy()
cfg = {**DEFAULT_CONFIG, **(config or {})}
ta = TradingAgentsGraph(debug=False, config=cfg)
full_signal, decision = ta.propagate(ticker, trade_date)