How developers manage multi-market portfolios with agents
Developers manage multi-market portfolios through one API using scoped keys, dollar-normalized sizing, and unified guardrails across all five supported market types.
- 01A single API can normalize orders across stocks, crypto, perps, options, and prediction markets into plain dollar amounts.
- 02Non-custodial scoped keys let an agent trade within limits without ever controlling withdrawals.
- 03Portfolio-level guardrails must aggregate exposure across all markets to prevent hidden correlation risk.
- 04Dollar-normalized sizing removes venue-specific contract math so the agent reasons about risk in one currency.
- 05Every live deployment needs a panic switch that flattens positions and revokes the key independently of the agent.
The goal is to let a single agent view and adjust positions across stocks, crypto, perpetual futures, options, and prediction markets as if they were one portfolio. Instead of managing separate accounts and APIs for each venue, the developer writes one integration that sees total exposure, available buying power, and open risk in a single currency. This removes the manual work of reconciling different margin systems, contract sizes, and settlement rules, and it lets the agent rebalance or hedge across asset classes automatically.
What does multi-market portfolio management mean for an agent?
A multi-market portfolio agent does not treat a stock broker, a crypto exchange, a perps venue, an options venue, and a prediction market as five separate problems. It treats them as one set of positions denominated in dollars, with each venue providing a different risk profile. The agent might hold a long stock position, hedge it with a short perp, fund the margin with a stablecoin balance, and use a prediction market position to express a view on an upcoming event. Trading can lose money, including the entire portfolio, so the agent must treat capital preservation as its primary constraint. Without this unified view, the agent can easily duplicate trades or over-leverage. Suppose the agent sees $10,000 at a stock broker and $10,000 at a crypto venue and treats them as independent budgets. It might deploy $8,000 to each, believing it is using 80 percent of its capital, when it is actually near 160 percent exposure. A single API surface prevents this by returning one buying-power number and one list of positions, no matter how many underlying venues are connected.
How does one API normalize five different market types?
Each market type speaks its own language. A stock broker uses share quantities. A perps venue uses notional value and leverage tiers. An options venue uses contracts, multipliers, and Greeks. A prediction market uses binary outcome shares. A crypto spot market uses base and quote assets. Writing custom adapters for each is tedious and error-prone, especially when the agent must compare risk across them. The API resolves this by accepting orders in plain US dollars and translating them into venue-specific instructions. If the agent wants $500 of exposure to an asset, it sends $500. The system handles the contract math, the margin requirements, and the minimum lot sizes. This means the agent’s logic can stay simple: it reasons about portfolio weights, target allocations, and risk budgets in a currency it understands, rather than in contracts, satoshis, or share counts.
The developer connects the agent through MCP tools or the REST API. The exact request schema is in the docs; the shape looks like this:
POST /v1/orders
Authorization: Bearer YOUR_KEY
Content-Type: application/json
{
"market": "perpetual_futures",
"asset": "example-asset",
"side": "buy",
"dollar_amount": 500,
"time_in_force": "gtc"
}The response returns the filled dollar amount, the average entry price, and the remaining buying power in the same normalized format. Whether the underlying venue is a perps venue or a stock broker, the agent parses the same fields. This uniformity is what makes cross-market rebalancing possible. Developers who want to see how rebalancing logic fits into the broader system can read our guide on how to build an AI portfolio rebalancing agent.
How should you size positions across markets?
Dollar-normalized sizing is the most important abstraction for multi-market agents. When every order is expressed in dollars, the agent can sum its total exposure in one line of logic. A $1,000 position in a stock and a $1,000 position in a perp are the same size from a portfolio perspective, even though the perp might require only $100 of margin. The agent should track notional exposure, not margin used, because a leveraged $1,000 position still moves like $1,000. The developer should also think about correlation. Suppose the agent holds a long position in a technology stock and a long position in a crypto asset that tends to move with technology stocks. The agent may think it is diversified because one position is at a stock broker and the other is at a crypto venue, but the underlying risk is concentrated. A simple correlation matrix, updated periodically, can help the agent reduce position sizes when two markets behave similarly. The API gives the agent the data; the developer must give it the logic to weigh that data.
Buying power is another area where normalization matters. A single API can return total available dollars across all venues, but the developer must remember that some of those dollars are locked as collateral. If the agent sees $5,000 available and uses $4,000 for an options spread, the remaining $1,000 might not be withdrawable immediately because the options venue holds it as margin. The agent should check both free buying power and total portfolio value before sizing new trades. Treating them as the same number leads to rejected orders or accidental overdrafts.
What guardrails matter when exposure spans multiple asset classes?
Guardrails for a multi-market agent must be portfolio-wide, not venue-specific. A budget cap that limits the agent to $5,000 at a perps venue is useless if the agent can also deploy $5,000 at an options venue and $5,000 at a stock broker. The developer should set a single global spend cap that sums all orders across all market types, and a global position limit that caps the total notional exposure in any one asset class or theme. A drawdown limit should also be global. If the agent loses 5 percent at the stock broker and 5 percent at the prediction market, the total portfolio is down roughly 10 percent. The kill switch should trigger on this combined figure. The exit plan should be unified: if the agent needs to reduce risk quickly, it should flatten the worst-performing positions first, regardless of which venue hosts them. Our guide on how to evaluate guardrails for a trading agent step by step covers the specific checks to run before going live.
Scoped keys are essential. The developer creates a key that can trade but cannot withdraw. Withdrawal addresses are owner-approved only, so even if the agent is compromised, it cannot send funds to an external wallet. The panic switch is a separate mechanism that the owner can trigger without the agent’s consent. It flattens positions and revokes the key. This is not a feature of the agent; it is a feature of the infrastructure. The agent should never be able to disable its own kill switch.
How do you keep custody while letting an agent rebalance?
Non-custodial design means the owner keeps the funds in a wallet they control. The agent receives a scoped API key that lets it place orders, read balances, and manage positions, but it cannot move the underlying capital to a new address. This is enforced by the infrastructure, not by the agent’s code. The developer does not need to write custom withdrawal protections because the system simply never grants that permission to the trading key. Rebalancing across five market types therefore does not require depositing funds into a black box. The owner connects each venue through the same wallet or account structure, authorizes the agent to trade within limits, and keeps the withdrawal keys offline. If the agent performs poorly, the owner revokes the key and the funds stay put. You can read more about how this works in our article on how scoped API keys let an agent trade without taking custody of your funds.
For rebalancing, the agent needs to know which venue holds which asset. The API exposes a unified positions list, but the developer may still want to add logic that prefers one venue over another for cost or latency reasons. For example, if the agent needs to reduce equity exposure, it might close the stock position first before touching a crypto hedge, simply because the stock broker offers faster settlement. These preferences belong in the agent’s strategy layer, not in the API layer. The API provides the tools; the developer provides the prioritization.
How do you move from paper to live execution?
Paper trading exists for exactly this reason. The developer can test multi-market logic, cross-venue buying power calculations, and global drawdown triggers without risking capital. Paper markets mirror the real venues in terms of order sizing, fee structures, and latency, so the agent behaves realistically. The developer should run the agent in paper mode long enough to see it handle a volatile day, a gap move, and a failed order at one venue while the others stay open. Live trading requires explicit owner authorization of a key. The developer should treat this as a deployment step, not a code change. The agent’s logic stays the same; only the key and the environment variable switch from paper to live. Before flipping the switch, the developer should verify that the global spend cap, the kill switch, and the exit plan are active. Our article on how to automate exit plans and take profits while keeping custody explains how to set these up so they run independently of the agent’s main loop.
After going live, the developer should monitor the agent’s logs for unexpected venue errors. A prediction market might reject an order for a different reason than a perps venue, and the agent must handle each gracefully without halting the entire portfolio. Retry logic should be conservative: if one venue is down, the agent should not double-trade at another to compensate. It should log the gap, alert the owner, and wait. Patience in automation is a safety feature, not a bug.
Frequently asked questions
Yes. The API presents all five market types through one integration, so the agent reads positions and sends orders in the same format for each. The developer writes one set of portfolio logic rather than separate adapters. The underlying venues remain distinct, but the agent does not need to know their individual contract rules.
The agent sends the notional dollar amount it wants exposed, and the API translates that into the correct contract size and margin for the perps venue. The agent sees $1,000 of risk whether it is in a spot crypto position or a leveraged perp. The developer should still track margin usage separately to avoid running out of collateral.
It should log the failure, skip the intended trade, and continue with the rest of the portfolio instructions. The developer should not program the agent to compensate by doubling the trade at another venue, because that changes the intended portfolio weights. A manual review or a scheduled retry is safer than an automatic override.
Trading always carries risk of loss, but the scoped key architecture prevents the agent from withdrawing funds to an external address. The worst-case scenario is that the agent trades within its authorized limits until the owner triggers the kill switch. The owner keeps custody, so revoking the key immediately locks the agent out.
Paper trading lets the agent run the same logic against simulated markets with realistic order handling and fees. The developer can observe how the agent behaves during volatility, margin changes, and partial fills without risking capital. Moving to live trading only requires owner authorization of a new scoped key.
The system connects each venue through the owner’s unified wallet structure, so the agent sees one balance and position list. The owner does not need to manually partition funds, though they may set sub-account limits if they prefer stricter segregation. The docs explain how to configure these connections.
Give your agent a key.
One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.
Newcomers often treat scoped API keys like strong passwords. In practice, they are programmable contracts that limit what an agent can do, regardless of whether the agent is buggy, compromised, or hallucinating.
Running a trading agent from Claude means connecting an LLM to real markets through MCP tools and scoped API keys. This guide walks through the architecture, safety setup, and first steps without assuming prior automation experience.