Agentic tradingRisk managementPosition sizingDevelopers

How to size positions for an AI trading agent from first principles

Position sizing controls how much an AI agent can lose. Learn to define dollar risk budgets, enforce hard limits, and normalize sizing across markets from first principles.

By the Felix team9 min read
Key takeaways
  • 01Position sizing is the primary defense against catastrophic loss, and it matters more than the accuracy of entry signals.
  • 02Every sizing rule should be expressed in dollars at risk, not in abstract percentages or in the agent's self-assessed confidence.
  • 03A non-custodial API with scoped budget caps prevents an agent from exceeding its allocated capital even when its logic demands larger trades.
  • 04Normalizing orders to plain US dollars removes venue-specific contract math from the agent's reasoning, which reduces errors across stocks, crypto, perps, options, and prediction markets.
  • 05Before deploying live capital, test sizing rules in paper trading and verify that hard limits bind even when the agent attempts to exceed them.

Position sizing is the control surface that determines how much capital an agent can destroy with a single bad decision. Without explicit, dollar-denominated sizing rules, an AI agent can concentrate the entire budget into one instrument before any safety check has time to react. Building from first principles means defining the maximum dollars at risk per trade, per strategy, and per account before the agent ever sees a price feed. The goal is not to maximize returns, but to ensure the agent survives long enough to be evaluated.

Why does position sizing matter more than entry timing?

Traders often spend most of their effort improving entry signals, but sizing is what determines survival. An agent can enter at the exact wrong time and still recover if the position is small. Conversely, an agent can enter with perfect timing and still lose everything if the position is too large. The mathematics of compounding work against large losses more aggressively than they reward large wins. A fifty percent drawdown requires a one hundred percent gain just to return to the starting point. For an autonomous agent that does not sleep, a single oversized position can trigger that drawdown while the owner is offline. Because agents operate without fatigue or emotional hesitation, they can execute far more decisions per day than a human. This volume magnifies any sizing error into a rapid sequence of losses. Entry timing is an optimization problem. Position sizing is a risk control problem. The agent should not be trusted to solve the second one on its own. Why AI agents force developers to rethink trading risk management explores this shift in more detail.

How do you define risk before the agent picks an instrument?

Start with a dollar budget, not a percentage. Percentages are abstractions that the agent must translate into contract counts, lot sizes, and margin requirements. Those translations are error-prone, especially when the agent moves across stocks, crypto, perps, options, and prediction markets. An agent calculating five percent of a wallet balance denominated in a volatile asset must know the asset price, the US dollar conversion, and the current balance. Any error in that chain produces the wrong size. A first principles approach states that this agent is allowed to lose a specific number of dollars on this trade. That number is the risk budget. From there, you derive the position size by looking at the distance between the entry price and the exit plan, whether that exit is a stop loss, a time limit, or a volatility target. If the agent plans to exit if the price moves ten dollars against it, and the risk budget is one hundred dollars, the position size is ten units. The agent does not need to know the notional value of the underlying. It only needs to know that its loss is bounded. You should also set a daily loss budget and a total account loss budget. When the daily budget is exhausted, the agent stops trading until the owner resets the counter or the clock turns. This prevents the classic failure mode of an agent doubling its size after a loss to make the money back. Suppose an agent loses two hundred dollars on its first trade of the day. If it has a daily budget of one thousand dollars, it now has eight hundred dollars of remaining risk capacity. It does not increase its next bet to recover the loss. It continues with its baseline size. This rule is simple to state and simple to enforce, which is exactly what an autonomous system needs.

What is the simplest position sizing model for an agent?

The simplest model is fixed dollar risk. You allocate a fixed amount of dollars that the agent is permitted to lose per trade, and you size each position so that the worst-case loss equals that amount. This model is easy to audit, easy to simulate, and easy to enforce at the API level. A fixed dollar model also makes backtesting more honest, because you are not allowing the strategy to implicitly assume it can scale infinitely with account growth. More complex models exist. Volatility targeting adjusts the position size so that each trade contributes the same expected dollar volatility. The Kelly criterion attempts to maximize logarithmic wealth growth by sizing according to perceived edge. These models are intellectually interesting but dangerous for autonomous agents. The Kelly criterion requires precise knowledge of win rates and payoff ratios, which an agent does not have. Imagine an agent estimates a sixty percent win rate and a two to one payoff. Kelly suggests betting twenty percent of capital. If the true win rate is fifty five percent, the agent is still overbetting and will accelerate toward ruin. For an agent, complexity is the enemy of safety. A fixed dollar risk model has no hidden parameters that can drift. The owner sets the number, the API enforces it, and the agent operates within the boundary. If the agent runs multiple strategies, you can give each strategy its own fixed dollar budget. This keeps one strategy from cannibalizing the capital of another. The agent does not need to know the total account balance. It only needs to know its own fixed risk budget. This removes a common source of errors where the agent miscalculates a percentage of a fluctuating balance.

How does Felix normalize sizing across five market types?

Stocks trade in whole shares. Crypto trades in decimals. Perpetual futures use contract sizes and margin. Options have multipliers, strike prices, and delta. Prediction markets use binary outcomes and share prices. Requiring an agent to manage all of these contract specifications is a source of bugs. Felix abstracts this by accepting orders in plain US dollars. You tell the API how many dollars of exposure or risk you want, and the system handles the translation into the venue-specific units. The agent reasons in dollars. The API normalizes the rest. This removes an entire class of errors where the agent miscalculates contract sizes, forgets an options multiplier, or confuses notional value with margin. 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" \
  -d '{
    "symbol": "EXAMPLE-ASSET",
    "side": "buy",
    "dollar_amount": 500,
    "risk_budget": 50
  }'

The agent does not need to compute how many shares to buy, how many decimals of a token, or how many contracts. It sends a dollar amount and a risk budget. The infrastructure translates that into the correct units for a stock broker, a crypto exchange, a perps venue, an options venue, or a prediction market. One API for every market explains this abstraction in more detail, and Non-custodial trading for AI agents describes how the funds remain under your control while the agent spends within these limits.

How do you enforce limits so the agent cannot override them?

The agent should not be the final authority on its own budget. Felix uses scoped API keys with hard budget caps, position limits, and owner-approved withdrawal addresses. The key is scoped to a specific dollar budget. When that budget is spent, the key cannot place new orders. The agent can request a trade, but the API will reject it if the remaining budget is insufficient. Position limits prevent the agent from concentrating too much into a single instrument. A kill switch can flatten all positions and revoke the key instantly. These controls exist outside the agent's reasoning. The agent cannot prompt engineer its way around them, because the enforcement happens at the infrastructure level, not inside the agent's loop. The owner retains custody of the funds at all times. The agent can spend within limits but can never withdraw to itself or to an unapproved address. This is the core of non-custodial agent trading. The agent operates within a sandbox of dollars that you define. If the agent's logic demands a larger size, the API simply returns an error. The agent must adapt or stop. You can also set a per-order maximum, a per-symbol maximum, and a maximum number of open positions. These layers create defense in depth. Even if the agent misinterprets a signal and decides to go all in, the API will only permit the order if it fits within the scoped limits. How to build a kill switch your trading agent cannot override walks through the mechanics of emergency shutdown.

What should you do when a position moves against the agent?

Markets move, and an agent will experience losses. The critical question is what happens next. The agent should not be allowed to add to a losing position unless you have explicitly programmed and capped that behavior. Averaging down without a hard limit turns a small loss into a large one. The safer default is to reduce or flatten. You should define an exit plan before entry. This can be a stop loss in dollars, a time limit, or a signal from a separate model. A time stop closes the position after a set duration if the expected move has not occurred, which prevents the agent from holding dead capital while waiting for a thesis that may never resolve. You should also define a drawdown limit for the overall account. If the agent loses a preset amount of its total budget, it stops trading. This is not a failure of the strategy. It is a survival mechanism. Trading can lose money, including the entire allocated budget. The purpose of sizing and exit rules is to ensure that if the agent does fail, it fails small and fails quickly, preserving capital for another attempt. Suppose the agent enters a position with a fifty dollar risk budget. If the unrealized loss hits that amount, the exit plan should trigger. If the agent instead buys more to lower its average cost, it has now violated its original risk budget. You must prevent this at the API level by capping total exposure per symbol and by using the budget cap as a hard ceiling. The agent may reason that the asset is cheaper now, but cheaper prices do not guarantee future profits. An autonomous agent does not have the judgment to distinguish between a temporary dip and a permanent decline. Therefore, it should not have the authority to increase risk on a losing position without human approval.

Frequently asked questions

Should an agent use the Kelly criterion for position sizing?

The Kelly criterion is theoretically optimal for known edges, but it is dangerous for autonomous agents. It requires precise estimates of win rates and payoffs that are almost always wrong in real markets. Overestimating edge leads to bet sizes that accelerate ruin. A fixed dollar risk model is safer and more auditable.

Can the agent adjust its own position size based on confidence?

The agent can vary size only within owner-defined hard ceilings. Confidence is not a reliable proxy for statistical edge. The API enforces budget caps regardless of the agent's stated confidence, preventing the common failure mode of oversized bets on ambiguous signals.

How does paper trading help test sizing rules?

Paper trading lets you observe how the agent behaves under budget constraints without risking real capital. You can verify whether the agent respects dollar limits, avoids concentration, and handles API rejections gracefully before authorizing live trading.

What is the difference between notional size and dollars at risk?

Notional size is the total market exposure of the position. Dollars at risk is the amount you actually lose if the trade hits your exit plan. An agent should target the latter, because a large notional position with a tight stop may have small risk, while a small notional position with no exit plan can be catastrophic.

Does Felix support margin or leverage in sizing calculations?

The API accepts plain dollar orders. Leverage is a property of the underlying venue, not a sizing input for the agent. The owner controls the total budget cap, which limits the agent's exposure regardless of how much leverage a venue offers.

Can I change position limits while the agent is running?

Yes. You can update scoped key parameters or trigger the kill switch at any time. These changes take effect at the API level immediately. The agent cannot revert them, because the enforcement logic sits outside the agent's control.

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.