ST-3.1: Course tags system - education.course_tags with slug, color, featured flag - education.course_tag_assignments (M:N) with auto usage_count - Seeds: 10 initial tags (forex, crypto, ICT, etc.) ST-3.2: Drawing tools for charts - Enum: trading.drawing_tool_type (18 types including ICT) - trading.drawing_tools with JSONB points and styles - trading.drawing_templates for reusable presets ST-3.3: Complete agent_executions - Added 10 columns: execution_time_ms, slippage, risk_score, etc. - 5 new performance indexes - Trigger for updated_at ST-3.4: ML composite indexes - 8 new composite/partial indexes for predictions - Optimized for symbol+timeframe+date queries - Partial indexes for high confidence and overlay display New files: 7 DDL, 2 migrations, 1 seed Modified: 3 existing DDL files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
110 lines
2.4 KiB
SQL
110 lines
2.4 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';
|