Skip to main content
Glama
alpacahq

alpaca-mcp-server

Official
by alpacahq

replace_order_by_id

Update an existing open order's parameters like quantity, price, or time-in-force to adjust trading strategies without canceling and re-submitting.

Instructions

Replaces an existing open order with updated parameters. At least one optional field must be provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_idYesorder id
qtyNonumber of shares to trade. You can only patch full shares for now. Qty of equity fractional/notional orders are not allowed to change.
time_in_forceNoThe Time-In-Force values supported by Alpaca vary based on the order's security type. Here is a breakdown of the supported TIFs for each specific security type: - Equity trading: day, gtc, opg, cls, ioc, fok. - Options trading: day. - Crypto trading: gtc, ioc. Below are the descriptions of each TIF: - day: A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours. - gtc: The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce (DNR) orders to opt out of such price adjustments. - opg: Use this TIF with a market/limit order type to submit “market on open” (MOO) and “limit on open” (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day’s opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange’s auction rules. - cls: Use this TIF with a market/limit order type to submit “market on close” (MOC) and “limit on close” (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day’s closing auction. Only available with API v2. - ioc: An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question. - fok: A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2.
limit_priceNoRequired if original order's `type` field was `limit` or `stop_limit`. In case of `mleg`, the limit_price parameter is expressed with the following notation: - A positive value indicates a debit, representing a cost or payment to be made. - A negative value signifies a credit, reflecting an amount to be received.
stop_priceNorequired if original order type is limit or stop_limit
trailNothe new value of the trail_price or trail_percent value (works only for type=“trailing_stop”)
client_order_idNoA unique identifier for the new order. Automatically generated if not sent. (<= 128 characters)
advanced_instructionsNoAdvanced instructions for Elite Smart Router: https://docs.alpaca.markets/docs/alpaca-elite-smart-router

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'replaces' an order, implying mutation, but doesn't clarify if this is destructive (e.g., overwrites existing order), requires specific permissions, has rate limits, or what happens on failure. The constraint 'At least one optional field must be provided' adds some context, but overall, it lacks details on safety, side effects, or response behavior, which is inadequate for a mutation tool.

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 extremely concise with two sentences that are front-loaded and waste no words. It directly states the purpose and a key constraint, making it easy to parse. Every sentence earns its place by providing essential information without redundancy.

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

Completeness3/5

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

Given the tool's complexity (8 parameters, nested objects, mutation operation) and the presence of an output schema (which handles return values), the description is minimally adequate. It covers the basic purpose and a constraint, but with no annotations and rich input schema, it should do more to explain behavioral aspects like error handling or idempotency. The output schema reduces the need for return value details, but the description lacks completeness for safe invocation.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly. The description adds minimal value beyond the schema by implying that optional fields are for updates, but it doesn't explain parameter interactions or provide additional semantics. Given the high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate with extra insights.

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 description clearly states the action ('Replaces an existing open order') and the resource ('order'), specifying it's for updates to parameters. It distinguishes from siblings like 'cancel_order_by_id' by focusing on modification rather than cancellation, though it doesn't explicitly name alternatives. The mention of 'open order' provides useful scope, but it could be more specific about what 'replaces' entails compared to other update tools.

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

Usage Guidelines3/5

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

The description implies usage by stating 'At least one optional field must be provided,' which suggests when to use it (for updating orders) but lacks explicit guidance on when to choose this over alternatives like 'place_stock_order' for new orders or 'cancel_order_by_id' for removal. It doesn't mention prerequisites (e.g., order must be open) or exclusions, leaving usage context somewhat vague.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/alpacahq/alpaca-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server