> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abacuslabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Trade checks

> Check trades you or the person drafted. Get the verdict and the nearest legal list.

```bash theme={null}
curl -s https://api.abacuslabs.ai/v1/trades/check \
  -H "Authorization: Bearer $ABACUS_API_KEY" -H "Content-Type: application/json" \
  -d '{"account_id": "acct_demo_concentrated", "trades": [{"symbol": "UNH", "side": "buy", "quantity": 5}]}'
```

| Field | Required | Meaning |
| - | - | - |
| `trades` | yes | `[{symbol, side, quantity, lots?}]`. `lots` (sells, optional): the lot ids to sell, as strings (`["lot_3", "lot_2"]`) or as the lot objects an option returns. The quantity comes from the trade: the lots are used in order. Without `lots`, Abacus Labs picks them. |
| `account_id`, `account`, `accounts` + `account_id`, or `snapshot_id` | one of them | As for [proposals](https://docs.abacuslabs.ai/concepts/proposals.md#request). Trades are checked for one account; the others count for wash sales. |
| `policy` | no | Rules to check besides the account's own. A saved account's policy applies too; `keep` and `exclude` lists add up with it. See the policy rules below. |
| `tax_rates` | no | `{short_term, long_term, state?, niit?}` as fractions: your rates, for `estimated_tax` and the `tax.max_tax` check. Without them, top federal rates (and the violation says so). |
| `wash_sale_policy` | no | `same_index` (default) or `exact`. |
| `max_credits` | no | Refuse the call (`402 max_credits_exceeded`, nothing charged) if it would cost more credits than this. See [Credits](https://docs.abacuslabs.ai/credits.md). |

The answer is always HTTP `200`. A failing check is an answer, not an error.

| `status` | Meaning | `results` |
| - | - | - |
| `pass` | Legal as sent. | an `option` block with your trades, lots and impact; `violations` (empty) |
| `repaired` | Your list broke a rule. The `option` is the nearest legal list. | `option` and `violations` |
| `rejected` | Nothing survives repair, or a policy limit (tax, gain, caps) is broken. | `violations`, and the `option` marked `checks: "fail"` when there is one |

The `violations` block also carries `ledger`: `{original, repaired}`, each with `per_trade` (`symbol`, `side`, `qty`, `est_price`, `cost`), `total_buys`, `total_sells`, `cash_before`, `cash_after`, `min_cash` and `shortfall`, so you can see how a repair changed the cash.

A `pass` or `repaired` check costs 5 credits. A `rejected` check is free.

## The rules

| `rule` | Checks |
| - | - |
| `whole_shares` | Whole shares when the account's rule or the policy says so. |
| `cash` | Buys are covered by cash plus sales, above the account's `min_cash`. `amounts` gives the shortfall. |
| `wash_sale` | A loss sale within 30 days of a buy of the same security (or a fund that tracks the same index), and a buy within 30 days of a loss sale. Across every account sent, the saved accounts linked to it, and the loss sales you [committed](https://docs.abacuslabs.ai/concepts/commits.md). |
| `max_position`, `max_sector` | The account's position and sector limits. |
| `no_short`, `oversell` | No short positions; no sale of more than is held. |
| `price` | Abacus Labs has market data for the symbol. A trade without it is dropped. |

The policy's rules are checked too:

| `rule` | Checks | When broken |
| - | - | - |
| `keep`, `exclude`, `exclude_themes`, `buy_only`, `no_sells` | Each trade against the lists | The trade is removed; `status` is `repaired` (or `rejected` if nothing is left) |
| `sell_lots` | A sell uses only lots of the allowed term (`short_term_only`: lots held a year or less) | The sell is narrowed to its allowed lots, or removed when it has none; `repaired` |
| `sector_cap`, `position_cap` | `policy.sectors` and `policy.positions` / `max_position` after the trades, counting what the funds hold | `rejected` |
| `max_names` | Holdings after the trades | `rejected` |
| `max_tax`, `max_gain` | Estimated tax and net realized gain of the list | `rejected` |
| `max_turnover` | (bought + sold) / 2 / account value | `rejected` |

A `rejected` check's option has `checks: "fail"` and repeats the violations: do not place it.

The check's `option` has its own `id`. To commit what you checked, commit the proposal's option when the check `pass`ed (same trades), or the check's option id when it `repaired` the list and the person approved the repaired trades. A sell naming a lot id the account does not hold, or a quantity of 0, is refused with `422` and the field.

This is the request at the top of this page, run after the [Quickstart](https://docs.abacuslabs.ai/quickstart.md) committed a loss sale of UNH. A buy of UNH within 30 days is a wash sale (trimmed):

```json theme={null}
{ "object": "trade_check", "status": "rejected", "credits_charged": 0,
  "answer": "None of the drafted trades survive the rule check: UNH: buying UNH now would wash an earlier loss: ...",
  "results": [ { "type": "violations", "data": {
    "violations": [ { "rule": "wash_sale", "symbol": "UNH",
      "detail": "buying UNH now would wash an earlier loss: UNH sold 0 days ago in commit cmt_8f5772607fb3 (acct_demo_concentrated) with a realized loss. Wait until 31 days after that sale, or buy a fund that tracks a different index." } ],
    "ledger": { "original": { "total_buys": 2037.3, "total_sells": 0.0, "cash_before": 6200.0, "cash_after": 4162.7, "min_cash": 1000.0, "shortfall": 0.0, ... },
                "repaired": { "total_buys": 0.0, "cash_before": 6200.0, "cash_after": 6200.0, ... } } } } ],
  "warnings": [ "Wash sales are checked against the accounts in this request and the saved accounts linked to it; ...",
                "dropped buy of UNH so the earlier loss sale is not washed" ] }
```

> [!TIP]
>
> Run a check on the chosen trades right before you place them, with fresh holdings.

> [!WARNING]
>
> Wash-sale checks only see the accounts and trades Abacus Labs knows about. They cannot see a 401(k) or a spouse's account you did not send. Every answer says so in `warnings`.

Reference: [Check trades](https://docs.abacuslabs.ai/api-reference/trade-checks/check-trades.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.