trading-platform-database-v2/ddl/schemas/trading/00-enums.sql
Adrian Flores Cortes 86112cf73a [REMEDIATION] fix: Update trading enums and price_alerts table DDL
Add missing enum values to trading schema and refactor price_alerts table
structure to align with backend types. Addresses DDL gaps from analysis.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:17:19 -06:00

130 lines
2.9 KiB
SQL

-- ============================================================================
-- 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';
-- Tipo de alerta de precio
CREATE TYPE trading.alert_type AS ENUM (
'price_above',
'price_below',
'percent_change',
'volume_spike'
);
COMMENT ON TYPE trading.alert_type IS 'Types of price alerts: above/below threshold, percent change, volume spike';
-- Estado de alerta de precio
CREATE TYPE trading.alert_status AS ENUM (
'active',
'triggered',
'expired',
'cancelled'
);
COMMENT ON TYPE trading.alert_status IS 'Status of price alerts: active, triggered, expired, cancelled';