-- ============================================================================
-- Schema: trading
-- File: 00-enums.sql
-- Description: Enumeraciones para el módulo de trading
-- Dependencies: None
-- ============================================================================

-- Tipo de orden
CREATE TYPE trading.order_type AS ENUM (
  'market',
  'limit',
  'stop',
  'stop_limit',
  'trailing_stop'
);

-- Estado de orden (CON 'partially_filled' que faltaba!)
CREATE TYPE trading.order_status AS ENUM (
  'pending',
  'open',
  'partially_filled',  -- AGREGADO - faltaba en análisis
  'filled',
  'cancelled',
  'rejected',
  'expired'
);

-- Lado de la orden
CREATE TYPE trading.order_side AS ENUM (
  'buy',
  'sell'
);

-- Estado de posición
CREATE TYPE trading.position_status AS ENUM (
  'open',
  'closed',
  'liquidated'
);

-- Tipo de señal (interfaz con ML)
CREATE TYPE trading.signal_type AS ENUM (
  'entry_long',
  'entry_short',
  'exit_long',
  'exit_short',
  'hold'
);

-- Nivel de confianza
CREATE TYPE trading.confidence_level AS ENUM (
  'low',
  'medium',
  'high',
  'very_high'
);

-- ============================================================================
-- DEPRECATED: Use public.trading_timeframe instead
-- This enum is maintained for backwards compatibility only.
-- Migration: migrations/2026-02-03_unify_timeframe_enum.sql
-- Task: ST-2.1 - Unificar enum timeframe en schema publico
-- Date: 2026-02-03
-- ============================================================================
-- Timeframes soportados
CREATE TYPE trading.timeframe AS ENUM (
  '1m', '5m', '15m', '30m',
  '1h', '4h',
  '1d', '1w', '1M'
);

-- Tipo de bot
CREATE TYPE trading.bot_type AS ENUM (
  'paper',      -- Paper trading (simulación)
  'live',       -- Trading real
  'backtest'    -- Backtesting
);

-- Estado de bot
CREATE TYPE trading.bot_status AS ENUM (
  'active',
  'paused',
  'stopped',
  'error'
);

-- Drawing tool types for chart annotations
CREATE TYPE trading.drawing_tool_type AS ENUM (
    'trend_line',
    'horizontal_line',
    'vertical_line',
    'ray',
    'extended_line',
    'parallel_channel',
    'fibonacci_retracement',
    'fibonacci_extension',
    'rectangle',
    'ellipse',
    'triangle',
    'arrow',
    'text',
    'price_range',
    'date_range',
    'order_block',
    'fair_value_gap',
    'liquidity_level'
);

COMMENT ON TYPE trading.drawing_tool_type IS 'Types of drawing tools available on charts';
