Skip to main content
Glama

close_position

Destructive

Close a coin's open perpetual position immediately with a reduce-only market order, either fully or by a specified fraction. Full closes cancel the attached stop and target; partial closes keep them.

Instructions

LIVE MONEY: acts on the real account. Close a coin's open position now with one reduce-only market order. Omit fraction (or pass 1) to close it all: the stop and target are then cancelled. fraction between 0 and 1 closes that share (0.5 = half) and keeps the stop and target, which still cover what is left; a share worth under the venue's $10 minimum closes $10 worth. Like any market order it pays the spread and slippage of the book. A flat coin returns ok=true with noop already_flat and sends nothing; closes are never refused for a delisted coin. Afterwards run sweep_brackets on the coin. Use when the user asks to exit now, fully or in part; to exit at a price instead, move the level with set_stop or set_target. Needs a trading key. Returns {closed, result: {total_sz, avg_px, partial, fraction}} or {error} with isError true; a fraction outside (0, 1] is refused with nothing sent.

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": {
      "coin": "<coin>"
    },
    "name": "close_position"
  }
}

Input Schema

NameRequiredDescriptionDefault
coinYesCoin: a main-dex perp by name (BTC, ETH) or a HIP-3 perp as dex:SYMBOL (xyz:GOLD, xyz:BRENTOIL).
fractionNoShare of the position to close, e.g. 0.5 for half. Omit to close it all.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.7.2
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / fraction
      Added value: +{
      +  "description": "Share of the position to close, e.g. 0.5 for half. Omit to close it all.",
      +  "exclusiveMinimum": 0,
      +  "maximum": 1,
      +  "type": "number"
      +}
  2. Changed1 schema field changedv0.6.1
    • changedInput schema / properties / coin / description
      Previous value: -"Coin ticker (e.g. BTC, ETH)"New value: +"Coin: a main-dex perp by name (BTC, ETH) or a HIP-3 perp as dex:SYMBOL (xyz:GOLD, xyz:BRENTOIL)."
  3. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only flag destructiveHint=true; the description goes far beyond that, disclosing real-money execution, reduce-only market order mechanics, spread/slippage cost, stop-and-target cancellation when closing fully, sub-$10 minimum handling, flat-position noop behavior, and that delisted coins are still closable. This is exactly the behavioral context an agent needs before a destructive trade.

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 'LIVE MONEY' so the risk warning lands first, and most sentences carry unique information. It is dense and slightly long, but nearly every clause (cancellation semantics, minimum clip, error shape) is load-bearing rather than filler.

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?

There is no output schema, yet the description still sketches the return payload ({closed, result: {total_sz, avg_px, partial, fraction}} or {error} with isError true). Combined with the stop/target and minimum-notional edge cases, nothing material is missing for a two-parameter destructive tool.

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 coverage is 100%, so the baseline is 3, but the description adds real meaning: omitting fraction or passing 1 cancels stop/target, a value in (0,1) keeps them for the remainder, and a sub-$10 share clips to $10. It also documents rejection of out-of-range fractions with nothing sent, which the schema's numeric bounds do not convey behaviorally.

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: 'Close a coin's open position now with one reduce-only market order.' It also distinguishes itself from the price-level siblings by naming set_stop and set_target as the exit-at-a-price path.

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?

Gives explicit when-to-use ('user asks to exit now, fully or in part') and an alternative for the opposite case ('to exit at a price instead, move the level with set_stop or set_target'). It also names the prerequisite ('needs a trading key') and the required follow-up ('run sweep_brackets on the coin').

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