INNER CODE UNIT · Python

_protection_snapshot

qrak/LLM_trader · src/app.py:554

    def _protection_snapshot(self) -> tuple[Any, Any] | None:
        """(stop_loss, take_profit) of the current position, or None without a contract."""
        snapshot_fn = getattr(self.trading_strategy, "protection_snapshot", None)
        if not callable(snapshot_fn):
            return None
        snapshot = snapshot_fn()
        return tuple(snapshot) if isinstance(snapshot, tuple) and len(snapshot) == 2 else None

    async def _protection_version(self) -> str | None:
        """Protection revision the executor reports, or None without that contract.

        Wave-5 requirement (3). The strategy's ``executor_protection_version`` asks the
        executor's ``/position`` for its ``protection_version`` (monotonic counter of
        protection changes; ``0`` = none observed, returned verbatim). An older executor
        without the field gives None, in which case the guard below stays inert (it
        never guesses a version). A strategy double / older strategy without the method
        also yields None — the guard must not fail a trading cycle over a missing hook.
        """

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…