Agentic tradingPerpetual futuresRiskDevelopers

How perpetual futures trading changes when an AI agent takes over execution

How AI agents change perpetual futures trading step by step, from reading funding rates to managing margin and liquidation risk with hard limits.

By the Felix team10 min read
Key takeaways
  • 01Perpetual futures require an AI agent to monitor funding rates, margin ratios, and liquidation prices continuously because leveraged positions can be closed by the venue on small adverse moves.
  • 02The API normalizes all contract math into plain US dollars, letting the agent reason in simple notional terms while the owner configures the underlying leverage and risk limits.
  • 03Hard limits including budget caps, position limits, and a panic switch are essential for perpetual futures because the downside can be the total loss of posted margin within minutes.
  • 04Position sizing for an agent must account for the distance to liquidation, not just the desired notional exposure, and conservative defaults are safer than signal-driven leverage.
  • 05Paper trading replicates the full margin and funding lifecycle, but the transition to live trading should start with small capital, low leverage, and active human oversight until the agent proves stable.

Perpetual futures are leveraged contracts with no expiry date, so an AI agent trading them must continuously track funding rates, margin ratios, and liquidation prices instead of simply watching a spot price. When the agent takes over execution, it replaces manual order entry with a continuous loop that reads market state, checks owner-defined limits, and submits orders through a single normalized API. The owner retains full custody of funds and sets hard boundaries on notional size, leverage exposure, and maximum loss, while the agent handles the mechanical work of staying within those boundaries or exiting when they are breached. Trading can lose money, including the entire margin allocated to a position, so the agent is only as safe as the limits configured around it.

What makes perpetual futures different from spot markets for an agent?

In a spot market, an agent buys an asset and holds it. The risk is mostly directional: the price may fall, but the agent still owns the units until it chooses to sell. Perpetual futures introduce a margin layer that changes the risk profile. The agent does not own the underlying asset. Instead, it posts collateral to support a notional position that can be many times larger than the collateral, depending on the leverage it chooses or the venue enforces.

  • ·No expiry date, so positions persist until the agent closes them or the venue intervenes.
  • ·Funding rates apply at regular intervals, creating a carry cost or income.
  • ·Margin requirements mean the position can be liquidated automatically if the market moves against it.
  • ·The API reports notional value in USD, but the underlying contract is still leveraged.

Liquidation is the defining difference. If the mark price moves against the position and the margin ratio drops below the maintenance level, the venue closes the position automatically. The agent does not get to decide whether to hold through the dip. This means the agent must monitor the distance to liquidation as closely as it watches the entry price. A spot agent might wait out a drawdown. A perp agent must either add margin, reduce size, or accept that the hard limit of the market will close the trade for it.

How does an AI agent interpret funding rates and margin requirements?

Funding rates represent the cost of carrying a position from one funding interval to the next. A positive rate means longs pay shorts; a negative rate means shorts pay longs. An agent that plans to hold a perp for more than a few hours should read the funding rate before opening and include it in its expected carry cost. If the agent is automated to trade across multiple markets, funding can be the deciding factor between a profitable loop and a slow bleed.

Margin requirements come in two layers. Initial margin is the collateral required to open a position. Maintenance margin is the minimum collateral required to keep the position open. The agent must calculate how much of its budget cap will be locked as initial margin and how close the mark price can move before hitting maintenance. The exact formulas vary by venue, but the agent can query the unified API for its available margin and liquidation price in USD terms. This lets the agent compare risk across different perp markets without learning each venue's native contract structure.

The agent should also distinguish between isolated margin and cross margin if the API exposes both modes. In isolated mode, only the margin assigned to a single position is at risk. In cross mode, the entire margin balance backs every position. An agent running with cross margin has more flexibility but also faces the risk that one bad trade drains the shared pool. A cautious setup usually starts with isolated margin and tight per-symbol caps so that one position cannot cascade into others.

Because the API reports everything in dollars, the agent can set simple rules. For example, if the liquidation price is within five percent of the mark price, do not increase size. If the funding rate exceeds a threshold in the adverse direction, reduce or flatten. These rules are easy to state in natural language and translate into API parameters through MCP tools or direct REST calls.

What does step-by-step execution look like?

Step-by-step execution for a perp agent follows a loop that mixes observation, risk checks, and action. The loop does not need to be fast for every strategy, but it does need to be consistent.

  1. 01Observe. The agent reads the current mark price, funding rate, open interest, and account margin. It also checks pending orders.
  2. 02Evaluate. The agent compares the proposed trade against the owner-defined budget cap, position limit, and daily loss limit. If any boundary would be breached, it stops.
  3. 03Calculate. The agent decides on a notional amount in USD. The API handles the contract multiplier, so the agent does not need to convert contracts or coins. It verifies that the implied leverage and liquidation price fit its risk parameters.
  4. 04Pre-flight. The agent confirms that an exit plan is active, whether a stop order, time-based exit, or signal-based reversal. It also confirms that audit logging is on and the panic switch is reachable.
  5. 05Submit. The agent sends the order through the API.
  6. 06Monitor. After the fill, the agent tracks mark price against liquidation price, the next funding schedule, and any change in margin requirements.
  7. 07Exit or adjust. If a stop level is hit, funding flips adverse, or a new signal overrides the old one, the agent submits a reducing or flattening order and the loop restarts.

The exact request schema is in the docs; the shape looks like this.

curl -X POST https://api.felix.trade/v1/orders \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "market_type": "perp",
    "side": "buy",
    "notional_usd": 500,
    "symbol": "EXAMPLE-USD",
    "check_limits": true
  }'

This seven-step process replaces the manual trader's sequence of checking a chart, calculating size, entering an order, and watching the position. The difference is that the agent never sleeps and never skips a step, provided the limits and logic are coded correctly.

How do you size positions when leverage amplifies both gains and losses?

Position sizing in perpetual futures is not just about how many dollars you want to gain. It is about how much margin you can afford to lose and how far the price can move before the venue closes you out. The API normalizes sizing into plain US dollars, which simplifies the agent's task, but the owner still needs to configure the underlying risk.

Suppose the agent has a total budget cap of two thousand dollars. It might be tempting to let the agent open a two-thousand-dollar notional position. At 10x leverage, this locks only two hundred dollars of margin, leaving eighteen hundred dollars free. That free capital is misleading. A ten percent move against the position would wipe the margin entirely and trigger liquidation. The agent has not spent the full budget, but it has exposed the account to a total loss of the locked margin.

A safer approach is to size each position so that a normal adverse move does not come close to the maintenance margin. The position sizing guide explains how to map volatility expectations to notional caps. In practice, many owners start by capping each perp position at a small fraction of the total budget, then using low leverage so that the liquidation price sits far outside the daily trading range.

The agent should also respect concentration limits. Holding three perp positions in correlated assets, each sized at ten percent of the budget, can behave like one large position at thirty percent exposure. The API allows per-symbol limits and total notional caps, so the owner can enforce diversification even if the agent does not understand correlation. Common mistakes include letting the agent size purely by signal strength without checking margin, or ignoring the difference between notional value and actual collateral at risk. The common mistakes article covers these in detail. The core principle is that leverage makes small errors fatal, so the agent's sizing logic must be conservative by default and aggressive only within narrow, pre-approved bands.

Why are hard limits more critical for perpetuals than for spot?

In a spot market, the worst-case outcome for a single trade is usually that the asset loses most of its value. The position remains open and the units are still in the wallet. In perpetual futures, the worst-case outcome can be the complete loss of the posted margin in minutes, followed by liquidation. This asymmetry makes hard limits essential.

The owner configures these limits before the agent receives a key. A budget cap restricts the total margin the agent can allocate across all perp positions. A position limit restricts the notional size of any single trade. A daily loss limit stops the agent from trading further once a drawdown threshold is reached. These are not suggestions; they are enforced by the infrastructure around the agent.

The hard limits for perpetuals article describes how these boundaries interact with leverage. A 5x leveraged position reaches its liquidation price five times faster than an unleveraged spot equivalent. The kill switch, or panic button, flattens all positions and revokes the API key immediately. This is especially important for perps because a disconnected or malfunctioning agent could accumulate opposing positions or fail to reduce size as margin dwindles.

Scoped keys add another layer. The agent's key is authorized only for perp trading and only up to the configured caps. It cannot withdraw funds, it cannot trade spot or options unless explicitly allowed, and it cannot add new withdrawal addresses. Because the setup is non-custodial, the funds remain in the owner's wallet. The agent can only lose what it has been permitted to margin, and only inside the perp venues it has been approved to access.

Even with these limits, trading can lose money. A flash move can liquidate a position before the kill switch is pressed. The limits reduce the maximum damage but do not eliminate it. Owners should treat the first live deployment as an experiment with a small, fixed amount of capital that they are prepared to lose entirely.

How do you transition from paper trading to live margin safely?

Paper trading lets the agent run the full loop against live market data without risking real margin. The funding rates, margin calculations, and order matching behave identically to live trading. This is the right place to test sizing logic, stop rules, and the behavior of the agent around funding intervals.

Before moving to live trading, the owner generates a new scoped key and explicitly authorizes it for perpetual futures. The budget cap should be set to the smallest meaningful amount, not the full intended allocation. The owner should also enable audit logs and connect them to an external dashboard so that every order, rejection, and fill is visible outside the agent's own output.

The building safely article recommends a staged rollout. Start with 1x or 2x leverage so that the agent experiences the mechanics of margin and funding without the compressed timeline of high leverage. Observe the agent across at least two funding cycles to see how it reacts to the cost. Only after the agent demonstrates stable behavior should the owner consider raising the cap or the leverage.

During the first live sessions, the owner should keep the kill switch visible and define a clear time limit. If the agent is not behaving as expected, flatten, revoke, and review the logs. Do not let the agent run unattended overnight on its first live deployment. Automated execution is reliable only after it has been proven reliable. Trading can lose money, including the entire allocated margin. Paper trading profits do not predict live results. Slippage, latency, and margin calls affect real capital in ways that simulations approximate but never perfectly replicate. The transition from paper to live is a change in risk, not just a change in accounting.

Frequently asked questions

Can an AI agent choose its own leverage?

The agent selects a notional size in USD, and the venue applies leverage based on the margin available in the account. The owner controls the effective leverage by setting budget caps and position limits, so the agent cannot accidentally take on more risk than permitted.

What happens if the agent is holding a position during a funding interval?

The venue credits or debits funding automatically to the position. The agent should monitor funding rates as a cost input, but it does not need to make manual payments or deductions.

How quickly can I stop an agent that is trading perps?

The panic switch flattens all open perp positions and revokes the API key in one action. This takes effect immediately and prevents the agent from opening new positions.

Can one agent trade multiple perp markets at the same time?

Yes, as long as the total notional exposure stays within the combined budget cap and each market respects its per-symbol position limit. The API normalizes all markets to USD, so the agent can compare risk across venues.

Does paper trading include liquidation and margin calls?

Yes, paper trading simulates the full margin lifecycle, including liquidations, funding payments, and order rejections. It is designed to behave identically to live trading so that the agent can be tested under realistic conditions.

Is the agent custodial over the margin funds?

No. The funds remain in a wallet the owner controls. The agent can only use the margin it has been authorized to spend, and it cannot withdraw funds to itself or to any address that the owner has not pre-approved.

Give your agent a key.

One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.

Keep reading

Not a brokerage, exchange, or investment adviser. Not investment advice. Trading involves risk, including total loss.