import type { ExchangeBalance, ExchangePosition } from "./exchanges/index.js"; export interface RiskLimits { maxDrawdownUsd: number; maxPositionUsd: number; maxTotalExposureUsd: number; dailyLossLimitUsd: number; maxPositions: number; maxLeverage: number; maxMarginUtilization: number; minLiquidationDistance: number; maxDrawdownPct?: number; maxPositionPct?: number; maxExposurePct?: number; dailyLossPct?: number; } /** Resolve effective USD limit: min of fixed USD and pct-of-equity (if both set) */ export declare function effectiveLimit(usdLimit: number, pctLimit: number | undefined, totalEquity: number): number; export declare function loadRiskLimits(): RiskLimits; export declare function saveRiskLimits(limits: RiskLimits): void; export type RiskLevel = "low" | "medium" | "high" | "critical"; export interface RiskViolation { rule: string; severity: RiskLevel; message: string; current: number; limit: number; } export interface LiquidationDistanceInfo { exchange: string; symbol: string; side: "long" | "short"; markPrice: number; liquidationPrice: number; distancePct: number; status: "safe" | "warning" | "danger" | "critical"; } /** Calculate % distance from current price to liquidation price */ export declare function calcLiquidationDistance(markPrice: number, liquidationPrice: number, side: "long" | "short"): number; export declare function getLiquidationDistances(positions: { exchange: string; position: ExchangePosition; }[], limits?: RiskLimits): LiquidationDistanceInfo[]; export interface RiskAssessment { level: RiskLevel; violations: RiskViolation[]; metrics: { totalEquity: number; totalUnrealizedPnl: number; totalMarginUsed: number; totalExposure: number; positionCount: number; marginUtilization: number; largestPositionUsd: number; maxLeverageUsed: number; minLiquidationDistancePct: number; }; liquidationDistances: LiquidationDistanceInfo[]; limits: RiskLimits; canTrade: boolean; } export declare function assessRisk(balances: { exchange: string; balance: ExchangeBalance; }[], positions: { exchange: string; position: ExchangePosition; }[], limits?: RiskLimits): RiskAssessment; /** Pre-trade check: would this new order violate risk limits? */ export declare function preTradeCheck(assessment: RiskAssessment, newOrderNotional: number, newOrderLeverage: number): { allowed: boolean; reason?: string; };