Brokerage API
A brokerage API is the programmatic interface a broker exposes so that software can do what a person does in the broker's app. The software places orders, reads positions and cash, and receives account updates as they happen. A trading platform connects to that interface on the user's behalf. The strategy decides what to buy or sell, and the API is the channel that carries the order to the broker and carries the fill back.
An API call is also where the hypothetical part of a backtest ends. Everything before the order is a computation on data: indicators, rules, a target position. The order is the first step that touches a real market, a real price and a real counterparty. For that reason the brokerage API sets the practical limits of what an automated strategy can do in a given account: which order types exist, how orders are confirmed, how fills are reported and what happens when something is rejected.
The backtest library used on this site puts rough numbers on how much work such an interface does. It covers 12 strategy templates on 59 ETFs over 1,444 sessions, from 2021-01-04 to 2026-10-02. The median number of round trips per template runs from 2 to 166 across those funds. Each round trip is at least two orders, and each order is a call to a broker. One order's path from the strategy to the broker and back is described first, followed by the funds and rules that put the most strain on that path.
The four jobs of the interface
A brokerage API does four jobs, and a platform has to handle all four.
- Authentication. The user grants the platform permission to act on the account. The grant should be limited, and it should be revocable.
- Orders. The platform submits, modifies and cancels orders, and says what type each order is, how long it lives and at what price it should execute.
- Account state. The platform reads cash, buying power and positions, so it knows what the account holds before it decides what to send.
- Fill reports. The broker tells the platform what actually executed, at what price and in what size.
The fourth job matters most for accounting. DeployQuant's product reference states that positions and cash are accounted from the broker's own fill reports, so the platform's books follow what actually filled at the broker. A strategy does not get to assume that the order it sent was the order that filled. If the broker fills part of an order, or rejects it, the report says so and the books change to match.
A broker connection on DeployQuant has trade and read permissions only. It cannot withdraw or transfer money, and the user can disconnect at any time. Those limits come from what the API grant allows, which is the reason the grant matters. An API key or a login token with withdrawal rights would be a different risk from one without them.
The life of one order
An order moves through states, and each state is something the API reports. The exact names vary by broker, so the list below is the general pattern.
- The strategy produces a target, for example "hold 100% of the account in this fund".
- The platform turns the target into an order of a specific type and size.
- The platform checks the order against its own rules before sending it.
- The broker accepts the order or rejects it.
- The order rests, partly fills, fully fills or is cancelled.
- The broker reports each fill, and the platform updates the position.
DeployQuant's OMS, the order management system, sits between the strategies and the broker. According to the glossary definition it tags each order with the strategy that owns it, validates it against limits and available cash, routes it, tracks its lifecycle and matches fills back to their owner. The product reference says all sleeves in an account share one broker connection and one login, and the OMS sends every order down that one connection.
Several checks happen before an order reaches the broker. Each order is checked against its own sleeve's cash, so one strategy cannot spend another's money. Price bands refuse limit orders priced too far from the market. Per-order and per-position dollar caps apply, and so does a cap on orders per sync. The caps never block an order that reduces exposure, which means a strategy can always get out of a position even when it is at the limit on getting in.
One adapter per broker
The glossary definition says authentication, order lifecycle, error handling and reconciliation all live behind one adapter per broker. The adapter is the translation layer. The platform speaks one internal language of strategies, targets and sleeves. Each adapter converts that language into the calls and message formats of one broker, and converts the replies back.
The reason for an adapter is that brokers do not agree on the details. They differ in how a user authorises access, in which order types they accept, in which time-in-force options exist, and in whether a paper environment is available. The same strategy rule can need different calls at different brokers, and the adapter hides that from the strategy author.
DeployQuant supports three brokers today. The product reference lists Webull for live accounts, Charles Schwab for live accounts and Alpaca for live and paper accounts. Webull's API has no paper environment, so paper trading for a Webull user happens on DeployQuant's own paper mode instead. Other brokers can be requested from inside the app. Paper trading needs no brokerage account at all, which means the first contact with a brokerage API comes at the live step, after the strategy has already run on live data. The paper trading entry covers that step.
Capability differences change what a strategy can do
The definition says API capability differences, such as order types and fractional support, shape what strategies can deploy where. The strategy templates in the library show why.
Take the momentum breakout, which buys after a +10% four-week burst with a 10% trailing stop managing the exit. It needs an exit that follows the price. A broker that offers a native trailing-stop order can hold that exit at the broker. A broker without one needs the platform to track the high-water mark and send a stop or a market order when the level is hit. Both can work, but the first survives a lost connection better, and the second depends on the platform staying connected.
The weekly 7% target rests a +7% profit target after the first open of each week. That is a resting limit order that can sit at the broker for days, so it depends on an order lifetime longer than one session. A rule whose orders only live for the day would have to be resubmitted each morning.
The 200-day regime filter and the golden cross decide on closing prices. They need an order to go in near the close or at the next open, and the broker's auction and close order types determine how closely the fill can follow the rule. The test in this library fills on minute bars, so it models those fills as happening at the bar's price, and a real broker may differ.
Fractional share support matters for small accounts. The library starts with $10,000 and no margin. A fund priced in the hundreds of dollars per share fits in that account, but the rounding to whole shares still leaves some cash idle, and an API that accepts fractional orders would leave less. The test here rounds as the engine does and makes no claim about any one broker's fractional rules.
How much API traffic each rule creates
The median number of round trips across the 59 ETFs tells how often a rule calls the broker.
The RSI(2) snapback has a median of 166 round trips. The weekly 7% target has 106, the monthly cycle has 69, and the EMA 12/26 trend has 22. The 200-day regime filter has 18, the SMA 10/50 trend has 17 and the RSI mean reversion rule has 15. The 3-month momentum rule has 12, the momentum breakout has 6, the trend plus trailing stop rule has 4, the golden cross has 3 and the dip buyer has 2.
The rules at the top of that list send a few hundred orders in a bit under six years. The rules at the bottom send only a handful. The first group tests how the integration copes with routine volume: rejections, retries, orders that cross, partial fills. The second group tests how it copes with a long silence, where the connection, the login token and the account state have to still be valid when a rare signal finally fires. A token that expires between signals is a failure that only a slow strategy will find.
Each order is also a place where cost enters. The headline runs in the library include no fees and no slippage, and cost runs add 5 and 10 basis points. The median CAGR among the busy rules is 4.74% for the RSI(2) snapback, 6.61% for the weekly 7% target and 5.46% for the monthly cycle. Those are the figures that a per-order cost at the broker can reduce most.
What the fund decides about the fill
The API carries an order to the market, and the fund determines how the market treats it. The library's market data shows how different the funds are.
SPY had an average daily dollar volume of $30,453,859,411 and a median minute volume of 107,870. QQQ had $18,772,024,579 and 77,976. IWM had $5,885,548,447 and 46,034. TLT had $2,159,787,473 and 35,636, and TQQQ had $4,150,045,180 and 285,786.5. UVXY had $458,284,172 and a median of 1,145 shares a minute.
For a $10,000 account, an order in SPY or QQQ is small against that volume, and a market order should fill close to the quote. A median minute volume of 1,145 in UVXY is a thinner book, and the average intraday range of 7.03% means the price moves a good deal inside a bar. The same API call produces a different quality of fill in the two funds. The broker reports the fill price, and the platform's books record it, so the difference shows up in the account exactly as it happened.
The overnight gap adds another effect for rules that trade at the open. The average gap was 0.44% for SPY, 0.59% for QQQ and 1.78% for TQQQ, and 2.53% for UVXY. An order sent before the open is filled at the opening price, and the API reports whatever that price was. Because of this, a rule that decides on the close and trades at the next open is exposed to the gap in every mode.
Errors, rejections and what the platform does with them
Orders can be rejected. A limit price may be too far from the market, the account may lack buying power, or the order type may not be allowed for that security or time of day. A rejection comes back through the API as a message, and the platform has to decide what to do with it.
On DeployQuant, Webull order errors on live accounts are sent to the user by email. The OMS keeps each order's lifecycle, so a rejected order is recorded against the sleeve that sent it, and the sleeve's cash and positions stay as they were. One switch pauses a single strategy and another pauses every strategy on a broker connection, which gives the user a way to stop new orders while the cause is investigated.
Dry-run mode runs the whole order flow without sending any order to the broker. It is the way to test the translation from strategy to order without a real fill, and it is separate from paper trading, which runs the strategy on the live feed with simulated fills. Real money only moves after the user types an explicit confirmation on a live deployment.
The point of these controls is that an API gives a program the same power as a person with the app, at machine speed. A bug in a strategy can send many orders quickly. The caps on order size, position size and orders per sync limit how much a mistake can do before someone sees it.
Sleeves, tags and shared connections
A brokerage account has one balance and one list of positions. A platform that runs several strategies in the account has to divide that single picture into parts. The brokerage API itself does not know about strategies. It knows about orders and positions in one account.
DeployQuant divides the account into sleeves. Each sleeve has its own cash, positions and P&L. Every order is tagged with the strategy that placed it, and fills return to the sleeve that placed the order. A strategy that sells everything sells only its own positions. Two strategies can hold the same symbol in the same account, and each one's share of the position is tracked separately. Cash in the account that is not allocated to a sleeve is never traded, and positions the user trades by hand stay theirs.
The tags and the sleeve books live on the platform side. The broker sees only the combined order flow of one connection. That is why accounting from the broker's fill reports matters: the platform has to match every fill back to the sleeve that owns it, even when two strategies are trading the same fund through the same login.
Why the market data feed is a separate matter
A brokerage API handles orders and accounts. Quotes and bars for decisions come from a market data feed, which is a separate connection with its own rules. DeployQuant says paper and live trading use the same real-time consolidated feed, and backtests use minute-resolution consolidated US equity data going back years, with 1-second bars available for Python strategies.
The split has a practical effect. A strategy sees the same prices in paper and live trading, because both read one feed, and the brokerage API is the only part that changes when a strategy goes live. If a live result differs from a paper result, the data is not the first suspect. The order handling, the fill quality and the account rules are.
It also explains why a paper account needs no broker at all. Everything a paper session needs is the feed and the simulator. Only a live deployment needs the broker's interface to submit orders and read fills.
Limits of the numbers here
The statistics on this page come from backtests on 59 US ETFs over one window of 5.74 years. Orders in the test fill on minute bars with no margin, and the headline run has no fees or slippage. The cost runs at 5 and 10 basis points are a stand-in for what an execution path costs and do not model any specific broker, any rejection, any outage or any partial fill.
The descriptions of brokers follow DeployQuant's product reference as of 2026-10-02. Broker interfaces change, so the reference and the broker's own documentation decide what is supported at a given time. Backtest results are hypothetical, and nothing here is investment advice. Live trading carries a risk of loss.
Frequently asked questions
What is a brokerage API?
A brokerage API is the interface a broker exposes so software can place orders, read positions and cash, and receive account updates. A trading platform uses it to send a strategy's orders and to learn what filled. The adapter for each broker handles the differences in login, order types and error messages.
Do I need a brokerage API to paper trade?
No. DeployQuant's paper trading runs on the same real-time consolidated feed as live trading and needs no brokerage account. A brokerage API only comes into play at the live step, when real orders go to a broker. Alpaca also offers its own paper accounts, while Webull and Charles Schwab are live only.
Can a brokerage API connection withdraw my money?
On DeployQuant, no. A broker connection has trade and read permissions only, so it cannot withdraw or transfer money, and you can disconnect it at any time. Cash and shares stay in your own brokerage account in your name. Read the broker's own permission screen to confirm what the grant allows.
Which brokers does DeployQuant connect to?
DeployQuant connects to Webull and Charles Schwab for live accounts and to Alpaca for live and paper accounts. Other brokers can be requested from inside the app. Questions on each broker are answered on pages such as [automating on Alpaca](/learn/answers/automate-trading-on-alpaca/) and [automating on Schwab](/learn/answers/automate-trading-on-schwab/).
What happens if the broker rejects an order?
The rejection comes back through the API and the platform records it against the sleeve that sent the order. That sleeve's cash and positions stay unchanged. On DeployQuant, Webull order errors on live accounts are sent to the user by email, and a single strategy or a whole broker connection can be paused.
Does the brokerage API affect my backtest results?
The backtest does not call a broker. It fills orders on minute bars with no fees or slippage in the headline run, and cost runs add 5 and 10 basis points. Live fills come through the brokerage API and can differ, mostly for rules that trade often, such as the RSI(2) snapback with a median of 166 round trips.
How does DeployQuant keep strategies apart in one broker account?
Each strategy runs in its own sleeve with its own cash, positions and P&L. Every order is tagged with the strategy that placed it and checked against that sleeve's cash, and fills return to the sleeve that placed the order. The question of who holds your money has its own answer at [does DeployQuant hold my money](/learn/answers/does-deployquant-hold-my-money/).
Build it from blocks (or type it in English), backtest it on 5.7 years of minute data in seconds, tweak any parameter, then paper trade it on live data. No card, no broker needed to start.
Related terms
Backtests are hypothetical, computed by DeployQuant's engine on minute-resolution consolidated US market data (2021-01-04 to 2026-10-02, $10,000 starting capital, no margin, no fees or slippage in the headline run; buy-and-hold puts 98% of the account in at the first open, as the templates do) and do not guarantee future results. Nothing on this page is investment advice. Live trading involves risk of loss.