from __future__ import annotations

from typing import Any, Protocol

from backend.data.contracts import DataSource, ProviderResult


class ProviderError(RuntimeError):
    pass


class MarketDataProvider(Protocol):
    source: DataSource

    @property
    def configured(self) -> bool: ...

    def calendar(self, start_date: str, end_date: str) -> ProviderResult: ...

    def entities(self) -> ProviderResult: ...

    def daily(self, entity_type: str, identifier: str, end_date: str) -> ProviderResult: ...

    def minute(self, entity_type: str, identifier: str, trade_date: str) -> ProviderResult: ...

    def snapshot_inputs(
        self, trade_date: str, previous_trade_date: str
    ) -> dict[str, ProviderResult | dict[str, Any]]: ...

    def realtime_market_inputs(
        self,
        trade_date: str,
        previous_trade_date: str,
        identifiers: tuple[str, ...],
    ) -> dict[str, ProviderResult | dict[str, Any]]: ...

    def sector_members(self, representative: str, trade_date: str) -> ProviderResult: ...

    def heaven_inputs(
        self, representative: str, trade_date: str
    ) -> dict[str, ProviderResult | None]: ...

    def heaven_realtime_inputs(
        self, representative: str, trade_date: str, previous_trade_date: str
    ) -> dict[str, ProviderResult | None]: ...

    def market_insight(
        self,
        kind: str,
        trade_date: str,
        previous_trade_date: str = "",
        identifier: str = "",
    ) -> dict[str, ProviderResult | None]: ...

    def realtime_snapshots(
        self, identifiers: tuple[str, ...], start_time: str, end_time: str
    ) -> ProviderResult: ...

    def event_reasons(self, trade_date: str) -> ProviderResult: ...

    def screener_inputs(self, trade_dates: tuple[str, ...]) -> dict[str, ProviderResult | None]: ...
