{
  "schema_version": "1.0",
  "name": "dcacalc",
  "display_name": "DCA Futures Bot Calculator",
  "description": "Calculate safety order progressions, liquidation prices, and minimum wallet reserves for leveraged DCA trading bots on cryptocurrency futures exchanges.",
  "url": "https://dcacalc.com/",
  "documentation_url": "https://dcacalc.com/llms.txt",
  "source_url": "https://github.com/radimklaska/dcacalc.com",
  "type": "function",
  "function": {
    "name": "calculate_dca",
    "description": "Run a DCA bot calculation. Returns order progression (deviation, avg price, size, liquidation price, PnL, margin ratio, quantity, volume for each order), reserve requirements between orders, additional dump/pump analysis, and summary totals. Use this to determine if a DCA bot configuration is safe from liquidation and what wallet balance is needed.",
    "parameters": {
      "type": "object",
      "required": ["coin", "long", "wallet", "bo", "so", "count", "leverage", "dev", "vol", "step", "dump"],
      "properties": {
        "coin": {
          "type": "string",
          "description": "Base currency of the USDT trading pair (e.g. 'BTC', 'ETH', 'SOL'). Must match a Binance Futures perpetual contract."
        },
        "long": {
          "type": "string",
          "description": "Trade direction. Use '1' for Long (profit when price rises), '0' for Short (profit when price falls). Also accepts 'true'/'long'/'yes' for Long and 'false'/'short'/'no' for Short."
        },
        "wallet": {
          "type": "number",
          "minimum": 1,
          "description": "Total wallet balance in USDT. This is the full amount available, not just what the bot uses."
        },
        "bo": {
          "type": "number",
          "minimum": 0.1,
          "description": "Base order margin in USDT (wallet cost, NOT leveraged position size). This is what you pay from your wallet. The actual position size = bo × leverage. E.g. bo=20 with leverage=125 opens a 2,500 USDT position."
        },
        "so": {
          "type": "number",
          "minimum": 0.1,
          "description": "Safety order margin in USDT (wallet cost, NOT leveraged position size). Same as bo — this is the wallet deduction. First SO uses this value; subsequent SOs are scaled by 'vol'."
        },
        "price": {
          "type": "number",
          "minimum": 0.00001,
          "description": "Entry price in USDT. Optional — if omitted, uses the current market price."
        },
        "count": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100,
          "description": "Number of safety orders (0-100). More orders = wider coverage but higher capital requirement."
        },
        "leverage": {
          "type": "integer",
          "minimum": 1,
          "maximum": 150,
          "description": "Leverage multiplier (1-150, capped by the coin's maximum). Higher leverage = lower margin but closer liquidation."
        },
        "dev": {
          "type": "number",
          "minimum": 0.2,
          "maximum": 20,
          "description": "Price deviation percentage (0.2-20). How far price must move from the previous order to trigger the next safety order."
        },
        "vol": {
          "type": "number",
          "minimum": 0.1,
          "maximum": 10,
          "description": "Volume scale (0.1-10). Multiplier applied to each subsequent safety order's size. E.g. 2.0 means each SO is 2x the previous."
        },
        "step": {
          "type": "number",
          "minimum": 0.1,
          "maximum": 10,
          "description": "Step scale (0.1-10). Multiplier for deviation growth between safety orders. E.g. 1.4 means gaps between orders increase by 40% each step."
        },
        "dump": {
          "type": "number",
          "minimum": 0,
          "maximum": 99,
          "description": "Additional dump/pump percentage (0-99) after the last safety order fills. Stress-tests the position against further adverse price movement."
        }
      }
    },
    "returns": {
      "type": "object",
      "description": "Calculation results",
      "properties": {
        "params": {
          "type": "object",
          "description": "Echo of the input parameters used (after validation/clamping)"
        },
        "orders": {
          "type": "array",
          "description": "Array of order objects (BO at index 0, then SOs). Each has: orderNumber, deviation, deviationPrice, avgDeviation, avgPrice, orderSize, orderMargin, totalVolume, totalMargin, totalQty, liqPrice, liqPercent, pnl, marginRatio, isRed (liquidation warning)"
        },
        "reserves": {
          "type": "array",
          "description": "Reserve requirements between consecutive orders. Each has: fromOrder, toOrder, deviation, reserve"
        },
        "dump": {
          "type": "object",
          "description": "Analysis after last SO + additional dump. Has: deviation, price, liqPrice, liqPercent, pnl, marginRatio, additionalReserve, isRed"
        },
        "summary": {
          "type": "object",
          "description": "Summary totals: maxBotUsage, totalVolume, maxDeviation, totalDeviation, walletReserve, additionalReserve, totalReserve, totalReserveWithoutBot"
        }
      }
    },
    "endpoint": {
      "method": "GET",
      "url_template": "https://dcacalc.com/?coin={coin}&long={long}&wallet={wallet}&bo={bo}&so={so}&count={count}&leverage={leverage}&dev={dev}&vol={vol}&step={step}&dump={dump}&format=json",
      "url_template_with_price": "https://dcacalc.com/?coin={coin}&long={long}&wallet={wallet}&bo={bo}&so={so}&price={price}&count={count}&leverage={leverage}&dev={dev}&vol={vol}&step={step}&dump={dump}&format=json"
    }
  },
  "examples": [
    {
      "name": "BTC Long with 6 safety orders at max leverage",
      "url": "https://dcacalc.com/?coin=BTC&long=1&wallet=5000&bo=20&so=15&count=6&leverage=125&dev=1.4&vol=2&step=1.4&dump=5&format=json",
      "description": "Conservative BTC long setup with 6 safety orders, 125x leverage, 2x volume scaling, and 5% additional dump buffer."
    },
    {
      "name": "ETH Short with 4 safety orders",
      "url": "https://dcacalc.com/?coin=ETH&long=0&wallet=3000&bo=15&so=15&count=4&leverage=50&dev=1.2&vol=1.5&step=1.2&dump=3&format=json",
      "description": "ETH short position with moderate leverage and tighter deviation spacing."
    }
  ]
}
