"""
Optopsy - Options Backtesting Library

Optopsy is a Python library for backtesting options trading strategies using
historical options chain data. It provides:

- 38 built-in options strategies (singles, spreads, ratio spreads, butterflies, condors, collars, calendars)
- Flexible filtering by DTE, delta targeting, bid-ask spread, and option Greeks
- Configurable slippage models (mid, spread, liquidity-based)
- Statistical analysis with aggregated performance metrics
- Raw trade data export for custom analysis

Example:
    >>> import optopsy as op
    >>> data = op.csv_data('./SPX_2018.csv')
    >>> results = op.long_calls(data, max_entry_dte=60, exit_dte=30)

For detailed documentation, visit: https://github.com/michaelchu/optopsy
"""

__version__ = "2.2.0"

from .datafeeds import csv_data
from .metrics import (
    calmar_ratio,
    compute_risk_metrics,
    conditional_value_at_risk,
    max_drawdown,
    max_drawdown_from_returns,
    omega_ratio,
    profit_factor,
    sharpe_ratio,
    sortino_ratio,
    tail_ratio,
    value_at_risk,
    win_rate,
)
from .signals import (
    Signal,
    ad_cross_above_sma,
    ad_cross_below_sma,
    adx_above,
    adx_below,
    alma_cross_above,
    alma_cross_below,
    and_signals,
    ao_above,
    ao_below,
    apply_signal,
    aroon_cross_above,
    aroon_cross_below,
    atr_above,
    atr_below,
    bb_above_upper,
    bb_below_lower,
    cci_above,
    cci_below,
    chop_above,
    chop_below,
    cmf_above,
    cmf_below,
    cmo_above,
    cmo_below,
    custom_signal,
    day_of_week,
    dema_cross_above,
    dema_cross_below,
    donchian_above_upper,
    donchian_below_lower,
    ema_cross_above,
    ema_cross_below,
    fisher_cross_above,
    fisher_cross_below,
    hma_cross_above,
    hma_cross_below,
    iv_rank_above,
    iv_rank_below,
    kama_cross_above,
    kama_cross_below,
    kc_above_upper,
    kc_below_lower,
    kst_cross_above,
    kst_cross_below,
    macd_cross_above,
    macd_cross_below,
    massi_above,
    massi_below,
    mfi_above,
    mfi_below,
    natr_above,
    natr_below,
    obv_cross_above_sma,
    obv_cross_below_sma,
    or_signals,
    ppo_cross_above,
    ppo_cross_below,
    psar_buy,
    psar_sell,
    roc_above,
    roc_below,
    rsi_above,
    rsi_below,
    signal,
    sma_above,
    sma_below,
    smi_cross_above,
    smi_cross_below,
    squeeze_off,
    squeeze_on,
    stoch_above,
    stoch_below,
    stochrsi_above,
    stochrsi_below,
    supertrend_buy,
    supertrend_sell,
    sustained,
    tema_cross_above,
    tema_cross_below,
    tsi_cross_above,
    tsi_cross_below,
    uo_above,
    uo_below,
    vhf_above,
    vhf_below,
    willr_above,
    willr_below,
    wma_cross_above,
    wma_cross_below,
    zlma_cross_above,
    zlma_cross_below,
)
from .simulator import PortfolioResult, SimulationResult, simulate, simulate_portfolio
from .strategies import (
    # Ratio spreads
    call_back_spread,
    call_front_spread,
    # Cash-secured put
    cash_secured_put,
    # Collar
    collar,
    # Covered strategies
    covered_call,
    iron_butterfly,
    # Iron condor and iron butterfly strategies
    iron_condor,
    # Butterfly strategies
    long_call_butterfly,
    # Calendar spread strategies
    long_call_calendar,
    # Condor strategies
    long_call_condor,
    # Diagonal spread strategies
    long_call_diagonal,
    long_call_spread,
    long_calls,
    long_put_butterfly,
    long_put_calendar,
    long_put_condor,
    long_put_diagonal,
    long_put_spread,
    long_puts,
    long_straddles,
    long_strangles,
    protective_put,
    put_back_spread,
    put_front_spread,
    reverse_iron_butterfly,
    reverse_iron_condor,
    short_call_butterfly,
    short_call_calendar,
    short_call_condor,
    short_call_diagonal,
    short_call_spread,
    short_calls,
    short_put_butterfly,
    short_put_calendar,
    short_put_condor,
    short_put_diagonal,
    short_put_spread,
    short_puts,
    short_straddles,
    short_strangles,
)
from .timestamps import normalize_dates
from .types import (
    CalendarStrategyParams,
    CalendarStrategyParamsDict,
    Commission,
    StrategyParams,
    StrategyParamsDict,
    TargetRange,
)

__all__ = [
    "__version__",
    "long_calls",
    "long_puts",
    "short_calls",
    "short_puts",
    "long_straddles",
    "short_straddles",
    "long_strangles",
    "short_strangles",
    "long_call_spread",
    "short_call_spread",
    "long_put_spread",
    "short_put_spread",
    # Butterfly strategies
    "long_call_butterfly",
    "short_call_butterfly",
    "long_put_butterfly",
    "short_put_butterfly",
    # Iron condor and iron butterfly strategies
    "iron_condor",
    "reverse_iron_condor",
    "iron_butterfly",
    "reverse_iron_butterfly",
    # Condor strategies
    "long_call_condor",
    "short_call_condor",
    "long_put_condor",
    "short_put_condor",
    # Covered, protective & collar
    "covered_call",
    "protective_put",
    "collar",
    "cash_secured_put",
    # Ratio spreads
    "call_back_spread",
    "put_back_spread",
    "call_front_spread",
    "put_front_spread",
    # Calendar spread strategies
    "long_call_calendar",
    "short_call_calendar",
    "long_put_calendar",
    "short_put_calendar",
    # Diagonal spread strategies
    "long_call_diagonal",
    "short_call_diagonal",
    "long_put_diagonal",
    "short_put_diagonal",
    "csv_data",
    # Type definitions
    "Commission",
    "StrategyParams",
    "StrategyParamsDict",
    "CalendarStrategyParams",
    "CalendarStrategyParamsDict",
    "TargetRange",
    # Signal functions — combinators & utilities
    "apply_signal",
    "and_signals",
    "or_signals",
    "sustained",
    "Signal",
    "signal",
    "custom_signal",
    # Signal functions — momentum
    "rsi_below",
    "rsi_above",
    "macd_cross_above",
    "macd_cross_below",
    "stoch_below",
    "stoch_above",
    "stochrsi_below",
    "stochrsi_above",
    "willr_below",
    "willr_above",
    "cci_below",
    "cci_above",
    "roc_above",
    "roc_below",
    "ppo_cross_above",
    "ppo_cross_below",
    "tsi_cross_above",
    "tsi_cross_below",
    "cmo_above",
    "cmo_below",
    "uo_above",
    "uo_below",
    "squeeze_on",
    "squeeze_off",
    "ao_above",
    "ao_below",
    "smi_cross_above",
    "smi_cross_below",
    "kst_cross_above",
    "kst_cross_below",
    "fisher_cross_above",
    "fisher_cross_below",
    # Signal functions — overlap / moving averages
    "sma_below",
    "sma_above",
    "ema_cross_above",
    "ema_cross_below",
    "dema_cross_above",
    "dema_cross_below",
    "tema_cross_above",
    "tema_cross_below",
    "hma_cross_above",
    "hma_cross_below",
    "kama_cross_above",
    "kama_cross_below",
    "wma_cross_above",
    "wma_cross_below",
    "zlma_cross_above",
    "zlma_cross_below",
    "alma_cross_above",
    "alma_cross_below",
    # Signal functions — volatility
    "atr_above",
    "atr_below",
    "bb_above_upper",
    "bb_below_lower",
    "kc_above_upper",
    "kc_below_lower",
    "donchian_above_upper",
    "donchian_below_lower",
    "natr_above",
    "natr_below",
    "massi_above",
    "massi_below",
    # Signal functions — trend
    "adx_above",
    "adx_below",
    "aroon_cross_above",
    "aroon_cross_below",
    "supertrend_buy",
    "supertrend_sell",
    "psar_buy",
    "psar_sell",
    "chop_above",
    "chop_below",
    "vhf_above",
    "vhf_below",
    # Signal functions — volume
    "mfi_above",
    "mfi_below",
    "obv_cross_above_sma",
    "obv_cross_below_sma",
    "cmf_above",
    "cmf_below",
    "ad_cross_above_sma",
    "ad_cross_below_sma",
    # Signal functions — IV rank
    "iv_rank_above",
    "iv_rank_below",
    # Signal functions — calendar
    "day_of_week",
    # Simulation
    "simulate",
    "simulate_portfolio",
    "SimulationResult",
    "PortfolioResult",
    # Risk metrics
    "compute_risk_metrics",
    "sharpe_ratio",
    "sortino_ratio",
    "max_drawdown",
    "max_drawdown_from_returns",
    "value_at_risk",
    "conditional_value_at_risk",
    "win_rate",
    "profit_factor",
    "calmar_ratio",
    "omega_ratio",
    "tail_ratio",
    # Timestamp utilities
    "normalize_dates",
]
