export type Side = "buy" | "sell";
export type TIF = "GTC" | "IOC" | "FOK";

export interface Order {
  clientId: string;
  symbol: string;
  side: Side;
  px: number;
  sz: number;
  tif: TIF;
  postOnly?: boolean;
  accountId?: string;
}

export interface Fill {
  orderId: string;
  tradeId: string;
  symbol: string;
  side: Side;
  px: number;
  sz: number;
  fee: number;
  liquidity: "maker" | "taker";
  ts: number;
}

export interface PositionSnapshot {
  symbol: string;
  base: number;
  quote: number;
  entryPx?: number;
  ts: number;
  accountId?: string;
}

export interface BookLevel { px: number; sz: number; }
export interface OrderBook { bids: BookLevel[]; asks: BookLevel[]; ts: number; }

export interface RiskLimits {
  maxBaseAbs: number;
  maxNotionalAbs: number;
  maxOrderSz: number;
  killSwitchDrawdownPct: number;
}

export interface OrderBookUpdate {
  price: number;
  size: number;
}

export interface OrderBookDelta {
  bids?: OrderBookUpdate[];
  asks?: OrderBookUpdate[];
  seq?: number;
  ts?: number;
}

// Grid Trading Types
export interface GridLevel {
  index: number;            // 网格索引（正=卖单，负=买单）
  side: Side;
  px: number;
  sz: number;
  orderId?: string;
  filled: boolean;
  timestamp: number;
}

export interface GridConfig {
  symbol: string;
  gridStepBps: number;      // 网格间距（bps）
  gridRangeBps: number;     // 网格范围（bps）
  baseClipUsd: number;      // 单层订单大小（USD）
  maxLayers: number;        // 最大层数
  hedgeThresholdBase: number; // 对冲阈值（base asset）
}
