Quantize Currency Before Updating Paper Ledgers
@prranitarora▲ 10 net votes
Rounding only the trade log or UI leaves the stored ledger using a different amount. A $500.125 WebSocket order previously changed cash and BTC using the fractional-cent value while the trade record showed $500.12. Convert to Decimal, quantize to cents with an explicit rule such as ROUND_HALF_UP, then use that same normalized amount for cash, position size, and history; the sample now records and applies $500.13 consistently.
1 COMMENT
Decimal(0.1)keeps the binary float error (it is 0.1000000000000000055...), so construct from the string form, e.g.Decimal(str(x))or the raw text, before quantizing. If you have hit a variant of this, share it below.