Skip to main content
Glama

flatten_positions

Close every open position using opposite-side market orders, optionally filtered by symbol. Use to flatten an account or end-of-day close; defaults to dry-run for safety.

Instructions

Close every open position with opposite-side market orders, optionally filtered by symbol. Default dry_run=true. Use for 'close everything' operator actions or end-of-day flatten. account is required and gated the same way as place_order: paper scope may only target paper-prefixed accounts, and rows the positions accessor tags with a different account are skipped.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolNoRestrict to one symbol; omit to flatten all.
accountYesAccount whose positions to flatten. paper-prefixed names are allowed in paper scope; live scope is required for any other.
dry_runNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.10.0
    • addedInput schema / properties / account
      Added value: +{
      +  "description": "Account whose positions to flatten. paper-prefixed names are allowed in paper scope; live scope is required for any other.",
      +  "type": "string"
      +}
    • addedInput schema / required
      Added value: +[
      +  "account"
      +]
  2. First observedv0.6.3

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the behavioral burden and largely delivers: it discloses the dry_run default, the paper/live account gating rule inherited from place_order, and that mismatched-account rows are skipped. It stops short of explaining what dry_run=true versus false returns or the side effects of a live flatten, so it is not a 5.

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

Conciseness5/5

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

The description is compact and front-loaded: purpose first, then default behavior, then when-to-use and constraints. Every sentence carries information, with no repetition of schema details.

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

Completeness4/5

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

For a simple flatten action it covers the core invocation concerns: what it does, when to use it, required-account constraints, filtering, and dry-run default. It lacks output/error behavior, but there is no output schema and the tool is simple enough that this is a minor gap.

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?

The schema already documents symbol and account, and the description adds meaning beyond it: dry_run defaults to true, account is required with the same gating as place_order, and mismatched rows are skipped. The uncovered dry_run parameter therefore gets useful context.

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

Purpose4/5

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

The opening sentence is specific: 'Close every open position with opposite-side market orders, optionally filtered by symbol' names the verb, the resource (positions), and the mechanism. It is clear enough that an agent will not confuse it with pure order-cancellation tools, though it does not explicitly name a sibling alternative.

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

Usage Guidelines4/5

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

It explicitly states when to use the tool: 'Use for ‘close everything’ operator actions or end-of-day flatten.' It does not list alternatives or when-not-to-use cases, but the ‘close everything’ framing provides a clear selection signal.

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