USE CASE

Pre-trade checks for AI agents: wash sales, whole shares, cash

2026-11-06 · 5 min read

Your agent drafted a trade list. Before it reaches the broker, send it to propose with the trades in place of a goal. Abacus Labs returns pass, or every violation with a repaired list and an original-versus-repaired ledger, in one call.

The problem

Agents improvise trades. A model that reads a portfolio and writes "sell 41.7 shares of AMD, buy VOO with the rest" has done something useful and something dangerous in the same breath. In our October 2026 measurements, frontier models writing trades directly produced a list a broker would accept 10% to 25% of the time. The failures are mundane: cash that does not add up, fractional shares in a whole-share account, position limits, and buy-backs inside the wash-sale window.

Wash sales are the costly one. A loss is disallowed if a substantially identical security is bought within 30 days before or after the sale, across all of the person's accounts (SEC; IRS Publication 550). The broker will usually accept the order anyway. The person finds out at tax time. No API tells you whether two securities are substantially identical. The IRS gives no list, only that you "must consider all the facts and circumstances" (IRS Publication 550), so the rule is an interpretation that has to be encoded and maintained.

Regulators are watching the same gap. FINRA's 2026 oversight report flags agent-based systems whose reasoning is hard to audit (Debevoise summary). A checked list with a certificate is the audit trail.

What the agent asks

        agent drafts trades from its own reasoning

        agent -> propose(account, trades=[
                   { "symbol": "AMD", "side": "buy",  "qty": 41.7 },
                   { "symbol": "VOO", "side": "buy",  "qty": 12 },
                   { "symbol": "INTC","side": "sell", "qty": 400 }
                 ])

        Abacus Labs -> 3 violations, repaired list, ledger

AGENT   Two fixes before I send this. AMD was sold at a loss
        in your IRA 12 days ago, so buying it now would wash
        that loss; I'll buy a similar fund instead. And your
        account trades whole shares, so 41 not 41.7.

USER    Fine. Go.

        agent -> commit(repaired_option)

What Abacus Labs returns

{
  "status": "repaired",

  "understood": { "intent": "check_trades" },

  "violations": [
    { "rule": "wash_sale", "symbol": "AMD",
      "detail": "AMD sold at a loss on 2026-10-25 in ira_demo_1, listed in wash_sale_accounts. A buy on 2026-11-06 is day 12 of the 61-day window." },
    { "rule": "whole_shares", "symbol": "AMD",
      "detail": "41.7 shares is fractional; acct_demo_1 trades whole shares." },
    { "rule": "cash",
      "detail": "Buys exceed proceeds plus cash by $212.40 after rounding.", "amounts": { "shortfall": 212.40 } }
  ],

  "options": [
    { "id": "opt_e0b4", "label": "repaired",
      "summary": "Your trades, repaired to pass every rule",
      "trades": [
        { "symbol": "INTC", "side": "sell", "qty": 400, "lots": ["lot_03"] },
        { "symbol": "SOXX", "side": "buy",  "qty": 7 },
        { "symbol": "VOO",  "side": "buy",  "qty": 12 }
      ],
      "checks": { "cash": "pass", "whole_shares": "pass",
                  "wash_sale": "pass", "limits": "pass", "status": "pass" },
      "explain": "Replaces the AMD buy with a semiconductor fund that is not substantially identical, rounds to whole shares and leaves $38 cash." }
  ],

  "ledger": {
    "original": { "total_buys": 14612.40, "total_sells": 13200.00,
                  "cash_before": 1200.00, "cash_after": -212.40, "min_cash": 0, "shortfall": 212.40 },
    "repaired": { "total_buys": 14362.00, "total_sells": 13200.00,
                  "cash_before": 1200.00, "cash_after": 38.00, "min_cash": 0, "shortfall": 0 }
  },

  "decision_id": "dec_2026-11-06_e0b4"
}

How it works

The same rule checker runs on every Abacus Labs output, whatever produced it. Rules: cash including settlement, whole shares where the account requires them, position and sector limits, and the 61-day wash-sale window in both directions. The wash-sale check works because the account carries history, the recent sales that are no longer visible in the lots, and wash_sale_accounts, the linked accounts whose purchases count. Abacus Labs checks the lots, the history, recent commits and the trade list itself across all of them. Each failure comes back with the rule, the trade and a one-line reason the agent can relay.

Repair is not a heuristic. Abacus Labs reads the intent of the drafted list, which exposures it adds and removes, and solves for the smallest change that keeps that intent while passing every rule, using the same exact mixed-integer solver behind commit. The response carries the violations on the list exactly as sent, the repaired option, and a ledger that shows the original and repaired lists side by side: totals bought and sold, cash before and after, and any shortfall. The repaired option has an id and can be committed like any other.

Check mode is free and runs in tens of milliseconds for a pass. It is the same propose call with trades in place of goal, so agents that prefer to draft trades themselves still get a checked list, and the wash-sale state is shared with goal-based proposals and with commit.

Feasible trade lists by approach


LLM writes the trades      ####                                       10%

Larger LLM, same           ##########                                 25%

LLM runs its own solver    ####################################       90%   $3.20 / 70 s

Drafted, then checked      ########################################  100%   ms

Internal measurements, October 2026, frontier models on the same requests. Every list that passes the check meets the cash, whole-share, limit and wash-sale rules before it is returned.

Who uses this

Agents that draft their own trades
One propose call between the model's output and the broker's order API. The agent keeps its reasoning. Abacus Labs keeps the list executable and within the rules.
Broker agent teams
A single checker across every account type and every model version, with the certificate stored next to the order.
Advisor platforms
Pre-trade compliance on trades an adviser or their assistant typed, including wash sales across the household.

The Personal plan is free: 3 portfolios and 300 credits a month, no card. Paid plans add portfolios, credits and client use.

Related