# Spot Trading Loss Controls Design

## Context

Recent synced spot fills show repeated small realized losses across lower-liquidity spot symbols. The bot also has current positions in symbols outside the most liquid set, so sell automation must still be able to exit existing holdings while new buys should be restricted.

## Scope

This change implements two controls:

1. Restrict future spot buy and AI prediction symbols to `BTCUSDT`, `ETHUSDT`, `BNBUSDT`, and `SOLUSDT`.
2. Add a cost-aware sell guard for automatic and AI-driven spot sells.

The change does not alter exchange order placement, protective stop orders already resting at Binance, futures trading, or manual account operations.

## Trading Pool

`BINANCE_AUTO_BUY_SYMBOLS` and `BINANCE_AI_TRADER_SYMBOLS` should be narrowed to the four high-liquidity USDT pairs. `BINANCE_AUTO_SELL_SYMBOLS` should remain unchanged so the bot can still process exits for existing non-core holdings.

## Sell Guard

The sell guard uses locally synced `spot_trade_fills` as the source of cost basis. It reconstructs open lots with FIFO accounting:

- BUY fills add net base quantity and USDT cost.
- SELL fills consume oldest lots.
- Fees in base reduce net received quantity.
- Fees in USDT increase buy cost or reduce sell proceeds.
- Other fee assets are ignored for guard purposes to avoid blocking on unavailable conversion data.

For a candidate sell, if there is no local open-lot cost basis, current behavior is preserved. If cost basis exists, the guard estimates proceeds as `quantity * bid_price`. A sell is allowed when estimated proceeds are at least the matched FIFO cost, or when every matched lot is at least `BINANCE_AUTO_SELL_MIN_HOLD_SECONDS` old. Otherwise it is rejected with `sell below cost before minimum hold`.

Default settings:

- `BINANCE_AUTO_SELL_REQUIRE_PROFIT=true`
- `BINANCE_AUTO_SELL_MIN_HOLD_SECONDS=21600`

## Data Flow

Automatic sell path:

1. Scan candidate symbols using existing downside scoring.
2. Run existing sell risk checks.
3. Run cost-aware sell guard before reserving or submitting the sell.
4. Record rejected auto-sell run when guard blocks.

AI sell path:

1. Parse AI prediction and apply existing confidence/risk checks.
2. Run the same cost-aware sell guard before reservation or order placement.
3. Record rejected AI and auto-sell runs when guard blocks.

## Testing

Tests must cover:

- The guard blocks a below-cost sell before the minimum hold period.
- The guard allows a below-cost sell after the minimum hold period.
- The guard allows a sell with no local cost basis to preserve manual-position behavior.
- Automatic sell runner applies the guard.
- AI sell runner applies the guard.
- New config defaults and validation are covered.

