import type { Candle } from '../../connectors/types.js';
export type { Candle };

export enum SignalDirection {
    BUY = 'BUY',
    SELL = 'SELL',
    NONE = 'NONE'
}

export interface MarketContext {
    // Candles
    symbol: string;
    candles4h: Candle[];
    candles1h: Candle[];
    candles15m: Candle[];

    // Core Indicators (Pre-calculated for efficiency)
    ema20_1h?: number;
    ema50_1h?: number;
    ema50_4h?: number;
    ema200_4h?: number;
    rsi_1h?: number;

    // 15m Indicators (Phase 2)
    ema20_15m?: number;
    rsi_15m?: number;

    // Current State
    currentPrice: number;
    change24h: number;
    changeToday: number;
    session: string;
    isMajorSession: boolean;
    volatility: string;
    latestSignal: SignalDirection;
}

export interface RuleResult {
    ruleName: string;
    passed: boolean; // Did this rule allow the trade?
    signal?: SignalDirection; // Does this rule suggest a direction?
    reason?: string; // Human-readable explanation (e.g., "RSI is 28 (Oversold)")
    metadata?: any; // Extra data (e.g., calculated risk size)
}

export interface IRule {
    name: string;
    isEnabled(): boolean;
    check(context: MarketContext, params?: Record<string, any>): Promise<RuleResult>;
}
