> For the complete documentation index, see [llms.txt](https://bump.sh/tie-tech/hub/b2b-api/doc/broker-overview/llms.txt)

# Positions, fees, and accounting

An account can hold `YES` and `NO` contracts in the same market simultaneously.

- `presentation=dual` returns `yes_qty` and `no_qty` separately, plus `yes_reserved` and `no_reserved` locked by active limit orders.
- `presentation=net` returns signed `qty = yes_qty - no_qty`; positive is `YES`, negative is `NO`. This is the default.

Use `dual` for balances and available-quantity calculations. `POST /trading/accounts/{account_id}/merge` converts equal `YES` and `NO` quantities back into cash. Setting `auto_merge: true` on an order requests automatic merging when both token balances accumulate after a fill.

`/accounting` delivers atomic accounting updates containing cash, margin-release, and position deltas. `ref_id` and `client_ref_id` correlate updates with orders or merge commands. Settlement and void are delivered as `accounting_payout`; `GET .../payouts` provides payout records for reconciliation.

> **Critical:** `/accounting` is the authoritative incremental feed, and the public API does not provide deep replay beyond the one-hour WebSocket window. REST positions and payouts do not reconstruct every missed accounting delta. If `/accounting` returns `resume_too_old`, do not reconnect without `since` and assume the ledger is complete; stop automatic accounting application and follow the agreed operational reconciliation process.

## Fees and balance accounting

### Fee calculation

For an execution quantity `Q` at execution price `P`, the trading fee is:

```text
fee = ceil_to_1e-9(Q × P × (1 − P) × fee_rate)
```

`ceil_to_1e-9` rounds upward to the next multiple of `0.000000001`; it does not round to a whole currency unit. Quantities, prices and cash use nine-decimal precision. Use decimal or fixed-point arithmetic rather than binary floating point for financial calculations.

The rate depends on the execution's liquidity role:

- **Taker:** the incoming order executes against available liquidity. Immediate executions of LIMIT IOC and LIMIT FOK use the taker rate, as do MARKET executions.
- **Maker:** a resting order supplies liquidity to an incoming order. A LIMIT order is not automatically a maker order; its immediate executions are taker executions, while a permitted resting remainder can later execute as maker.

Use the applicable maker/taker rates for your integration. The rates in the example below are illustrative, not a published tariff or default. This API reference does not specify a rate-discovery endpoint.

Commission depends on the execution price, not just the order's limit price. The factor `P × (1 − P)` is the same for complementary YES/NO prices. A better execution price can increase the fee component when it moves closer to `0.50`; do not estimate actual fees solely from the limit price.

### LIMIT: fees on top

A LIMIT order specifies the contract quantity. Fees are charged in addition to the contract cost; they do not reduce the submitted `qty`. This also applies to LIMIT IOC and LIMIT FOK. The limit `price` protects the contract price, not the total amount including fees.

For a LIMIT BUY YES of quantity `Q` at limit price `P_limit`, the broker reserves:

```text
fee_reserve = ceil_to_1e-9(Q × P_limit × (1 − P_limit) × taker_rate)
locked = Q × P_limit + fee_reserve
```

On execution, the actual contract cost and execution fee are charged. Unused reserves are released through `/accounting`, including the difference due to price improvement or the applicable maker rate. Cancellation releases the reserve for the unfilled quantity; it does not reverse fees already charged on executions. An IOC partial fill therefore retains its execution fees, while a FOK cancelled without fills has no execution fee.

### MARKET BUY: fees within the budget

For MARKET BUY, `volume` is the total purchase budget `B`, including trading fees. The broker reserves this budget, and execution must satisfy:

```text
filled_volume + filled_fee <= B
```

At a price level `P`, the documented quantity calculation is:

```text
Q = floor_to_1e-9(B_remaining / (P × (1 + (1 − P) × taker_rate)))
```

`B_remaining` is the unspent budget; `floor_to_1e-9` rounds quantity down to nine decimal places. The fee is still rounded upward as described above, and the total-budget constraint remains mandatory. Use the reported execution and accounting amounts for reconciliation rather than treating a client-side quantity estimate as the final result.

MARKET SELL specifies `qty`, not a purchase budget. Its execution fees are reflected in the net sale cash change delivered by `/accounting`.

### Applying accounting updates

In an `accounting_update`, use `payload.deltas`:

- `cash` is the actual cash change **including execution fees**. For a purchase, the charged amount includes contract cost plus fee; for a sale, the cash change is net of fees.
- `margin_release` is the amount released from the order's reserved funds for the executed or cancelled quantity, including the associated fee reserve.
- `position_delta` carries the position change.

For the broker's free/frozen cash balances, apply the accounting amounts as follows:

```text
free_balance   += deltas.cash + deltas.margin_release
frozen_balance -= deltas.margin_release
```

`/accounting` aggregates changes atomically for a command-processing step, which may include multiple executions. The `filled_fee` field in an order update is a cumulative fee total for that order; `fees_paid` in a position response is a cumulative total for that market. These totals are for reporting and reconciliation, **not additional debits**: do not subtract them again after applying `deltas.cash`.

### Example: a limit buy executed as maker

Assume `BUY YES 100 @ 0.30`, an illustrative taker rate of `0.0020`, and an illustrative maker rate of `0.0010`:

```text
reserved fee       = 100 × 0.30 × 0.70 × 0.0020 = 0.042000000
locked             = 30.000000000 + 0.042000000 = 30.042000000
```

If the order rests and later fills entirely at `0.30` as maker:

```text
actual fee         = 100 × 0.30 × 0.70 × 0.0010 = 0.021000000
deltas.cash        = -30.021000000
deltas.margin_release = 30.042000000
```

Applying the update releases the full reserve, charges the actual purchase cost and fee, and returns the unused `0.021000000` fee reserve to the free balance. Do not debit the reported fee a second time.

