fix(coherence): Add all trading enums aligned with DDL (E-COH-002, ST1.4)
- Extended src/modules/trading/types/order.types.ts with all DDL enums - Added OrderType with trailing_stop support - Added PositionStatus (open, closed, liquidated) - Added SignalType (entry_long, entry_short, exit_long, exit_short, hold) - Added ConfidenceLevel (low, medium, high, very_high) - Added Timeframe (1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M) - Added BotType (paper, live, backtest) - Added BotStatus (active, paused, stopped, error) All types now aligned with trading.* enums from DDL schema. Provides comprehensive type definitions for trading module. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
1be94f0c1f
commit
d73253130f
@ -2,21 +2,31 @@
|
|||||||
* Order Types
|
* Order Types
|
||||||
* ============
|
* ============
|
||||||
* Type definitions for trading orders
|
* Type definitions for trading orders
|
||||||
* Aligned with trading.orders DDL schema
|
* Aligned with trading.* DDL schema (apps/database/ddl/schemas/trading/00-enums.sql)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Alineado con trading.order_type (DDL)
|
||||||
|
export type OrderType = 'market' | 'limit' | 'stop' | 'stop_limit' | 'trailing_stop';
|
||||||
|
|
||||||
export enum OrderTypeEnum {
|
export enum OrderTypeEnum {
|
||||||
MARKET = 'market',
|
MARKET = 'market',
|
||||||
LIMIT = 'limit',
|
LIMIT = 'limit',
|
||||||
STOP = 'stop',
|
STOP = 'stop',
|
||||||
STOP_LIMIT = 'stop_limit',
|
STOP_LIMIT = 'stop_limit',
|
||||||
|
TRAILING_STOP = 'trailing_stop',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Alineado con trading.order_side (DDL)
|
||||||
|
export type OrderSide = 'buy' | 'sell';
|
||||||
|
|
||||||
export enum OrderSideEnum {
|
export enum OrderSideEnum {
|
||||||
BUY = 'buy',
|
BUY = 'buy',
|
||||||
SELL = 'sell',
|
SELL = 'sell',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Alineado con trading.order_status (DDL)
|
||||||
|
export type OrderStatus = 'pending' | 'open' | 'partially_filled' | 'filled' | 'cancelled' | 'rejected' | 'expired';
|
||||||
|
|
||||||
export enum OrderStatusEnum {
|
export enum OrderStatusEnum {
|
||||||
PENDING = 'pending',
|
PENDING = 'pending',
|
||||||
OPEN = 'open',
|
OPEN = 'open',
|
||||||
@ -27,6 +37,9 @@ export enum OrderStatusEnum {
|
|||||||
EXPIRED = 'expired',
|
EXPIRED = 'expired',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time In Force (not in DDL - application level)
|
||||||
|
export type TimeInForce = 'gtc' | 'ioc' | 'fok' | 'gtd';
|
||||||
|
|
||||||
export enum TimeInForceEnum {
|
export enum TimeInForceEnum {
|
||||||
GTC = 'gtc', // Good Till Cancelled
|
GTC = 'gtc', // Good Till Cancelled
|
||||||
IOC = 'ioc', // Immediate Or Cancel
|
IOC = 'ioc', // Immediate Or Cancel
|
||||||
@ -34,6 +47,70 @@ export enum TimeInForceEnum {
|
|||||||
GTD = 'gtd', // Good Till Date
|
GTD = 'gtd', // Good Till Date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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',
|
||||||
|
}
|
||||||
|
|
||||||
export interface Order {
|
export interface Order {
|
||||||
id: string;
|
id: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user