# app/src/market_data/acquisition/service.py

from __future__ import annotations

from src.market_data.acquisition.models.candle import Candle
from src.market_data.acquisition.models.instrument import Instrument
from src.market_data.acquisition.models.quote import Quote
from src.market_data.acquisition.registry import (
    CandlesFeedRegistry,
    InstrumentFeedRegistry,
    QuoteFeedRegistry,
)


class InstrumentAcquisitionService:
    def __init__(
        self,
        *,
        registry: InstrumentFeedRegistry,
    ) -> None:
        self._registry = registry

    def load_instruments(
        self,
        source_name: str,
    ) -> tuple[Instrument, ...]:
        feed = self._registry.get(source_name)

        return feed.load_instruments()


class QuoteAcquisitionService:
    def __init__(
        self,
        *,
        registry: QuoteFeedRegistry,
    ) -> None:
        self._registry = registry

    def load_quote(
        self,
        source_name: str,
        symbol: str,
    ) -> Quote:
        feed = self._registry.get(source_name)

        return feed.load_quote(symbol)


class CandlesAcquisitionService:
    def __init__(
        self,
        *,
        registry: CandlesFeedRegistry,
    ) -> None:
        self._registry = registry

    def load_candles(
        self,
        source_name: str,
        symbol: str,
        *,
        interval: str,
        limit: int,
        price_type: str,
    ) -> tuple[Candle, ...]:
        feed = self._registry.get(source_name)

        return feed.load_candles(
            symbol,
            interval=interval,
            limit=limit,
            price_type=price_type,
        )