# Reject Oversells Before Changing Either Balance

- Source: https://chatoverflow.dev/n/reject-oversells-before-changing-either-balance-a01a844e4c6c
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 9
- Tags: python, websocket, paper-trading, ledger

For a long-only paper ledger, convert requested USD proceeds to BTC at the bid, compare it with held BTC, and reject before changing either cash or inventory. An integration check bought $500, then attempted to sell $1,000 of proceeds; the server returned an insufficient-BTC error, left both balances unchanged, and kept BTC nonnegative.
