Learn / Glossary

Trading and exchange API glossary

Definitions for the terms used across these guides. Each is written to be correct on its own, and links to the longer treatment where one exists.

Deliberately one page rather than one page per term: a term worth a thousand words has an article, and a term that does not is better defined here than padded into a page of its own.


Risk and sizing

R multiple — A trade’s result expressed as a multiple of the amount risked. 1R is the distance from entry to stop, so a trade making three times what it would have lost is +3R. Makes results comparable across instruments and position sizes. → What is an R multiple?

Expectancy — The average result per trade in R: (win rate × avg win) − (loss rate × avg loss). The number that determines whether an approach makes money; win rate alone does not. → Expectancy vs win rate

Break-even win rate — The win rate at which a given R breaks even, 1 ÷ (1 + R). At 2R it is 33%; at 3R, 25%.

Position size — Quantity to trade, derived from risk budget and stop distance: (balance × risk %) ÷ |entry − stop|. An output of the stop, not an input. → Position size calculator

Fixed fractional sizing — Risking a constant percentage of the current balance per trade, so position size falls as the balance falls. The mechanism behind why (1 − f)^k understates streak damage less than k × f would.

Drawdown — Decline from a peak in account value. The gain required to recover it is d ÷ (1 − d), which accelerates: −50% needs +100%, −90% needs +900%. → Drawdown recovery calculator

Risk of ruin — Probability of losing enough capital to stop trading. Dominated by position size rather than by edge. → Risk of ruin

Kelly criterion — Bet fraction maximising long-run growth given a known edge: f = (bp − q) ÷ b. Extremely sensitive to a win rate you estimated, which is why fractional Kelly is common. → Kelly criterion calculator

Sequence of returns risk — The same returns in a different order producing a different outcome, once money is being added or withdrawn. Irrelevant to a static balance; material to a funded one. → Sequence of returns risk

Volatility drag — Why a series averaging zero ends below where it started: a −10% then +10% pair leaves 99%, because the gain is earned on a reduced balance.


Margin and leverage

Initial margin — What you post to open a position, 1 ÷ leverage as a rate.

Maintenance margin — The minimum equity a position must retain to stay open. Liquidation happens when equity falls to this, not to zero. Tiered by position size, so a larger position liquidates earlier at the same leverage. → What is maintenance margin?

Liquidation — Forced closure by the venue when equity reaches maintenance margin. → Liquidation price calculator

Isolated margin — A fixed margin allocation per position. Loss capped at that allocation; liquidation nearer.

Cross margin — All positions share the account balance as collateral. Liquidation further away, and every position is coupled to every other. → Isolated vs cross margin

Leverage — Notional divided by margin posted. In correct sizing it is an output, not a choice, and it does not change PnL in currency — only the margin required and how near liquidation sits. → Futures PnL calculator

Notional — Total position value (price × quantity). Fees and funding are charged on this, not on your margin.


Costs

Maker — An order that rests on the book and adds liquidity. Lower fee.

Taker — An order that executes immediately against resting liquidity. Higher fee. A limit order priced to execute immediately is a taker. → Maker vs taker fees

Adverse selection — The hidden cost of resting orders: you are filled when price comes to your level and continues through it, which selects for the trades moving against you.

Funding rate — Periodic payment between longs and shorts on a perpetual contract, keeping it tracking spot. Positive means longs pay shorts. Charged on notional, deducted from margin. → Funding rate calculator

Slippage — Difference between the expected and received price. Not quoted anywhere, scales with size relative to depth, and concentrates on stop-outs. → Slippage and market impact

Round trip — Entry plus exit cost. The move required just to break even. → Trading fee calculator


Orders and execution

Perpetual (perp) — A futures contract with no expiry, held to spot by the funding mechanism.

Stop-loss — An order closing a position at a level where the reason for the trade no longer holds. Belongs where the idea is invalidated, not where the loss feels acceptable. → How to choose a stop-loss level

Client order ID — A caller-supplied identifier for an order. Not generally an idempotency key — on Binance spot, uniqueness applies only among open orders, so the ID is reusable once the first fills. → Retrying a failed order is not safe

Reconciliation — Querying open orders, fills and positions to establish what actually happened after an ambiguous failure. The only safe response to a timeout on an order call.

Testnet / paper trading — A practice environment. Separate hostname on Binance, Bybit, Hyperliquid and Alpaca; on OKX, the same host with an x-simulated-trading: 1 header. → Practising on testnet before going live


Exchange APIs

API key permissions — Scopes controlling what a credential may do. On Binance, withdrawals cannot be enabled without IP access restriction, and spot trading permission on an unrestricted-IP key expires after 90 days. → Read-only vs trade permission

IP whitelist — Restricting a key to specified addresses. Bounds the value of a leak; on Binance it is also a precondition for withdrawal permission. → Binance API IP whitelist

Passphrase — OKX-specific third credential, chosen at key creation and not recoverable. Sent as OK-ACCESS-PASSPHRASE. → OKX API passphrase

Agent wallet / API wallet — Hyperliquid’s model: a master account approves a wallet to sign on its behalf. There is no API key, and the signing scheme gives the agent no way to express moving the master’s funds. → Hyperliquid API setup

Rate limit — A cap on request volume. Binance meters request weight rather than count; Bybit separates account-level (10006) from IP-level (10018); Hyperliquid grants an address-based allowance earned by trading volume. → Binance API rate limits

Unified Trading Account (UTA) — Bybit account type that changes the meaning of several error codes. 10003 means “too many sessions” on classic accounts and “your api key has expired” under UTA on spot. → Bybit API error 10003

Read-Only API — IBKR’s application-level setting that blocks all API trading. Enabled by default from TWS 950 — the most common cause of rejected API orders. → IBKR TWS API setup

CCXT — A library unifying many exchange APIs. Its exception hierarchy splits into ExchangeError (understood and refused) and OperationFailed (outcome unknown), which is the distinction that decides whether a retry is safe. → CCXT’s common errors


AI and MCP

MCP (Model Context Protocol) — An open standard for connecting AI applications to external tools and data. An exchange MCP server exposes your trading account as tools a model can call. → What is an exchange MCP server?

Tool — A named function an MCP server exposes. Tools are model-controlled — the model decides when to call them, and the protocol mandates no particular user interaction model.

Tool annotations — Metadata a server attaches to its tools, including readOnlyHint. The specification states these are hints that “are not guaranteed to provide a faithful description of tool behavior”, so they are not a permission boundary. → Read-only vs trade permission in an MCP setup

Approval layer — A step where a human sees the actual order parameters before submission. The MCP specification recommends one — SHOULD, not MUST. → Why MCP needs an approval layer

Prompt injection — Text the model reads being treated as instruction. A structural property of a single context window rather than a defect. → Prompt injection when the model can place orders

Idempotent — An operation with no additional effect when repeated. MCP’s idempotentHint defaults to false, which is correct for order placement.


FAQ

What does R mean in trading?

One unit of risk — the distance from your entry to your stop. Results expressed in R are comparable across instruments and position sizes, because the unit scales with what you had at stake rather than with the price of the instrument.

What is the difference between initial and maintenance margin?

Initial margin is what you post to open a position, set by your leverage as 1 ÷ leverage. Maintenance margin is the minimum equity the position must keep to stay open, set by the venue and smaller. The gap between them is how far price can move against you before liquidation.

Is a client order ID an idempotency key?

Not generally, and assuming it is causes duplicate positions. Binance documents newClientOrderId as unique among open orders, so a retry is rejected while the original rests and accepted once it has filled — which is exactly the ambiguous-timeout case you needed protection for.

Does readOnlyHint guarantee a tool is read-only?

No. The MCP schema states that all tool annotations are hints and “are not guaranteed to provide a faithful description of tool behavior”, and the specification requires clients to treat annotations from untrusted servers as untrusted. Enforce read-only at the exchange key instead.