Skip to main content
Glama

TradingCalc MCP: Options, Forex, Risk Stats, Prediction Markets, On-Chain & Crypto Futures

Average Entry Price

primitive.average_entry
Read-only

Calculate 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

NameRequiredDescriptionDefault
inputYesObject with a "fills" array, e.g. { "fills": [{ "price": 60000, "quantity": 0.5 }, { "price": 58000, "quantity": 1 }] }
symbolYesTrading pair symbol, e.g. BTCUSDT
contractTypeNolinear = USDT-margined, average is the arithmetic mean (default). inverse = coin-margined, average is the harmonic mean (fill quantity is USD notional).
exchangeCodeNoExchange identifier (optional)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • changedInput schema / properties / input / properties / fills / items / properties / quantity / description
      Previous value: -"Fill quantity"New value: +"Fill quantity, required unless \"size\" is given (the same field)"
    • addedInput schema / properties / input / properties / fills / items / properties / size
      Added value: +{
      +  "description": "Same field as quantity",
      +  "type": "number"
      +}
    • changedInput schema / properties / input / properties / fills / items / required
      Previous value: -[
      -  "price",
      -  "quantity"
      -]New value: +[
      +  "price"
      +]
  2. Changed2 schema fields changed
    • addedInput schema / properties / input / description
      Added value: +"Object with a \"fills\" array, e.g. { \"fills\": [{ \"price\": 60000, \"quantity\": 0.5 }, { \"price\": 58000, \"quantity\": 1 }] }"
    • addedInput schema / properties / input / properties / fills / description
      Added value: +"Buy/sell fills to average, each with a price and a quantity (at least 1)"
  3. Changed1 schema field changed
    • addedInput schema / properties / contractType
      Added value: +{
      +  "description": "linear = USDT-margined, average is the arithmetic mean (default). inverse = coin-margined, average is the harmonic mean (fill quantity is USD notional).",
      +  "enum": [
      +    "linear",
      +    "inverse"
      +  ],
      +  "type": "string"
      +}
  4. Added

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only say read-only, non-destructive, closed-world; the description goes well beyond by listing validation preconditions (symbol non-empty, at least one fill, every price and quantity > 0) and the exact return fields (averagePrice, totalSize, totalCost). It also discloses the weighting rule and what the result deliberately omits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose, then constraints, exclusions, and the sibling alternative — nothing is redundant with the title. It is dense and briefly run-on in the edge-case clause, but nearly every sentence carries usable information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter primitive calculation tool with no output schema, the description supplies the return shape, input preconditions, weighting logic, and the workflow-level alternative — the information an agent needs to call it correctly and interpret the result.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is already 100%, so the baseline is 3; the description earns extra credit by clarifying the size/quantity aliasing ("size is accepted as quantity" and that workflow.run_dca_entry uses the same field) and by stating the returned totals, which the schema cannot. Minor confusion: it discusses an optional "leverage" input that does not appear in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Calculate the weighted average entry price from multiple buy/sell fills (DCA)") and immediately scopes it ("the bare number only, no breakeven or per-fill breakdown"). It also names the sibling it is not (workflow.run_dca_entry), so an agent can route without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to-use: "Use when user asks only 'what's my average entry?' and wants just that figure." Explicit alternative: "For breakeven and a per-level summary too, use workflow.run_dca_entry instead." Plus exclusions on what not to feed in (fees, sells or partial closes, funding).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.