Skip to main content
Glama
bartest5

Alpaca MCP Server

by bartest5

replace_order_by_id

Modify an existing open order by updating parameters such as quantity, limit price, or time in force. At least one optional field must be provided to execute the replacement.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qtyNonumber of shares to trade. You can only patch full shares for now. Qty of equity fractional orders are not allowed to change. Non-IPO notional orders cannot be replaced at all - no fields (qty, limit_price, stop_price, etc.) can be modified; cancel and resubmit instead.
trailNothe new value of the trail_price or trail_percent value (works only for type="trailing_stop")
notionalNoNew notional (dollar amount) for the order. Only valid for IPO indications of interest (`asset_class: "ipo"`); will be rejected for any other asset class. Mutually exclusive with `qty` on the same replace request.
order_idYesorder id
stop_priceNorequired if original order type is limit or stop_limit
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.
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.
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?

No annotations are provided, so the description must fully disclose behavior. It states the action ('Replaces') and a constraint, but does not disclose side effects (e.g., whether the original order is canceled, permissions required, or error conditions). The rich parameter descriptions in the schema carry behavioral details, but the tool description itself is insufficient 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 entire description is two short sentences, no filler, and front-loads the core action. This is efficient and well-structured.

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?

For a tool with 9 parameters, nested objects, and a complex domain, the description is minimal. It identifies the core purpose and a validation rule, but doesn't contextualize the tool's place among order management operations or surface high-level restrictions (like the non-IPO notional exception) that are only buried in parameter descriptions. With such a rich schema, this is passable but not fully complete.

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?

The schema has 100% description coverage for all 9 parameters, including detailed constraints for qty, notional, and limit_price. The description adds only the general rule that at least one optional field must be provided, which is useful but not parameter-specific. Baseline 3 applies because the schema does the heavy lifting.

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 uses a specific verb ('Replaces') with a clear resource ('existing open order') and scope ('with updated parameters'). It distinguishes from sibling tools like place_stock_order (create) and cancel_order_by_id (cancel), though it doesn't explicitly name them.

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 context (existing open order) and a validation rule (at least one optional field), but it does not explicitly contrast with alternatives such as cancel-and-resubmit or mention when replacement is not allowed (e.g., non-IPO notional orders). This is minimal guidance, not comprehensive.

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/bartest5/alpacahq_alpaca-mcp-server'

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