67 production .py modules that the running PINK service imports but which were never committed: prod/bingx/ (HTTP client, market/user streams, journal, config), prod/clean_arch/ adapters/persistence/runtime/dita/dita_v2 production modules and their co-located tests. Rule going forward: every module imported by launch_dolphin_pink.py / pink_direct.py must appear in git ls-files. Excludes _backup dirs, __pycache__, and non-code files. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""Compatibility wrapper for the legacy policy engine namespace."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
from prod.clean_arch.dita.account import AccountProjection, AccountSnapshot
|
|
from prod.clean_arch.dita.contracts import DecisionConfig as PolicyConfig
|
|
from prod.clean_arch.dita.decision import DecisionEngine
|
|
from prod.clean_arch.dita.intent import IntentEngine
|
|
from prod.clean_arch.dita.trade import TradeExecutor
|
|
|
|
from .contracts import PolicyContext, PolicyPosition
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class PolicyContextWrapper:
|
|
"""Backward-compatible context alias for older callers."""
|
|
|
|
capital: float
|
|
open_positions: int = 0
|
|
trade_seq: int = 0
|
|
|
|
|
|
class PolicyEngine:
|
|
"""Legacy facade that now delegates to the DITA boundary."""
|
|
|
|
def __init__(self, config: Optional[PolicyConfig] = None):
|
|
self.config = config or PolicyConfig()
|
|
self.decision_engine = DecisionEngine(self.config)
|
|
self.intent_engine = IntentEngine(self.config)
|
|
self.trade_executor = TradeExecutor()
|
|
self.account = AccountProjection(
|
|
runtime_namespace="pink",
|
|
strategy_namespace="pink",
|
|
event_namespace="pink",
|
|
)
|
|
self.account.snapshot = AccountSnapshot(capital=25_000.0, equity=25_000.0)
|
|
|
|
def decide(self, snapshot, context: PolicyContext, position: Optional[PolicyPosition] = None):
|
|
decision = self.decision_engine.decide(snapshot, context, position)
|
|
return decision
|
|
|