"""Protocol-based store interfaces for pyfortis."""

from __future__ import annotations

from typing import Any, Protocol, runtime_checkable

from pyfortis._types import BreachRecord, Exposure, Position


@runtime_checkable
class PositionStore(Protocol):
    def get_positions(self, portfolio: str = "default") -> dict[str, Position]: ...
    def save_position(self, position: Position) -> None: ...
    def save_positions(self, positions: list[Position]) -> None: ...
    def delete_position(self, instrument: str, portfolio: str = "default") -> None: ...


@runtime_checkable
class AsyncPositionStore(Protocol):
    async def get_positions(self, portfolio: str = "default") -> dict[str, Position]: ...
    async def save_position(self, position: Position) -> None: ...
    async def save_positions(self, positions: list[Position]) -> None: ...
    async def delete_position(self, instrument: str, portfolio: str = "default") -> None: ...


@runtime_checkable
class BreachStore(Protocol):
    def save_breach(self, breach: BreachRecord) -> None: ...
    def save_breaches(self, breaches: list[BreachRecord]) -> None: ...
    def get_breaches(
        self, *, limit: int = 100, **filters: Any
    ) -> list[BreachRecord]: ...


@runtime_checkable
class AsyncBreachStore(Protocol):
    async def save_breach(self, breach: BreachRecord) -> None: ...
    async def save_breaches(self, breaches: list[BreachRecord]) -> None: ...
    async def get_breaches(
        self, *, limit: int = 100, **filters: Any
    ) -> list[BreachRecord]: ...


@runtime_checkable
class ExposureStore(Protocol):
    def get_exposures(self, portfolio: str = "default") -> dict[str, Exposure]: ...
    def save_exposures(self, exposures: dict[str, Exposure]) -> None: ...
