# API order rejected for insufficient balance but you have enough

What a bot can spend is derived, not read: the free amount of the asset the order debits, in the wallet it debits, after venue holds and fees, from a snapshot that reflects the last balance change the bot knows of. When a field is missing or the snapshot may be older, the answer is unknown, not a number.

Canonical: <https://pitofficer.com/blog/api-order-rejected-insufficient-balance/>
Author: Eugene Palchukovsky <https://github.com/palchukovsky>
Description: Your order is rejected for insufficient balance while your bot reads enough: trace the gap to the wallet, the fee, open-order holds and snapshot age.
Published: 2026-11-26T21:23:35+02:00
Updated: 2026-11-26T21:23:35+02:00
Tags: order-validation, risk-controls, trading-bots, reconciliation

Your bot reads 2.0 ETH, buys 0.5 more and sends a sell for 2.5, and Binance
rejects it for insufficient balance. The balance was real; the venue checked
what the bot could spend.

:::stat
**1.2995 of 2.5 ETH**

The free ETH Binance checked the sell against: the bot's resting order held
1.2 ETH, the fee took 0.0005. Amounts, prices and fee rate are illustrative.
:::

:::timeline

1. **The bot reads its balance: 2.0 ETH.** All of it is free.
2. **Its resting sell for 1.2 ETH is accepted.** Binance sets that 1.2 ETH
   aside; the bot's snapshot still says 2.0.
3. **A market buy for 0.5 ETH fills.** The bot has too little BNB for the fee,
   so Binance takes it from the ETH received: 0.4995 ETH arrives.
4. **The bot sends a sell for 2.5 ETH.** Its snapshot plus what it bought.
5. **Binance rejects the sell.** It checks the 1.2995 ETH that is free.

:::

:::cards

- **The balance is not what you can spend.** Spendable is the free amount of
  the asset this order debits, in the wallet it debits, after the venue's holds
  for working orders and after fees.
- **Each venue publishes its own formula.** Binance reports a free amount per
  asset, Kraken a hold-aware extended balance, Alpaca buying power, and
  Polymarket the balance minus the unfilled size of open orders.
- **A snapshot is stale once it misses a balance change, however recent it
  is.** A balance read before a fill, an order or a fee sizes the next order
  from the wrong number. Without a stream that reports every balance change,
  it also needs a time limit.
- **A missing field, a stale value and a valid zero are three states.** An
  adapter that turns a removed field into 0 sizes orders from a number the
  broker no longer sends.
- **Matched is not settled.** On Polymarket a trade is matched, then mined,
  then confirmed; position balances update at confirmation, and nothing
  guarantees the next order's check sees them sooner.

:::

## Why does the venue reject an order your balance covers?

**Because it checks a different number from the one you read: the free amount
of the asset the order debits, in the wallet it debits, after its holds and
the fees.**

:::outcomes

- **Wallet: no difference here.** The sell debits the spot account, and all
  2.0 ETH are there.
- **Fee asset: 0.0005 ETH.** The buy was meant to pay its fee in BNB; with too
  little BNB, the full fee came out of the ETH received.
- **Venue hold: 1.2 ETH.** The bot's own resting sell holds it.
- **Snapshot age: what hid both.** The snapshot predates the resting sell and
  the fill, so it showed neither.
- **The trap: a fresher snapshot is not enough.** Read after the resting sell,
  the account shows 0.8 ETH free; the bot adds the 0.5 it buys, sends a sell
  for 1.3, and is rejected again for the fee.

:::

The fix: compute spendable per order, from a snapshot that reflects the bot's
last event on that asset, and refuse to compute it when the inputs do not
allow it. The cost is an extra request or a stream-maintained balance, and
orders that wait while the balance is unknown.

:::more[Terms this article uses]
The **spendable balance** is the amount of the debited asset that a new order
may commit right now: for a spot buy, the quote asset; for a spot sell, the
base asset, as Kraken's
[error reference](https://docs.kraken.com/exchange/guides/general/errors.md)
puts it for its insufficient-funds error. A **venue hold** is the part of a
balance the venue has set aside for working orders or other services and will
not let a new order use. **Snapshot age** is how far a balance snapshot may be
behind the account: the balance changes on the asset it may not reflect,
counted in your own events and, where changes can happen unseen, in time. A
trade is **settled** when the venue has finished it and its proceeds count in
the balance it checks new orders against.
:::

:::more[The worked rejection, balance by balance]
Binance spot ETH/USDT. The resting sell is for 1.2 ETH at 3,200 USDT, the
market buy fills 0.5 ETH at 3,000 USDT, and the rejected sell is for 2.5 ETH
at 3,050 USDT. BNB free stays at 0.0010 throughout.

| Step | ETH free | ETH locked | ETH the bot counts |
| --- | --- | --- | --- |
| 1. Reads the balance | 2.0000 | 0 | 2.0000 |
| 2. Resting sell accepted | 0.8000 | 1.2000 | 2.0000 |
| 3. Buy fills, fee in ETH | 1.2995 | 1.2000 | 2.5000 |
| 4. Sends a sell for 2.5 | 1.2995 | 1.2000 | Rejected |

The fee: at a 0.1% standard fee rate, with no tax or special commission, and
the BNB discount multiplier of 0.75 from the example in Binance's
[Query Commission Rates](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account)
reference, the fee on the 0.5 ETH received is 1.5 USDT at 3,000, discounted to
1.125 USDT, or 0.001875 BNB at 600 USDT per BNB, and the account holds 0.0010
BNB. Binance's
[commission FAQ](https://github.com/binance/binance-spot-api-docs/blob/master/faqs/commission_faq.md)
says that without enough BNB "the full commission will be taken out of your
received amount" instead: 0.1% of 0.5 ETH, so 0.4995 ETH arrived.

The bot sized the sell as the first snapshot plus what it bought; the venue
checked 1.2995 ETH free. The 1.2005 ETH between them is the 1.2 ETH hold and
the 0.0005 ETH fee.
:::

## Which wallet and which asset does the order debit?

**The side and the fee rule set the asset; the endpoint you trade through sets
the wallet. Check both before you compare a balance with an order.**

:::cards

- **The debit asset.** A buy debits the quote asset and a sell the base asset,
  on Binance and Kraken alike. On Polymarket a buy needs "sufficient pUSD" and
  a sell needs outcome tokens.
- **The asset the pair settles in.** Kraken's own example is a BTC/USD order
  from an account that holds only CAD: a similar-looking asset does not count.
- **The fee asset.** Where Binance's BNB discount is enabled, the fee is paid
  in BNB while BNB lasts, then in full from the asset you receive. Take what
  arrived from each fill, not from the order.
- **The wallet.** Binance's account endpoint reports the spot account; funds
  in the Funding account have to be transferred to Spot before they trade
  there.
- **Balances you can see but not trade.** Kraken lists staked and
  yield-bearing entries beside the base asset, some of them read-only. Check
  the base asset's entry, not every entry that starts with its code.

:::

The fee fields and entry suffixes are in
[the venue notes](#what-does-each-venue-document).

:::more[Funds in the funding wallet, not in spot]
Binance's funding-wallet query "currently supports" only Binance Pay, Binance
Card, Binance Gift Card and Stock Token assets, so it is not a general way to
find money that is not in spot. A balance you expected in spot and do not see
there may be a transfer that has not happened; the absence alone does not tell
you which cause it is.
:::

:::more[A fee asset that switches when BNB runs out]
The fallback is applied on the fill. A bot that sells "everything it bought"
is short by the fee from the first fill after BNB runs dry. Keep a BNB floor,
or size sells from each fill's fee amount and fee asset.
:::

:::more[Rounding a sell past the balance]
Binance requires a quantity that is a whole multiple of the pair's lot step.
With a step of 0.001 ETH (illustrative), rounding 1.2995 to the nearest step
gives 1.300, which passes the step-size check and fails the balance check.
Round sell quantities down; the cost is 0.0005 ETH of dust left behind.
Rounding below the minimum quantity fails a filter instead, a different
rejection that tells you nothing about balance.
:::

## What does the venue already hold for your working orders?

**Everything your working orders could still spend, so subtract the venue's
hold, never the order list you keep.**

:::cards

- **Binance spot: the free amount.** It is already net of what open orders
  and "other services" hold, so it is the number to check; free plus locked is
  not. Neither knows about an order still on its way to the venue.
- **Kraken spot: the extended balance.** Its formula subtracts what spot,
  non-margin orders hold, not a margin order's commitment. The plain balance
  documents no deduction for open orders.
- **Alpaca: buying power.** Open buy long and sell short orders reduce it
  until they are "executed or canceled"; a pending sell adds nothing until it
  executes. A sell of a long position checks the quantity available on the
  position.
- **Polymarket: balance minus open orders.** The unfilled size of open orders
  comes off, in pUSD for buys and in the outcome token for sells, and the
  allowance is a separate condition the same error covers.

:::

Then do not count the hold twice: the venue's number already excludes the
orders it reflects, and subtracting your reservations for them again refuses
orders you could afford. Subtract only reservations for orders the snapshot
does not reflect yet
([multiple trading bots on one account](/blog/multiple-trading-bots-one-account/)),
and among them an order whose submission timed out, at full size: it may be
working and holding funds
([duplicate orders after a timeout](/blog/duplicate-orders-after-timeout/)).

## How old is the balance your bot is looking at?

**Too old as soon as one balance change on that asset is not in it.**

It is the same problem as a stale price
([stale market data in a bot's loss limits](/blog/stale-market-data-trading-bot/)),
except that your own events age it: an order sent, acknowledged, filled,
canceled or rejected, a fee charged, a transfer. At the fill in the opening
timeline, a snapshot taken a second earlier is already wrong. Deposits, manual
trades and other bots change the balance with no event of yours; without a
stream that reports every balance change, also cap the snapshot's age in time.

```d2 title="When the bot may size from a balance, and when the answer is unknown"
direction: down
snap: "Snapshot of\nthe debited\nasset"
after: "Requested\nafter your\nlast event?"
age: "Stream\nsees every\nchange, or\nwithin the\ntime cap?"
present: "Asset in\nthe\nsnapshot?"
zero: "Asked to\nomit zeros,\nand you\ntrade the\nasset?"
fields: "Every\nfield\npresent?"
ledger: "Agrees\nwith your\nledger?"
spend: "Spendable:\nformula\nminus\nunshown\norders"
unknown: "Unknown:\nrefresh,\nnever size"
snap -> after
after -> age: "yes"
age -> present: "yes"
present -> fields: "yes"
present -> zero: "no"
zero -> fields: "yes: a\nzero entry"
fields -> ledger: "yes"
ledger -> spend: "yes"
after -> unknown: "no"
age -> unknown: "no"
zero -> unknown: "no"
fields -> unknown: "no"
ledger -> unknown: "no"
```

An unknown balance carries no number on purpose: a number gets compared with
an order.

:::cards

- **Re-read after every event.** A snapshot after the last event on the
  asset, before the next order. A full account read is expensive in Binance's
  request weight, so a bot that trades often spends its rate budget on balance
  reads, and every order waits a round trip.
- **Maintain it from the stream.** Binance pushes an update whenever a balance
  changes, carrying only the assets that possibly changed: merge it per asset,
  never replace the whole balance with it. The cost is a stream to monitor.

:::

:::more[Why the checks discard some good snapshots]
The first check is conservative: a snapshot requested before your last event
is discarded even though a fill that landed during the request may already be
in it. The second asks for evidence, because a snapshot requested after the
event can still lag it. The ledger it compares against records what each fill
delivered and what each working order holds, and the check also returns
unknown when a transfer, a manual trade or another service moved the balance;
that is the moment to stop and look.
:::

:::more[Rebuilding the balance after a reconnect]
Subscribe first, take a snapshot, then reconcile the buffered updates against
it: an update can already be in the snapshot or be older than it. Binance's
update time and snapshot time are only diagnostic; Binance does not document
them as comparable, so an asset whose order you cannot establish stays unknown
until a later update or snapshot settles it.
:::

:::more[An asset missing from the snapshot]
Binance can be asked to emit only the non-zero balances. In a valid answer for
the intended account, an asset you trade that is absent is then a zero. Any
other absence has no documented meaning, so it stays unknown. The adapter has
to know whether it asked.
:::

:::more[The venue rejects the order anyway]
An insufficient-balance answer is a rejection: release what the order
reserved, take a fresh snapshot and resize. A blind retry can fail again, and
a fill, a transfer or a cancel may have changed the balance in between.
:::

:::more[With the OpenPit SDK 0.11.0]
In the OpenPit SDK
[0.11.0](https://github.com/openpitkit/pit/releases/tag/v0.11.0), the
[Spot Funds](https://wiki.openpit.dev/Spot-Funds/) policy keeps `available`,
`held` and `incoming` per account and asset and reserves each passing order's
funds; your application keeps the ledger, seeds balances through account
adjustments and reconciles from the reported `delta`
([Balance Reconciliation](https://wiki.openpit.dev/Balance-Reconciliation/)).
:::

## What changes when a broker field changes meaning?

**The number your bot reads can stop meaning what it did while the field keeps
its name, and then disappear.**

When FINRA replaced the pattern day trader rule with intraday margin
standards, Alpaca replaced Day Trade Buying Power with Intraday Buying Power
and told API clients to read buying power instead.
Until removal, its Broker API kept the old fields: the day-trader flag and the
day-trade counts fixed, the day-trading buying power mirroring buying power.
Then both APIs removed them.

:::outcomes

- **The field is absent.** The broker no longer sends it, or the parse broke:
  stop, it is unknown, not 0.
- **Present, from a snapshot older than your last order event.** Stale:
  refresh first.
- **Present and 0, from a current snapshot.** Nothing to spend: refuse the
  order.
- **The trap: present, current and meaningless.** A fixed count of 0 passed
  a rule such as "fewer than three day trades" on every order: it enforced
  nothing, and the response itself could not reveal it.

:::

On the removal date, older versions of Alpaca's Python client, fixed four days
earlier, failed to parse the account: the model required fields the response
stopped sending. That loud failure is the
right one: the bot stops. The dangerous adapter defaults the missing field to
0, or to last week's cached value, and keeps trading. Make every field sizing
needs required; the cost is a bot that stops on the removal day, and reading
the broker's changelog moves that stop earlier.

## When are a match's proceeds spendable?

**On Polymarket, not before the trade is confirmed, and only once the balance
your next order is checked against shows them.**

:::timeline

1. **The bot holds 100 YES tokens and 10 pUSD.** It counts 10 pUSD; 10 are
   settled.
2. **It sells 100 YES at 0.60 and the trade matches.** It counts 70 pUSD; 10
   are settled.
3. **It sends a buy for 50 NO at 0.40 in another market, cost 20 pUSD.** The
   balance check does not see the proceeds yet: rejected.
4. **The trade is mined.** Still 10 pUSD settled.
5. **The trade is confirmed.** Position balances update: 70 pUSD settled.

:::

Times are illustrative; the sell is fee-free, the allowance is granted and no
other orders are open, so only the balance can fail. Polymarket gives no
guarantee about when the check sees the proceeds: count them as pending
through confirmation, confirm the collateral is in the balance before you
reuse it, and do not count the sold tokens as sellable again in between. The
cost is capital idle until finality, which the lifecycle page does not quantify: missed
trades for a strategy that recycles proceeds quickly.

:::more[A match that never settles]
A trade being retried can end failed, and settlement is atomic: "either the
entire trade succeeds or nothing happens". You still hold the tokens and the
proceeds never arrive. A bot that credited them at the match has spent money
it does not have.
:::

:::more[A rejection that is about the allowance]
The same error covers a missing approval. Check the balance and the allowance
before you resize an order that may have been rejected for an approval.
:::

## What should your bot check before it sizes an order?

- Every order is checked against the spendable amount of its debit asset, in
  the wallet the endpoint trades from, by the venue's own formula.
- Sells are sized from what each fill delivered after its fee, rounded down to
  the lot step.
- A snapshot that may miss the last balance change on the asset, is past its
  time cap when changes can go unseen, or lacks a required field is unknown,
  never 0.
- The venue's hold is subtracted once: the venue's number, minus your
  reservations for orders the snapshot does not reflect, including orders
  with an unknown outcome.
- The adapter knows whether it asked the venue to omit zero balances.
- Proceeds count only once settled and shown in the balance; on Polymarket,
  not before the trade is confirmed.
- A broker changelog that removes or redefines a field your bot reads is a
  change to the bot, done before the removal date.

## What does each venue document?

**The codes, fields, endpoints and dates behind everything above, venue by
venue.**

:::more[Binance spot]

- **Rejection.** `-2010` with "Account has insufficient balance for requested
  action."
- **Spendable.** `free` of the debited asset. The
  [spot glossary](https://github.com/binance/binance-spot-api-docs/blob/master/faqs/spot_glossary.md)
  defines `free` as what "can be used to trade or withdraw" and `locked` as
  what is "locked in open orders and other services". `externalLockUpdate`
  fires when "an external system" locks part of the spot balance.
- **Snapshot.** `GET /api/v3/account`, 20 request weight; its example shows
  `"accountType": "SPOT"`, and it carries `updateTime`. `omitZeroBalances`,
  announced on 2024-04-02: set to `true`, it "emits only the non-zero balances".
- **Fees.** The BNB `discount` multiplier comes from Query Commission Rates.
  The
  [user data stream](https://github.com/binance/binance-spot-api-docs/blob/master/user-data-stream.md)
  `executionReport` carries the commission amount in `n` and its asset in `N`:
  when `N` is the asset you bought, subtract `n` from what arrived.
- **Balance stream.** `outboundAccountPosition` (`f`, `l`) is sent "any time
  an account balance has changed" (since the event was added on 2019-08-15,
  per the
  [changelog](https://github.com/binance/binance-spot-api-docs/blob/master/CHANGELOG.md))
  and "contains the assets that were possibly changed". Its `u` ("Time of last
  account update") and the snapshot's `updateTime` are not documented as
  comparable. `balanceUpdate` fires on deposits, withdrawals and "transfer of
  funds between accounts (e.g. Spot to Margin)".
- **Wallets.** Funds in the Funding account have to be transferred to Spot "if
  you want to trade on the Spot Market", per the
  [transfer guide](https://www.binance.com/en/support/faq/detail/472198b9d0fc4c6280a9c061100b2db8)
  (updated 2025-11-28).
  [Query Funding Wallet](https://developers.binance.com/docs/wallet/asset/funding-wallet),
  `POST /sapi/v1/asset/get-funding-asset`, is the query with the limited asset
  list.
- **Lot step.** The
  [`LOT_SIZE` filter](https://github.com/binance/binance-spot-api-docs/blob/master/filters.md)
  requires `quantity % stepSize == 0` and a quantity of at least `minQty`.

Sources: Binance
[account endpoints](https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/account),
[spot glossary](https://github.com/binance/binance-spot-api-docs/blob/master/faqs/spot_glossary.md),
[user data stream](https://github.com/binance/binance-spot-api-docs/blob/master/user-data-stream.md)
and
[commission FAQ](https://github.com/binance/binance-spot-api-docs/blob/master/faqs/commission_faq.md).
:::

:::more[Kraken spot]

- **Rejection.** `EOrder:Insufficient funds`; the
  [error reference](https://docs.kraken.com/exchange/guides/general/errors.md)
  checks the quote currency on a spot buy and the base on a sell.
- **Spendable.**
  [`BalanceEx`](https://docs.kraken.com/api/docs/rest-api/get-extended-balance)
  (`POST /private/BalanceEx`) documents `balance + credit - credit_used -
  hold_trade`, where `hold_trade` holds spot, non-margin orders: "held amounts
  only include spot non margin orders". It lists entries with suffixes such as
  `.S` for staked and `.B` for yield-bearing balances, calls some of them
  read-only, and directs you to the base asset to transact.
- **Not spendable.** The plain
  [`Balance`](https://docs.kraken.com/api/docs/rest-api/get-account-balance)
  endpoint returns cash balances "net of pending withdrawals" and documents no
  deduction for open orders. `TradeBalance` summarizes "collateral balances,
  margin position valuations, equity and margin level", not what a spot order
  can spend.
- **Wrong quote asset.** The
  [Insufficient Funds article](https://support.kraken.com/articles/115006599467--Insufficient-Funds-error-when-placing-an-order)
  (updated 2025-08-08) gives the BTC/USD order from a CAD-only account.

:::

:::more[Alpaca]

- **Spendable.** `buying_power` for equity buys, `non_marginable_buying_power`
  for crypto, from `GET /v2/account`; the position's `qty_available` for sells
  of a long position, from `GET /v2/positions`. Open orders on the position and
  shares locked for covered calls reduce it.
- **Holds.** Open buy long and sell short orders reduce buying power until
  they are "executed or canceled"; sell long and buy to cover orders "do not
  replenish your available buying power until they are executed"
  ([orders](https://docs.alpaca.markets/us/docs/orders-at-alpaca)).
- **Which buying power.** The
  [account reference](https://docs.alpaca.markets/reference/getaccount-1)
  defines `buying_power` as "Current available $ buying power" and
  `non_marginable_buying_power` as "Current available non-margin dollar buying
  power". On a margin account `buying_power` includes borrowed funds (the
  reference defines it as `cash` only at multiplier 1), so a bot meant to
  trade cash only checks `non_marginable_buying_power`, which Alpaca's
  [support answer](https://alpaca.markets/support/why-do-i-get-an-error-of-insufficient-balance-when-my-cash-balance-holds-the-requested-amount)
  also names as crypto buying power, since crypto needs settled cash.
- **The rule change.** FINRA
  [Regulatory Notice 26-10](https://www.finra.org/rules-guidance/notices/26-10)
  (2026-04-20) replaced the day-trading margin requirements, including the
  pattern day trader test and its 25,000 USD minimum equity, with intraday
  margin standards, effective 2026-06-04, with a phase-in allowed until
  2027-10-20.
- **The fields.** Alpaca's
  [announcement](https://alpaca.markets/blog/finra-retires-the-pdt-rule-introducing-alpacas-new-intraday-margin-framework/)
  (2026-04-27, updated 2026-06-04) told API clients to replace
  `pattern_day_trader`, `daytrade_count`, `last_daytrade_count`,
  `last_daytrading_buying_power` and `daytrading_buying_power` with
  `buying_power`. Until removal, it says, the Broker API fields returned
  `pattern_day_trader` `false` and both day trade counts 0, and both
  day-trading buying power fields mirrored `buying_power`, so a check such as
  "`daytrade_count` below 3" passed on every order. After the
  [2026-06-03 deprecation](https://docs.alpaca.markets/us/changelog/2026-06-03-pdt-651df23),
  the [2026-07-06 changelog](https://docs.alpaca.markets/us/changelog/2026-07-06-pdt-db49dba)
  removed `daytrade_count`, `daytrading_buying_power` and
  `pattern_day_trader` from the Trading API account, and those three plus
  `last_daytrade_count`, `last_daytrading_buying_power` and `bod_dtbp` from
  the Broker API trading account.
- **The parse failure.** An alpaca-py user reported
  [validation errors](https://github.com/alpacahq/alpaca-py/issues/697) for
  the account model, opened 2026-07-06: `last_daytrading_buying_power` and
  `last_daytrade_count` were "Field required". The fix, which lets responses
  omit the deprecated fields, shipped in
  [v0.43.5](https://github.com/alpacahq/alpaca-py/releases/tag/v0.43.5) on
  2026-07-02. The dangerous version is an adapter that reads
  `account.get("daytrading_buying_power", 0)`.

Sources: Alpaca [orders](https://docs.alpaca.markets/us/docs/orders-at-alpaca),
[account](https://docs.alpaca.markets/reference/getaccount-1) and
[positions](https://docs.alpaca.markets/reference/getallopenpositions).
:::

:::more[Polymarket]

- **Spendable.** `balance - Σ(openOrderSize - filledAmount)`, in pUSD for
  buys and in the outcome token for sells, with the allowance granted; from
  [`GET /balance-allowance`](https://github.com/Polymarket/py-clob-client-v2/blob/main/py_clob_client_v2/endpoints.py)
  and your open orders.
- **Rejection.** "not enough balance / allowance" covers a shortfall in
  either, and an allowance error names "one missing spender at a time".
  Rejection bodies also report a `sum_of_matched_orders`, and a client report
  describes the check as balance against open plus matched orders plus the new
  one
  ([rs-clob-client-v2 #36](https://github.com/Polymarket/rs-clob-client-v2/issues/36));
  the lifecycle page does not define that term.
- **When it checks.** At submission, and on markets with a delay window again
  when the delay expires.
- **Trade states**, from the
  [order lifecycle](https://docs.polymarket.com/concepts/order-lifecycle):
  `MATCHED` - "Trade matched, sent to executor for onchain submission"; not
  terminal. `MINED` - "Transaction mined into the blockchain"; not terminal.
  `CONFIRMED` - "Trade achieved finality, successful"; terminal; at this step,
  "your position balances update". `RETRYING` - "Transaction failed, being
  retried"; not terminal. `FAILED` - "Trade failed permanently"; terminal.

Sources: Polymarket
[order lifecycle](https://docs.polymarket.com/concepts/order-lifecycle) and
[error codes](https://docs.polymarket.com/resources/error-codes).
:::

## What does the spendable check look like in code?

:::more[The spendable check in pseudocode]
One account, one venue adapter. Everything venue-specific is in the formula
and the field list.

```text
# Pseudocode. One account, one venue adapter. Amounts are exact decimals.

on_balance_event(asset):              # once per asset the event touches: base, quote,
    seq[asset] += 1                   # fee asset. Own order sent, acknowledged, filled,
                                      # canceled, rejected; fee charged; any balance
                                      # change on the stream (Binance: balanceUpdate,
                                      # externalLockUpdate, outboundAccountPosition)

take_snapshot(omit_zero):
    started = copy(seq)               # the events the bot had seen when it asked
    taken = now()
    raw = venue.account(omit_zero)    # Binance: omitZeroBalances=omit_zero
    return Snapshot(raw, started, taken, omit_zero)

spendable(asset, snap):
    if snap.started[asset] < seq[asset]:      # 1. an event after the request left
        return Unknown(asset + ": requested before the last known event")
    if not STREAM_SEES_EVERY_CHANGE and now() - snap.taken > MAX_AGE:
        return Unknown(asset + ": older than MAX_AGE")   # time cap: unseen changes
    entry = snap.raw.balances.get(asset)
    if entry is none:
        if not (snap.omit_zero and asset in TRADED_ASSETS):
            return Unknown(asset + ": not in the snapshot")
        entry = ZERO_ENTRY[venue]     # omitted because zero; still checked below
    for field in REQUIRED[venue]:     # Binance: free, locked. Kraken: balance,
        if field not in entry:        # credit, credit_used, hold_trade
            return Unknown(asset + ": " + field + " missing")
    if not ledger.matches(asset, entry):      # 2. evidence: e.g. free and locked each
        return Unknown(asset + ": lags or differs from own events")  # equal the ledger's
    return FORMULA[venue](entry) - reserved_not_reflected(asset, snap)

may_send(order):
    s = spendable(order.debit_asset, latest_snapshot)
    if s is Unknown:
        return REFRESH                # never size from a guess; alert if it repeats
    return order.debit_amount + order.fee_in_debit_asset <= s
```

:::

## What else do people ask?

:::more[Why does Binance say my account has insufficient balance when I have enough?]
Binance checks the `free` amount of the asset the order debits, and that is
smaller than the total you read whenever open orders hold part of it
(`locked`), the fee came out of the asset you bought because BNB ran out, or
your snapshot does not reflect your last fill or order. Compare the order with
`free` from a snapshot that does, and size sells from what each fill
delivered.
:::

:::more[Do open orders lock my balance?]
Yes, on every venue covered here. Binance moves the amount from `free` to
`locked`; Kraken counts it in `hold_trade`, which `BalanceEx` subtracts and
plain `Balance` does not; Alpaca reduces buying power for open buy long and
sell short orders; Polymarket subtracts the unfilled size of open orders from
the maximum order size. A successful cancel frees the unfilled part; spend it
once a balance you read shows it released.
:::

:::more[Why does Kraken say insufficient funds when my balance shows enough?]
Kraken documents its `Balance` endpoint as cash balances net of pending
withdrawals and gives no adjustment for open orders. `BalanceEx` documents the
hold-aware formula, `balance + credit - credit_used - hold_trade`.
`TradeBalance` summarizes "collateral balances, margin position valuations,
equity and margin level", not what a spot order can spend. Check the quote
currency on buys and the base currency on sells, and leave room for the fee.
:::

:::more[What replaces day-trading buying power at Alpaca?]
`buying_power`. Alpaca removed `daytrade_count`, `daytrading_buying_power` and
`pattern_day_trader` from the Trading API account on 2026-07-06, after FINRA replaced the pattern
day trader rule with intraday margin standards. Treat a missing field as an
error that stops sizing, not as zero.
:::

:::more[Why does Polymarket say not enough balance or allowance right after my sell matched?]
A matched trade is not settled: position balances update when it reaches
`CONFIRMED`, and until then it can still fail. Treat the proceeds as pending
through confirmation and check `GET /balance-allowance` before you spend them;
if the balance is there, the allowance is the shortfall.
:::

## Where should I read next?

- [Multiple trading bots on one account](/blog/multiple-trading-bots-one-account/):
  reserving before you send, and subtracting the venue's hold once.
- [Duplicate orders after a timeout](/blog/duplicate-orders-after-timeout/):
  an order whose outcome is unknown still holds funds.
- [Stale market data in a bot's loss limits](/blog/stale-market-data-trading-bot/):
  the same age check for prices.
- Polymarket [order lifecycle](https://docs.polymarket.com/concepts/order-lifecycle):
  the trade states between a match and finality.
