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

# Re-anchor daily loss

> POST /v1/balances/{account_id}/daily-loss/reanchor — reset today's DLL anchor to current cash after migration.

Use this operation after importing an account or correcting its cash balance. It
moves today's daily-loss anchor to the account's **current cash balance** while
preserving the existing dollar loss allowance.

```http theme={null}
POST /v1/balances/{account_id}/daily-loss/reanchor
```

`operationId: reanchorDailyLoss`

A firm API key can call this route for an account in its firm. The operation:

1. Calculates the existing allowance as `previous start_of_day_balance - previous daily_loss_limit_trigger`.
2. Sets `start_of_day_balance` to current `balance`.
3. Sets `realized_day_pnl` to `0`.
4. Sets `daily_loss_limit_trigger` to the new anchor minus the preserved allowance.
5. Publishes `balance.updated` so live risk enforcement uses the new trigger.

## Migration example

An imported account was created at `$50,000`, with a `$1,250` DLL:

```text theme={null}
Previous anchor:  $50,000.00
Previous trigger: $48,750.00
DLL allowance:     $1,250.00
```

After a migration withdrawal, current cash is `$47,685.28`. Re-anchoring
produces:

```text theme={null}
New anchor:  $47,685.28
New trigger: $46,435.28
```

```bash theme={null}
curl -X POST "$TRADARA_BASE_URL/v1/balances/$ACCOUNT_ID/daily-loss/reanchor" \
  -H "X-Tradara-Api-Key: $TRADARA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reason_code": "PLATFORM_MIGRATION"
  }'
```

## Response — `200 OK`

```json theme={null}
{
  "account_id": "5b1c8a2e-9f2d-4d3c-b6f0-2b6c5b6e1f9a",
  "reason_code": "PLATFORM_MIGRATION",
  "daily_loss_value": "1250.00",
  "previous_start_of_day_balance": "50000.00",
  "previous_daily_loss_limit_trigger": "48750.00",
  "start_of_day_balance": "47685.28",
  "daily_loss_limit_trigger": "46435.28",
  "balance": {
    "account_id": "5b1c8a2e-9f2d-4d3c-b6f0-2b6c5b6e1f9a",
    "balance": "47685.28",
    "start_of_day_balance": "47685.28",
    "realized_day_pnl": "0.00",
    "daily_loss_limit_trigger": "46435.28"
  }
}
```

<Warning>
  This operation anchors to cash, while the firm daily-loss breach compares live
  equity with the resulting trigger. Flatten positions before re-anchoring if you
  need exactly the full DLL allowance from the account's current state.
</Warning>

<Warning>
  Re-anchoring starts a new daily measurement window and clears
  `realized_day_pnl`. Use it for migration or an explicit administrative
  correction before trading, not as a routine way to restore intraday loss room.
</Warning>

<Warning>
  Re-anchoring updates the DLL anchor and trigger, but it does not unlock an
  account that already has a hard daily-loss breach. Correct the account before it
  breaches, or use the applicable breach-review workflow separately.
</Warning>

## Errors

| HTTP          | Meaning                                                                          |
| ------------- | -------------------------------------------------------------------------------- |
| `400`         | Invalid account id or missing `reason_code`.                                     |
| `403`         | Caller is not a firm operator or platform admin.                                 |
| `404`         | Account is unknown or outside the API key's firm.                                |
| `409`         | The account has no valid daily-loss trigger from which to preserve an allowance. |
| `421`         | Request hit the wrong balances shard. Retry through the gateway.                 |
| `502` / `503` | Balances service unavailable.                                                    |
