fix(coherence): Add all trading enums aligned with DDL (E-COH-002, ST1.4)

- Extended src/types/trading.types.ts with all DDL trading enums
- Added OrderType, OrderSide, OrderStatus enums
- Added PositionStatus enum (open, closed, liquidated)
- Added SignalType enum (entry_long, entry_short, exit_long, exit_short, hold)
- Added ConfidenceLevel enum (low, medium, high, very_high)
- Added Timeframe enum (1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M)
- Added BotType enum (paper, live, backtest)
- Added BotStatus enum (active, paused, stopped, error)
- Deprecated old Interval type in favor of Timeframe

All types now aligned with trading.* enums from DDL schema and backend types.
Replaces hardcoded string literals with proper enum definitions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Adrian Flores Cortes 2026-01-26 17:07:28 -06:00
parent c18459558f
commit e204853398

View File

@ -1,14 +1,118 @@
/**
* Trading Types
* Type definitions for trading features
* Aligned with trading.* DDL schema (apps/database/ddl/schemas/trading/00-enums.sql)
*/
import { Time } from 'lightweight-charts';
// ============================================================================
// Trading Enums (Aligned with DDL)
// ============================================================================
// Alineado con trading.order_type (DDL)
export type OrderType = 'market' | 'limit' | 'stop' | 'stop_limit' | 'trailing_stop';
export enum OrderTypeEnum {
MARKET = 'market',
LIMIT = 'limit',
STOP = 'stop',
STOP_LIMIT = 'stop_limit',
TRAILING_STOP = 'trailing_stop',
}
// Alineado con trading.order_side (DDL)
export type OrderSide = 'buy' | 'sell';
export enum OrderSideEnum {
BUY = 'buy',
SELL = 'sell',
}
// Alineado con trading.order_status (DDL)
export type OrderStatus = 'pending' | 'open' | 'partially_filled' | 'filled' | 'cancelled' | 'rejected' | 'expired';
export enum OrderStatusEnum {
PENDING = 'pending',
OPEN = 'open',
PARTIALLY_FILLED = 'partially_filled',
FILLED = 'filled',
CANCELLED = 'cancelled',
REJECTED = 'rejected',
EXPIRED = 'expired',
}
// Alineado con trading.position_status (DDL)
export type PositionStatus = 'open' | 'closed' | 'liquidated';
export enum PositionStatusEnum {
OPEN = 'open',
CLOSED = 'closed',
LIQUIDATED = 'liquidated',
}
// Alineado con trading.signal_type (DDL)
export type SignalType = 'entry_long' | 'entry_short' | 'exit_long' | 'exit_short' | 'hold';
export enum SignalTypeEnum {
ENTRY_LONG = 'entry_long',
ENTRY_SHORT = 'entry_short',
EXIT_LONG = 'exit_long',
EXIT_SHORT = 'exit_short',
HOLD = 'hold',
}
// Alineado con trading.confidence_level (DDL)
export type ConfidenceLevel = 'low' | 'medium' | 'high' | 'very_high';
export enum ConfidenceLevelEnum {
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
VERY_HIGH = 'very_high',
}
// Alineado con trading.timeframe (DDL)
export type Timeframe = '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d' | '1w' | '1M';
export enum TimeframeEnum {
ONE_MINUTE = '1m',
FIVE_MINUTES = '5m',
FIFTEEN_MINUTES = '15m',
THIRTY_MINUTES = '30m',
ONE_HOUR = '1h',
FOUR_HOURS = '4h',
ONE_DAY = '1d',
ONE_WEEK = '1w',
ONE_MONTH = '1M',
}
// Alineado con trading.bot_type (DDL)
export type BotType = 'paper' | 'live' | 'backtest';
export enum BotTypeEnum {
PAPER = 'paper',
LIVE = 'live',
BACKTEST = 'backtest',
}
// Alineado con trading.bot_status (DDL)
export type BotStatus = 'active' | 'paused' | 'stopped' | 'error';
export enum BotStatusEnum {
ACTIVE = 'active',
PAUSED = 'paused',
STOPPED = 'stopped',
ERROR = 'error',
}
// ============================================================================
// Market Data Types
// ============================================================================
/**
* @deprecated Use Timeframe instead for DDL alignment
*/
export type Interval = '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d' | '1w';
export interface Candle {