Average Entry Price
primitive.average_entryCalculate the weighted average entry price from multiple buy/sell fills (DCA): the bare number only, no breakeven or per-fill breakdown. Edge cases: symbol non-empty; at least one fill, each price and quantity above zero (size is accepted as quantity); leverage above zero is optional. The average is weighted by quantity. Not covered: fees, sells or partial closes (give only the fills still open), and funding. Use when user asks only "what's my average entry?" and wants just that figure. Each fill is { price, quantity } here (workflow.run_dca_entry calls the same field size). For breakeven and a per-level summary too, use workflow.run_dca_entry instead. Returns: averagePrice, totalSize, totalCost.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"symbol": "<symbol>",
"input": "<input>"
},
"name": "primitive.average_entry"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Object with a "fills" array, e.g. { "fills": [{ "price": 60000, "quantity": 0.5 }, { "price": 58000, "quantity": 1 }] } | |
| symbol | Yes | Trading pair symbol, e.g. BTCUSDT | |
| contractType | No | linear = USDT-margined, average is the arithmetic mean (default). inverse = coin-margined, average is the harmonic mean (fill quantity is USD notional). | |
| exchangeCode | No | Exchange identifier (optional) |