INNER CODE UNIT · Python
_reconcile_position_state
qrak/LLM_trader · src/app.py:443
async def _reconcile_position_state(self, source: str) -> LocalPositionReconciliation | None:
"""Run the strategy's public reconciliation hook (no-op when not wired).
The hook books a validated exchange-side exit exactly once; an unwired or
non-conforming strategy is left untouched (a test double must not decide the
trading state).
"""
hook = getattr(self.trading_strategy, "reconcile_local_position", None)
if not callable(hook):
return None
try:
pending = hook(source=source)
if not inspect.isawaitable(pending):
return None
outcome = await pending
except Exception as e: # noqa: BLE001
self.logger.warning("Position reconciliation (%s) failed: %s", source, e)
return None