import { Candle } from './candle.interface';
import { TimeFrame, WorkingEnv } from './common.interface';
import { GeneticSchema, ConfigValidator, StatsValidator } from './genetic.interface';
import { Order } from './order.interface';
import { PluginInterface } from './plugin.interface';
import { Connector, ConnectorType, MarketType } from './connector.interface';
import { InspectorTradeSettingsConfig } from './inspector.interface';
import { Subscription, Instrument, Provider, Advisor, PluginMeta, DetectorStrategyDefinition } from '.';
export type DetectorConfig = {
    apiPort: number;
    sysName: string;
    defaultSysName?: string;
    multiEnabled?: boolean;
    instances?: DetectorInstanceConfig[];
    strategyDefinitions?: DetectorStrategyDefinition[];
    path: string;
    logLevel: string;
};
export type DetectorInstanceRouteConfig = {
    connectorType?: ConnectorType;
    marketType?: MarketType;
    symbols?: string[];
};
export type DetectorInstanceConfig = {
    sysName: string;
    enabled: boolean;
    route?: DetectorInstanceRouteConfig;
    loaderSysName?: string;
    options?: Partial<Detector>;
};
export type DetectorPluginConfig = {
    modules: any[];
    metas: PluginMeta[];
};
export type DetectorModuleConfig = DetectorConfig & {
    plugins?: DetectorPluginConfig;
};
export interface DetectorQualityGateConfig {
    enabled?: boolean;
    minClosedTrades?: number;
    minWinRate?: number;
    minAvgRr?: number;
    maxConsecutiveLosses?: number;
    cooldownMs?: number;
}
export interface DetectorPerformanceConfig {
    enabled?: boolean;
    writeToQuestDb?: boolean;
    questTableTrades?: string;
    questTableSummary?: string;
}
/**
 * Interface representing the configuration options for a detector.
 */
export interface Detector {
    /**
     * A unique key for the detector.
     */
    key: string;
    /**
     * Stable UUID for UI studio (generated by provider at app registration).
     */
    studioKey?: string;
    sysname: string;
    logLevel: string;
    currency: string;
    useNotifications: {
        telegram: {
            token: string;
            chatId: string;
            messageFormat: string;
            isActive: boolean;
        };
    };
    advisor: Advisor;
    /**
     * The base API URL used by the detector.
     */
    restApiUrl: string;
    /**
     * List of connector configurations.
     */
    providers: Provider[];
    /**
     * Port number used for the inspector API.
     */
    /**
     * Optional system name for the detector.
     */
    detectorSysname?: string;
    /**
     * Array of symbols the detector will operate on.
     */
    instruments: Instrument[];
    /**
     * Array of active orders associated with the detector.
     */
    orders: Order[];
    /**
     * Array of time frames the detector will use.
     */
    intervals: TimeFrame[];
    /**
     * Configuration for indicators used by the detector.
     */
    indicators: Indicator[];
    /**
     * Optional plugins configuration for the detector.
     */
    plugins?: {
        modules: any[];
        metas: PluginMeta[];
    };
    /**
     * Indicates if the detector operates in sandbox mode.
     */
    useSandbox: boolean;
    /**
     * Indicates if the detector should start from scratch.
     */
    useScratch: boolean;
    /**
     * Indicates if the detector is blocked.
     */
    isBlocked?: boolean;
    /**
     * Indicates if the detector is currently active.
     */
    isActive?: boolean;
    subscriptions: Subscription[];
    tradeSettings?: InspectorTradeSettingsConfig;
    qualityGate?: DetectorQualityGateConfig;
    performance?: DetectorPerformanceConfig;
    customConfig?: Record<string, any>;
    preloadHistory?: boolean;
}
export interface Indicator {
    /** Optional key to store/read this indicator in the group. If omitted, key is derived from name+period (e.g. sma7, rsi14). */
    key?: string;
    name: string;
    parameters: IndicatorParameters;
    visual: IndicatorVisual;
}
export interface IndicatorParameters {
    period: number;
    source: string | {
        peak: string;
        trough: string;
    };
    overboughtLevel?: number;
    oversoldLevel?: number;
}
export interface IndicatorVisual {
    group?: string;
    paneSysName: string;
}
/**
 * Interface for metadata used in genetic algorithms and strategy creation.
 */
export interface Meta {
    /**
     * Parameters for the genetic algorithm.
     */
    parameters: GeneticSchema;
    /**
     * Function to calculate a score for the detector.
     * @param detector - The detector to score.
     * @returns The calculated score.
     */
    score: (detector: Detector) => number;
    /**
     * Function to retrieve statistics for the detector.
     * @param detector - The detector to analyze.
     * @returns The statistics for the detector.
     */
    stats: (detector: Detector) => unknown;
    /**
     * Function to create a new detector instance.
     * @param provider - The connector provider for the detector.
     * @param cfg - The configuration options for the detector.
     * @param env - The working environment for the detector.
     * @returns A Promise resolving to the created detector.
     */
    create: (provider: Connector, cfg: Detector, env: WorkingEnv) => Promise<Detector>;
    /**
     * Optional function to validate the detector configuration.
     */
    validate?: ConfigValidator;
    /**
     * Optional function to validate the detector's statistics.
     */
    validateStats?: StatsValidator;
    /**
     * Optional filter function for ticks.
     * @param solution - The detector options to filter.
     * @returns A function that filters ticks.
     */
    ticksFilter?: (solution: Detector) => (tick: Candle) => boolean;
    /**
     * Function to retrieve plugins for testing purposes.
     * @param cfg - The detector configuration.
     * @returns An array of test plugins.
     */
    testPlugins?: (cfg: Detector) => PluginInterface[];
    /**
     * Function to retrieve plugins for genetic algorithms.
     * @param cfg - The detector configuration.
     * @returns An array of genetic plugins.
     */
    geneticPlugins?: (cfg: Detector) => PluginInterface[];
}
/**
 * Runtime status of detector for API responses.
 * - active: registered and sending heartbeats, isActive=true
 * - disabled: registered but isActive=false
 * - blocked: isBlocked=true
 * - offline: not sending heartbeats (process down or not registered)
 */
export type DetectorStatus = 'active' | 'disabled' | 'blocked' | 'offline';
/**
 * Detector item as returned by GET /api/detectors (list).
 * Same as Detector with added status field from provider.
 */
export type DetectorListItem = Detector & {
    status: DetectorStatus;
};
/**
 * Interface representing a snapshot of the detector's state.
 */
export interface SnapshotData {
    /**
     * Array of orders in the detector's state.
     */
    orders: Array<Order>;
    /**
     * The detector's options at the time of the snapshot.
     */
    options: Detector;
    /**
     * Plugin-specific data for the snapshot.
     */
    pluginsData: Record<string, Record<string, unknown>>;
}
export declare enum DetectorEventType {
    SERVICE_STARTED = "SERVICE_STARTED",
    SERVICE_STOPPED = "SERVICE_STOPPED",
    DETECTOR_INITIALIZED = "DETECTOR_INITIALIZED",
    DETECTOR_STARTED = "DETECTOR_STARTED",
    DETECTOR_STOPPED = "DETECTOR_STOPPED",
    ERROR_OCCURRED = "ERROR_OCCURRED",
    RESTART_ATTEMPT = "RESTART_ATTEMPT",
    TICK_RECEIVED = "TICK_RECEIVED",
    CANDLE_UPDATED = "CANDLE_UPDATED",
    ORDERBOOK_UPDATED = "ORDERBOOK_UPDATED",
    MARKET_SNAPSHOT = "MARKET_SNAPSHOT",
    CONNECTION_LOST = "CONNECTION_LOST",
    CONNECTION_RESTORED = "CONNECTION_RESTORED",
    ENTRY_SIGNAL = "ENTRY_SIGNAL",
    EXIT_SIGNAL = "EXIT_SIGNAL",
    NO_ACTION = "NO_ACTION",
    CONDITION_EVALUATED = "CONDITION_EVALUATED",
    ORDER_PLACED = "ORDER_PLACED",
    ORDER_FILLED = "ORDER_FILLED",
    ORDER_PARTIALLY_FILLED = "ORDER_PARTIALLY_FILLED",
    ORDER_CANCELED = "ORDER_CANCELED",
    ORDER_REJECTED = "ORDER_REJECTED",
    POSITION_OPENED = "POSITION_OPENED",
    POSITION_CLOSED = "POSITION_CLOSED",
    RISK_TRIGGERED = "RISK_TRIGGERED",
    PNL_UPDATED = "PNL_UPDATED",
    BALANCE_UPDATED = "BALANCE_UPDATED",
    LEVERAGE_SET = "LEVERAGE_SET",
    RISK_ADJUSTED = "RISK_ADJUSTED",
    INDICATOR_UPDATED = "INDICATOR_UPDATED",
    PERFORMANCE_SNAPSHOT = "PERFORMANCE_SNAPSHOT",
    QUALITY_GATE_STATE = "QUALITY_GATE_STATE",
    RISK_CONTEXT_UPDATED = "RISK_CONTEXT_UPDATED",
    DECISION_CONTEXT_UPDATED = "DECISION_CONTEXT_UPDATED",
    HEALTH_CHECK_FAILED = "HEALTH_CHECK_FAILED",
    WEBHOOK_RECEIVED = "WEBHOOK_RECEIVED",
    CONFIG_UPDATED = "CONFIG_UPDATED",
    MOCK_EVENT = "MOCK_EVENT"
}
export type DetectorEventCategory = 'system' | 'market_data' | 'signals' | 'orders' | 'metrics' | 'infrastructure';
export declare const DetectorEventGroups: Record<DetectorEventCategory, DetectorEventType[]>;
//# sourceMappingURL=detector.interface.d.ts.map