"""AutoPilot autonomous trading engine module.

This module provides an autonomous background service that combines
geometric pattern recognition with NLP-based sentiment analysis
to generate trade signals.

Supported Patterns:
- Head and Shoulders (bullish/bearish)
- Double Top/Bottom
- Triple Top/Bottom
- Triangle patterns (Ascending, Descending, Symmetrical)
- Wedge patterns (Rising, Falling)
- Flag and Pennant patterns
- Candlestick patterns (Engulfing, Hammer, Doji, Stars, etc.)
- MA Crossovers (Golden Cross, Death Cross)
- Support/Resistance levels
- Harmonic patterns (ABCD)
- Gap patterns
"""

from .intelligent_autopilot import (
    IntelligentAutopilot,
    get_intelligent_autopilot,
    stop_all_autopilots,
)
from .market_analyzer import (
    MarketAnalyzer,
    MarketConditions,
    MarketRegime,
    get_market_analyzer,
)
from .strategy_selector import (
    StrategySelector,
    get_strategy_selector,
)
from .performance_tracker import (
    PerformanceTracker,
    get_performance_tracker,
)
from typing import Dict, Any

def get_autopilot_mode_info() -> Dict[str, Any]:
    """Get information about available autopilot modes.
    
    Returns:
        Dictionary with mode information including descriptions, capabilities, and tradeoffs
    """
    return {
        "modes": {
            "pattern": {
                "name": "Pattern-Based Autopilot",
                "description": "Detects technical chart patterns (Head & Shoulders, triangles, etc.) and combines with sentiment analysis",
                "how_it_works": "Rule-based logic - pattern + sentiment alignment = signal",
                "best_for": [
                    "Users who want transparency",
                    "Users who understand technical analysis",
                    "Users who prefer explainable decisions"
                ],
                "tradeoffs": {
                    "pros": [
                        "Transparent and explainable",
                        "No training data required",
                        "Fast and lightweight"
                    ],
                    "cons": [
                        "Less adaptive to market changes",
                        "Fixed decision rules"
                    ]
                },
                "features": [
                    "Pattern recognition (40+ patterns)",
                    "Sentiment analysis (FinBERT)",
                    "Real-time signal generation",
                    "Transparent decision logic"
                ],
                "requirements": {
                    "training_data": False,
                    "setup_complexity": "Low",
                    "resource_usage": "Low"
                }
            },
            "intelligent": {
                "name": "ML-Based Autopilot",
                "description": "Uses machine learning to select the best strategy based on current market conditions",
                "how_it_works": "ML model analyzes market conditions and selects optimal strategy from available strategies",
                "best_for": [
                    "Users who want adaptive, data-driven decisions",
                    "Users who don't need to understand every decision",
                    "Advanced users seeking optimization"
                ],
                "tradeoffs": {
                    "pros": [
                        "Adapts to market conditions",
                        "Learns from historical performance",
                        "Can optimize strategy selection"
                    ],
                    "cons": [
                        "Requires training data",
                        "Less transparent (black box)",
                        "More complex setup"
                    ]
                },
                "features": [
                    "ML-based strategy selection",
                    "Market condition analysis",
                    "Performance tracking",
                    "Auto-execution support"
                ],
                "requirements": {
                    "training_data": True,
                    "setup_complexity": "Medium",
                    "resource_usage": "Medium"
                }
            }
        },
        "comparison": {
            "transparency": {
                "pattern": "High - All decisions are explainable",
                "intelligent": "Low - ML model decisions are less transparent"
            },
            "adaptability": {
                "pattern": "Low - Fixed rules",
                "intelligent": "High - Learns and adapts"
            },
            "setup_time": {
                "pattern": "Immediate - No setup required",
                "intelligent": "Requires training data collection"
            },
            "resource_usage": {
                "pattern": "Low - Lightweight",
                "intelligent": "Medium - ML model overhead"
            }
        }
    }


__all__ = [
    "stop_all_autopilots",
    "IntelligentAutopilot",
    "get_intelligent_autopilot",
    "MarketAnalyzer",
    "MarketConditions",
    "MarketRegime",
    "get_market_analyzer",
    "StrategySelector",
    "get_strategy_selector",
    "PerformanceTracker",
    "get_performance_tracker",
    "get_autopilot_mode_info",
]
