Skip to main content
Glama

Size a position by risk

size_position
Read-onlyIdempotent

Turns "risk 1% of equity, stop 2% below" into a size in the base coin, rounded down to the venue step and capped by every limit; reads equity, price and contract rules itself. Use before preview_order. Not an order: preview and execute after it. Give the stop once and the amount once (see the inputs). Example: {"symbol": "BTC", "side": "buy", "stop_distance_pct": 0.02, "risk_pct_of_equity": 0.01}. Next: preview_order with preview_args from the result.

Input Schema

NameRequiredDescriptionDefault
sideYesbuy = long, sell = short
venueNoVenue: sandbox, hyperliquid, okx, bybit or binance. Omitted: the agent's only venue, else hyperliquid if connected, else your only connected exchange, else the sandboxhyperliquid
symbolYesBase coin, e.g. BTC
stop_lossNoThe stop as a price, USD per coin: below entry for a long, above for a short. Or give stop_distance_pct
entry_priceNoPlanned entry, USD per coin (a limit or trigger price); omitted: the mark
notional_usdNoOr the position's value in USD ("buy $200 worth"), instead of risk_pct_of_equity; still capped by the risk limits
stop_distance_pctNoThe stop as a distance from entry, a fraction of the price (0.02 = 2% away), instead of stop_loss
risk_pct_of_equityNoHow much of equity to lose if the stop fills (0.01 = 1%). Omit it and notional_usd for the most your limits allow

Output Schema

NameRequiredDescriptionDefault
sideYesbuy (long) or sell (short)
venueYesVenue name
symbolYesBase coin
risk_usdYesLoss if the stop fills, USD
capped_byYesWhich limit made the size smaller than asked, if any
size_baseYesSuggested size, in the base coin (e.g. BTC), not USD, rounded down to the venue's size step; pass it to preview_order as size_base
stop_lossYesStop-loss used, USD per coin
equity_usdYesEquity used for the calculation (the venue's book), USD
deprecationNoPresent only while this tool is deprecated: replacement, removal_date, changelog
entry_priceYesEntry used, USD per coin (the mark when not given)
notional_usdYessize_base x entry, USD
preview_argsYesThe arguments for preview_order with this size: symbol, side, size_base, stop_loss, venue and leverage (5, or less where a limit says so); add price and order_type for a limit order
within_limitsYesFalse if even the capped size cannot pass (e.g. below the venue minimum)
risk_pct_of_equityYesrisk_usd / equity, as a fraction

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.7/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotent and non-destructive, and the description reinforces that it places no order. It adds genuinely new behavioral detail beyond the annotations: rounding down to the venue step, capping by every limit, and self-fetching equity, price and contract rules. It stops short of describing failure behavior (wrong-side stop, insufficient equity, venue mismatch), which keeps it from 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?

Front-loaded with the core transformation, then the ordering constraint, then the input-uniqueness rule, then a compact example. Every clause carries operational information; nothing is redundant padding.

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 an eight-parameter, anyOf-constrained sizing tool this covers the essentials: what it computes, what it reads, what caps apply, what it is not, and the exact next call. Since an output schema exists, it correctly avoids explaining return values while still pointing at preview_args from 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 coverage is 100%, so baseline would be 3, but the description adds real meaning: stop_loss and stop_distance_pct are alternatives (give one), and risk_pct_of_equity versus notional_usd are alternatives, with omission defaulting to the maximum the limits allow. The worked example JSON anchors the units for stop_distance_pct and risk_pct_of_equity.

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 precise transformation: risk percentage plus stop distance becomes a base-coin size, rounded down to the venue step and capped by limits. This is a specific verb+resource that cannot be confused with siblings like preview_order or get_my_risk_limits, and it names what it reads internally (equity, price, contract rules).

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 sequencing: use before preview_order, then preview and execute afterwards, with preview_args from the result as the handoff. It also warns that this is not an order and instructs the caller to supply the stop once and the amount once, which prevents the most likely misuse.

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.

Resources