from abc import ABC, abstractmethod
from enum import Enum
from typing import Dict, Optional, cast
import pandas as pd  # type: ignore[import]

from pt_trading.results import BacktestResult
from pt_trading.trading_pair import TradingPair

NanoPerMin = 1e9


class PairsTradingFitMethod(ABC):
    TRADES_COLUMNS = [
        "time",
        "action",
        "symbol",
        "price",
        "disequilibrium",
        "scaled_disequilibrium",
        "pair",
    ]

    @abstractmethod
    def run_pair(
        self, config: Dict, pair: TradingPair, bt_result: BacktestResult
    ) -> Optional[pd.DataFrame]: ...

    @abstractmethod
    def reset(self) -> None: ...


class PairState(Enum):
    INITIAL = 1
    OPEN = 2
    CLOSED = 3
