USE CASE
Portfolio rebalancing for AI agents
Rebalancing brings a drifted account back to its target mix. Abacus Labs returns the smallest set of trades that gets within tolerance, with the tax cost, the risk change and the rule checks, so the agent can tell the person what it costs before anything moves.
The problem
When to rebalance is the easy part. Vanguard's study of a 60/40 portfolio over 1926 to 2009 found no meaningful difference in risk-adjusted return between monthly, quarterly and annual rebalancing, while the number of trading events ranged from 1,008 for monthly with no threshold to 15 for annual with a 10% band (Jaconetti, Kinniry and Zilbering, Vanguard). Their recommendation was annual or semiannual monitoring with a 5% threshold.
How to rebalance is the hard part, and it is where a language model breaks. Target percentages have to become whole shares that leave cash above the floor. Each sale has to come from specific tax lots, because selling the oldest lot can realize a gain that a newer lot would not. A sale at a loss cannot be followed by a buy of the same fund inside 61 days, including in another account. New cash and dividends should be used before anything is sold. Our measurements show frontier models writing trades directly get all of this right 10% to 25% of the time.
Rebalancing software exists for advisers, sold per seat or on assets, with no endpoint an AI agent can call. Abacus Labs is a rebalancing API with tax lots as first-class inputs.
What the agent asks
webhook -> agent: acct_demo_1 drifted 8.2% from target
AGENT Your stocks grew to 78% after the rally. Your target
is 70%. Want me to look at it?
USER Yes, but keep taxes under $500.
agent -> propose(account, "rebalance to target, tax under 500", options=3)
AGENT Three ways back:
1 full rebalance to 70/30 tax $480 drift 0.4%
2 use new cash, sell nothing tax $0 drift 3.1%
3 halfway now, rest in January tax $0 drift 1.6%
USER Do 1.
agent -> commit(option_1)
What Abacus Labs returns
{
"status": "ok",
"trades": [
{ "symbol": "VTI", "side": "sell", "qty": 95, "lots": ["lot_14", "lot_15"] },
{ "symbol": "QQQ", "side": "sell", "qty": 22, "lots": ["lot_09"] },
{ "symbol": "BND", "side": "buy", "qty": 410 }
],
"target": { "equity": 0.70, "bonds": 0.30 },
"drift": { "before": 0.082, "after": 0.004, "tolerance": 0.05 },
"tax": { "realized_gain": 2090.00, "realized_loss": 0.00, "estimated_tax": 480.00 },
"risk": { "before": 0.14, "after": 0.12, "benchmark": 0.12 },
"checks": { "cash": "pass", "whole_shares": "pass",
"wash_sale": "pass", "limits": "pass" },
"explain": "Sells the two highest-basis VTI lots and one QQQ lot, buys bonds with the proceeds and the $3,000 of new cash. Lands within 0.4% of target.",
"certificate": "cert_2026-11-06_9b07"
}
How it works
The target can be weights, a model portfolio, or "the mix this account had on a date". Tolerance bands, a tax budget, a cash floor, excluded tickers and whole shares are constraints, not afterthoughts. New cash and dividends are spent first. Lots are chosen for tax: losses first, then the highest basis. Every planned buy is checked against 30 days of sales in every linked account.
Our point-in-time risk model supplies the tracking error between the account and its target, so a rebalance that reaches the right percentages with the wrong names does not pass. Explore returns options in tens of milliseconds. Commit re-solves the chosen option with an exact mixed-integer solver, which is what makes whole shares and the cash floor hold exactly, and returns a certificate.
Drift monitoring is a watch on the account. Abacus Labs calls analyze on a schedule and posts the result to the agent's webhook when drift passes the band, so the agent can raise it with the person instead of waiting to be asked.
Rebalancing events by rule
Monthly, no band ######################################## 1,008 Monthly, 1% band ############### 389 Annual, 5% band # 36 Annual, 10% band # 15
Source: Vanguard, Best Practices for Portfolio Rebalancing, 60% stock / 40% bond portfolio, 1926 to 2009. Fewer events means fewer taxable sales. Not an Abacus Labs result.
Who uses this
- Broker agents
- "Put this deposit to work and get me back to target" in one call, with the trade list ready for the broker's order API.
- Fintech app agents
- Model-portfolio tracking across thousands of small whole-share accounts, each with its own lots and cash.
- Advisor tools
- Household rebalancing with a tax budget per client, and a certificate for the file.
The Personal plan is free: 3 portfolios and 300 credits a month, no card. Paid plans add portfolios, credits and client use.