UPDATE paper_trades
SET leverage = 5
WHERE leverage IS NULL OR leverage <= 1;

UPDATE paper_trades
SET margin_usdt = COALESCE(notional_usdt, 0) / NULLIF(leverage, 0)
WHERE notional_usdt IS NOT NULL
  AND leverage IS NOT NULL
  AND leverage > 0
  AND (
    margin_usdt IS NULL
    OR margin_usdt <= 0
    OR margin_usdt >= notional_usdt
  );
