Catalog/trade-average-down

Calculators

Average-down cost basis API

Blended cost basis across fills: averagePrice = Σ(price·units)/Σunits (= the break-even price). Deterministic weighted-average math. Answers 'what's my average price after adding','blended cost basis for these fills','break-even after averaging down'.

Price$0.01per request
MethodPOST
Route/v1/calc/trade-average-down
StatusLive
MIME typeapplication/json
Rate limit120/minute
CacheNo cache
calctradingaverage-downcost-basisbreak-evendcafillsaccounting
API URLhttps://x402.hexl.dev/v1/calc/trade-average-down
Integration docs
Example request
{
  "fills": [
    {
      "price": 100,
      "units": 10
    },
    {
      "price": 80,
      "units": 10
    }
  ]
}
Example response
{
  "fills": 2,
  "totalUnits": 20,
  "totalCost": 1800,
  "averagePrice": 90,
  "breakEvenPrice": 90,
  "formula": "averagePrice = Σ(price·units) / Σ units"
}
Input schema
{
  "type": "object",
  "required": [
    "fills"
  ],
  "properties": {
    "fills": {
      "type": "array",
      "description": "Array of {price, units} fills.",
      "items": {
        "type": "object",
        "required": [
          "price",
          "units"
        ],
        "properties": {
          "price": {
            "type": "number"
          },
          "units": {
            "type": "number"
          }
        }
      },
      "examples": [
        [
          {
            "price": 100,
            "units": 10
          },
          {
            "price": 80,
            "units": 10
          }
        ]
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}