Coverage for src/copytrading_engine/trading/application/ports.py: 100%
13 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-16 16:55 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-16 16:55 +0000
1"""Ports the trading use cases need from retained operational evidence."""
3import datetime as dt
4from pathlib import Path
5from typing import Protocol
7from copytrading_engine.execution.domain.events import JournalEvent
8from copytrading_engine.execution.domain.ledger_state import LedgerSnapshot
9from copytrading_engine.execution.domain.manual_commands import ManualSourceEvidence
10from copytrading_engine.execution.presentation.account_feed import AccountFeedPage
11from copytrading_engine.execution.presentation.operator_views import (
12 AccountEventPage,
13 AccountOverview,
14 DestinationView,
15)
16from copytrading_engine.shared.raw_message import RawMessage
17from copytrading_engine.shared.signals import Instruction
18from copytrading_engine.trading.presentation.operator_models import GuruPost, SourceActivityPage
21class ChannelHistory(Protocol):
22 """Recent text posts of one source channel, for learning a guru's style."""
24 async def recent_posts(
25 self, token: str, channel_id: str, author_id: str | None, limit: int
26 ) -> tuple[str, ...]: ...
29class OperatorEvidence(Protocol):
30 """Read committed source, parser, and account evidence without writing or binding."""
32 def source_page(
33 self,
34 database: Path,
35 *,
36 before_seq: int | None,
37 limit: int,
38 destinations: dict[str, tuple[DestinationView, ...]],
39 source_ids: tuple[str, ...] | None = None,
40 channel: tuple[str, str] | None = None,
41 channels: tuple[tuple[str, str], ...] | None = None,
42 ) -> SourceActivityPage: ...
44 def guru_posts(self, database: Path, *, since: dt.datetime) -> tuple[GuruPost, ...]: ...
46 def retained_account(
47 self, path: Path, *, before_seq: int | None = None, limit: int = 50
48 ) -> tuple[AccountOverview, LedgerSnapshot, AccountEventPage]: ...
50 def retained_feed(
51 self, path: Path, *, before_seq: int | None, limit: int
52 ) -> AccountFeedPage: ...
54 def retained_fills(self, path: Path) -> tuple[LedgerSnapshot, tuple[JournalEvent, ...]]: ...
56 def retained_message_events(
57 self, path: Path, message_ids: set[str]
58 ) -> tuple[JournalEvent, ...]: ...
60 def manual_source_evidence(self, database: Path, source_id: str) -> ManualSourceEvidence: ...
62 def record_owner_correction(
63 self,
64 database: Path,
65 source_id: str,
66 instructions: tuple[Instruction, ...],
67 at: dt.datetime,
68 ) -> None: ...
70 def historical_source_message(self, database: Path, source_id: str) -> RawMessage: ...
72 def delete_record(self, root: Path, account_id: str) -> str | None: ...