How trading APIs let AI agents trade across markets
A plain-language step-by-step explainer of how trading APIs work for AI agents, from non-custodial keys to normalized order sizing across five market types.
- 01A trading API for AI agents is a single, normalized interface that lets autonomous programs trade across stocks, crypto, perps, options, and prediction markets without taking custody of your funds.
- 02The owner controls funds through a scoped key that limits what the agent can do, and the infrastructure enforces budget caps, position limits, and a panic switch server-side.
- 03Orders are sized in plain US dollars, and the API handles venue-specific contract math so the agent can manage cross-market portfolios without learning each instrument’s native units.
- 04Developers connect via MCP tools for LLM-based agents or the REST API for headless scripts, and the exact request schema is documented at /docs.
- 05Paper trading lets you test integration and strategy logic with live data but simulated fills, while live trading requires explicit owner authorization and can lose money, including everything.
A trading API for AI agents is a single interface that lets an autonomous program read market data, place orders, and manage positions across stocks, crypto, perps, options, and prediction markets without ever taking custody of your funds. The owner keeps control of the wallet, sets spending limits and allowed actions, and can revoke access at any time. The agent receives a scoped key that only permits trading within those boundaries, so it can execute a strategy but cannot withdraw funds or exceed its budget.
What does a trading API for agents actually do?
Traditional trading interfaces are built for human clicks. An agentic API is different. It accepts instructions from code, translates them into venue-specific actions, and reports back in a normalized format. The goal is to let the agent focus on strategy while the API handles market mechanics. One API for every market means the agent does not need separate integrations for a stock broker, a perps venue, an options venue, a crypto exchange, and a prediction market. Instead, the agent sends a single type of order object, and the API routes it to the correct venue, handles authentication, normalizes responses, and abstracts away idiosyncratic rules like rate limits, session tokens, or order type names. The agent sees one data model for positions, balances, and orders, regardless of what is being traded. This reduces integration complexity and limits the surface area where a bug can leak into live execution. The API also bundles both market data and execution. The agent can query real-time prices, historical bars, and account state through the same interface it uses to trade. Execution is atomic from the agent’s perspective: it sends an intent, the API validates that intent against the owner’s guardrails, translates it into venue-specific instructions, and sends it to the market. If the venue rejects the order, the API returns a normalized error. If the order fills, the API translates the fill back into the unified model. This means the agent’s reasoning loop can be market agnostic. An agent designed to rebalance a portfolio can rebalance across stocks and crypto without code changes, because it reasons in dollars and percentages rather than in shares, satoshis, or contract sizes.
How does the agent connect without taking custody?
The architecture is non-custodial by construction. Funds remain in a wallet that the owner controls, typically through standard private key infrastructure or a secure signer. The owner generates a scoped key for the agent and defines exactly what that key can do. How an AI agent executes orders while you keep full custody explains the full flow, but the short version is that the agent key can initiate trades and read balances, yet it cannot change withdrawal addresses, move funds to unauthorized destinations, or revoke the owner’s own access. Withdrawal addresses are owner-approved only. If the agent is compromised, the attacker can only trade within the pre-set limits, not steal the underlying capital. This is a structural guarantee, not a policy promise. The API provider cannot move the funds either. Because the wallet is under the owner’s control, the provider acts as a routing layer, not a custodian. The scoped key is a credential that the agent holds in its environment. If the agent is an LLM using MCP, the MCP server typically holds the key on the user’s local machine, not in the model provider’s cloud. If the agent is a headless script, the key lives in that script’s environment. In both cases, the key is useless outside the API’s infrastructure, and the infrastructure will reject any request that violates the scope. The owner can rotate or revoke the key at any time, which instantly severs the agent’s access without needing to change passwords on five different exchanges.
What safety controls limit what the agent can do?
Before the agent runs, the owner configures guardrails. How to build guardrails for a trading agent covers this in depth, but the essential categories are budget caps, position limits, exit plans, and a panic switch. A budget cap sets the maximum notional or loss the agent can incur over a given period. A position limit restricts how large any single position can become. An exit plan defines conditions under which the agent must flatten and stop. The panic or kill switch is a manual override that immediately cancels open orders, closes positions, and revokes the agent’s key. A practical checklist for non-custodial AI trading can help you verify that each control is configured correctly before you authorize live trading. These constraints are enforced by the infrastructure, not by the agent’s own code, so a bug or adversarial prompt cannot simply turn them off. The checks happen server-side before the API forwards an order to the venue. If an agent tries to submit an order that exceeds its position limit, the API rejects it and returns an error. If the agent’s accumulated loss hits the daily budget cap, the API refuses further orders until the owner resets or extends the cap. The owner also receives alerts when the agent approaches limits, so a human can intervene before a boundary is reached. This layered approach means the agent has enough freedom to execute a strategy, but not enough freedom to cause catastrophic damage.
How does order sizing work across five market types?
Different instruments use different native units. Stocks trade in shares. Crypto trades in decimals. Perpetual futures use contract sizes that may not match the underlying spot price. Options use multipliers and strike denominations. Prediction markets often use share prices between zero and one dollar. A human trader learns each convention, but an agent should not need to. The API accepts order sizes in plain US dollars and normalizes the venue-specific contract math internally. When the agent decides to allocate one hundred dollars to an asset, it sends that dollar amount, and the API translates it into the correct number of shares, contracts, or tokens. This removes an entire class of sizing errors, such as accidental ten-thousand-contract orders caused by a decimal place mistake. It also lets the agent reason about portfolio allocation in a single currency, which simplifies risk management and reporting. Suppose an agent wants to buy one hundred dollars worth of a perpetual future. The contract might be worth five dollars per point, and the API converts the one hundred dollars into the correct number of contracts. Imagine the same agent wants to buy one hundred dollars of an option with a multiplier of one hundred. The API calculates the appropriate number of contracts without the agent needing to know the multiplier. This normalization extends to margin. The API can report buying power and margin usage in dollars, even though the underlying venue uses its own margin currency. The agent can see that it has two thousand dollars of buying power, allocate five hundred to stocks, five hundred to perps, and keep the rest in cash, without understanding each venue’s margin formulas. This makes cross-market portfolio management practical for an autonomous system.
What does a basic integration look like?
Developers connect agents through MCP tools or the REST API. MCP is useful when the agent is running inside Claude, Cursor, or another MCP client that needs to discover available actions. The REST API is useful for headless agents running on a server. In either case, the pattern is the same: authenticate with the scoped key, read normalized market data, submit an order in dollar terms, and poll or stream for fills. The agent can also query positions and balances in the same normalized format. For MCP users, the client exposes tools like place_order or get_portfolio that the LLM can call. The agent does not need to know whether the backend is talking to a stock broker or a perps venue. It simply calls the tool and receives a structured result. For REST users, the agent is typically a script or service that runs a loop: fetch signals, check current state, compute desired trades, submit orders, sleep, repeat. The exact request schema is in the docs; the shape looks like this.
{
"key": "YOUR_KEY",
"market": "example-market",
"side": "buy",
"dollar_amount": 100,
"time_in_force": "day"
}The response returns a normalized order object with status, fill details, and remaining amount. The developer does not need to parse venue-specific error codes or handle margin calculations directly. This abstraction means you can switch venues or add new markets without rewriting the agent’s core logic. If you later decide to trade prediction markets alongside stocks, the agent’s code changes very little, because the interface remains the same.
How do you move from paper trading to live markets?
Every new strategy should start in paper trading. The paper environment uses live market data but simulates fills and tracks a fake balance. This lets you observe how the agent behaves when it sees real prices, gaps, and slippage, without risking capital. Paper trading tests three things at once: the integration between your agent and the API, the correctness of your guardrails, and the logic of the strategy itself. Common pitfalls become visible here. Paper fills often assume mid-market prices, while live fills incur slippage. Paper latency is idealized, whereas live routing adds real milliseconds. A paper environment may not reject orders that a live venue would reject for margin reasons. When the owner is satisfied that the agent respects its guardrails and executes the intended logic, they can explicitly authorize the scoped key for live trading. This authorization step is deliberate; it requires a separate action from the owner, not just a code change. Once live, the agent operates under the same controls it had in paper mode, but now its orders result in real positions and real profit or loss. It is important to remember that trading can lose money, including everything. Automated trading can amplify mistakes quickly. A loop error or misinterpreted signal can generate many orders in seconds. The guardrails exist to contain this, but they cannot guarantee profitability. Start with small size, monitor the first sessions closely, and keep the panic switch within reach.
Frequently asked questions
No. Withdrawal addresses are owner-approved only, and the scoped key cannot move funds to unauthorized destinations. The agent can trade within its limits, but it cannot steal the underlying capital.
The API rejects further orders until the owner resets or extends the cap. The existing positions remain open unless the exit plan or the owner says otherwise.
No. The API accepts orders in plain US dollars and normalizes venue-specific contract math internally. The agent reasons in dollars, not in shares or multipliers.
Yes. You can create multiple scoped keys, each with its own limits and market permissions. One agent can be live while another remains in paper mode.
Use the panic or kill switch. It cancels open orders, flattens positions, and revokes the agent’s key in one action. The owner can also revoke the key manually at any time.
No. Paper trading uses live data but simulated fills. Slippage, latency, and margin checks differ from live markets. It is a useful test, but not a guarantee of live performance.
Give your agent a key.
One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.
Reading an order book is not the same as understanding it. In 2026, the gap between raw market data and what an AI agent actually comprehends remains the most underestimated risk in automated trading.
Algorithmic traders do not need to hand over custody to automate strategies. Self-custodial infrastructure lets an agent trade within scoped limits while you retain control of the funds.