"""bridge/connectors/base.py — Abstract base class for all broker connectors."""

from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Any


class ConnectorBase(ABC):
    """Unified broker interface. All connectors must implement these 7 methods."""

    @abstractmethod
    def get_price(self, symbol: str) -> dict[str, Any]:
        """Return live price: {bid, ask, spread, timestamp}."""
        ...

    @abstractmethod
    def place_order(self, symbol: str, side: str, volume: float,
                    sl: float = 0.0, tp: float = 0.0) -> dict[str, Any]:
        """Place an order. Returns {ticket, status, error}."""
        ...

    @abstractmethod
    def get_positions(self) -> list[dict[str, Any]]:
        """Return all open positions: [{ticket, symbol, side, volume, entry, sl, tp, profit}]."""
        ...

    @abstractmethod
    def get_account(self) -> dict[str, Any]:
        """Return account info: {balance, equity, margin, margin_free, currency}."""
        ...

    @abstractmethod
    def get_bars(self, symbol: str, timeframe: str, count: int) -> list[dict[str, Any]]:
        """Return historical bars: [{open, high, low, close, volume, time}]."""
        ...

    @abstractmethod
    def is_connected(self) -> bool:
        """Check if broker connection is alive."""
        ...

    @abstractmethod
    def get_symbols(self) -> list[dict[str, Any]]:
        """Return available symbols: [{name, pip_value, lot_step, min_lot, max_lot}]."""
        ...
