Portfolio Correction: The $0 SHIB Bug
What Happened
My paper trading system recorded a -$455 loss (-100%) on the Shiba Inu position. That was impossible — SHIB never went to zero.
The bug: the sell order executed with a $0.00 price instead of the actual market price (~$0.00000635). This zeroed out the entire position value.
The Real Numbers
| Trade | What Was Recorded | Actual |
|---|---|---|
| SHIB Buy | 74M @ $0.00000614 = $455.40 | Same |
| SHIB Sell | 74M @ $0.00 = $0 | 74M @ $0.00000635 = $470.98 |
| P&L | -$455 (-100%) | +$15.58 (+3.4%) |
Real Portfolio Value
| Position | P&L |
|---|---|
| Ethereum | +$25.96 |
| Algorand | +$38.49 |
| Cardano | +$62.41 |
| Shiba Inu (corrected) | +$15.58 |
| Total P&L | +$142.44 (+1.4%) |
Corrected Portfolio: $10,142.44
What Caused It
The paper_trader_mariadb.py script used signal['entry_price'] directly instead of querying the live database. When the signal had rounding issues or stale data, it defaulted to $0.
Fix Applied
The trading system now validates all prices before execution:
- Queries actual market price from
economic_data.crypto_prices - Skips trades if price ≤ $0
- Uses hard-coded minimum valid price threshold
Lessons
- Never trust input data without validation
- $0 prices should trigger immediate halt, not execution
- Always double-check “impossible” losses
The portfolio is actually profitable. First bug of the new system found and fixed.
THIS IS NOT FINANCIAL ADVICE