ST-2.1: Unify timeframe enum - Created ddl/00-global-types.sql with public.trading_timeframe - Marked trading.timeframe and market_data.timeframe as DEPRECATED ST-2.2: Resolve transaction_type conflict - Documented rename plan: financial.wallet_transaction_type - Documented rename plan: investment.investment_transaction_type - Added deprecation comments to both enums ST-2.3: Unify common functions - Created ddl/00-global-functions.sql with public.update_updated_at() - Marked schema-specific functions as DEPRECATED: - auth.update_updated_at() - education.update_updated_at_column() - financial.update_timestamp() - feature_flags.update_timestamp() Migrations created (not executed): - 2026-02-03_unify_timeframe_enum.sql - 2026-02-03_rename_transaction_type_enums.sql - 2026-02-03_unify_common_functions.sql Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
86 lines
1.9 KiB
SQL
86 lines
1.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'
|
|
);
|