import client from "prom-client";

export const registry = new client.Registry();

export const makerRatio = new client.Gauge({
  name: "maker_ratio",
  help: "Maker trade ratio (0-1)",
  labelNames: ["symbol"]
});

export const gridFillsPerMinute = new client.Gauge({
  name: "grid_fills_per_minute",
  help: "Grid strategy fills per minute",
  labelNames: ["symbol"]
});

export const gridSelfTradeRatio = new client.Gauge({
  name: "grid_self_trade_ratio",
  help: "Grid strategy self-trade ratio (0-1)",
  labelNames: ["symbol"]
});

export const deltaAbs = new client.Gauge({
  name: "delta_abs",
  help: "Absolute delta"
});

export const riskStatus = new client.Gauge({
  name: "risk_kill_switch_state",
  help: "Risk engine kill-switch state (0=running,1=halted)",
  labelNames: ["reason"]
});

export const riskDeltaAbs = new client.Gauge({
  name: "risk_delta_abs",
  help: "Risk engine delta abs snapshot"
});

export const riskHedgeFailures = new client.Gauge({
  name: "risk_hedge_failures",
  help: "Risk engine hedge failure count"
});

export const riskDataGapSeconds = new client.Gauge({
  name: "risk_data_gap_seconds",
  help: "Risk engine data gap seconds"
});

export const riskDrawdownPct = new client.Gauge({
  name: "risk_drawdown_pct",
  help: "Risk engine drawdown percentage"
});

export const gridStepBps = new client.Gauge({
  name: "grid_step_bps",
  help: "Current grid step size in basis points",
  labelNames: ["symbol"]
});

export const gridVolatilityBps = new client.Gauge({
  name: "grid_volatility_hourly_bps",
  help: "Hourly volatility estimate in bps",
  labelNames: ["symbol"]
});

export const gridPendingHedges = new client.Gauge({
  name: "grid_pending_hedges",
  help: "Number of pending hedge orders awaiting fills",
  labelNames: ["symbol"]
});

export const gridCurrentDelta = new client.Gauge({
  name: "grid_current_delta",
  help: "Current grid delta (base)",
  labelNames: ["symbol"]
});

registry.registerMetric(makerRatio);
registry.registerMetric(gridFillsPerMinute);
registry.registerMetric(gridSelfTradeRatio);
registry.registerMetric(deltaAbs);
registry.registerMetric(riskStatus);
registry.registerMetric(riskDeltaAbs);
registry.registerMetric(riskHedgeFailures);
registry.registerMetric(riskDataGapSeconds);
registry.registerMetric(riskDrawdownPct);
registry.registerMetric(gridStepBps);
registry.registerMetric(gridVolatilityBps);
registry.registerMetric(gridPendingHedges);
registry.registerMetric(gridCurrentDelta);

client.collectDefaultMetrics({ register: registry });
