π Bug Description
The TON Trading Bot report shows incorrect P&L calculations when closing positions in simulation mode.
Current (Wrong) Behavior:
- Position 28: Shows
10 TON β 16.24 USDT with +13,310% profit
- Position 29: Shows
50 TON β 16.28 USDT with -73.53% loss
- Total reported:
+$1.247 net profit
Expected (Correct) Behavior:
Based on entry/exit prices:
-
Position 28 (Entry $1.240, Exit $1.249):
10 TON Γ $1.240 = $12.40 β 10 TON Γ $1.249 = $12.49
Actual P&L: ~+$0.09 (not +$16.24!)
-
Position 29 (Entry $1.252, Exit $1.251):
50 TON Γ $1.252 = $62.60 β 50 TON Γ $1.251 = $62.55
Actual P&L: ~-$0.05 (not -$45.22!)
Root Cause:
The ton_trading_record_trade tool (or report generator) is using incorrect formula for P&L calculation. It appears to:
- Use wrong
amount_in/amount_out values in the report
- OR calculate PnL percentage based on incorrect base amounts
Affected Components:
- TON Trading Bot plugin (likely in
plugins/ton-trading or similar)
- The
recordTrade / calculatePnL function
- Report generation in HEARTBEAT.md workflow
Steps to Reproduce:
- Open a simulated trade (e.g., 10 TON/USDT at $1.240)
- Close the trade at a slightly higher price ($1.249)
- Check the generated report β shows incorrect USDT amounts and P&L%
Expected Fix:
P&L should be calculated as:
pnl_usd = (amount_in Γ exit_price_usd) - (amount_in Γ entry_price_usd)
pnl_pct = ((exit_price - entry_price) / entry_price) Γ 100
Report should show:
- Correct USDT amounts based on actual TON amount Γ price
- Accurate P&L percentages
Priority: High π΄
This breaks trading performance tracking and could lead to wrong decisions in YOLO mode.
Date: 2026-04-09
Reporter: Tony ID (@labtgbot)
π Bug Description
The TON Trading Bot report shows incorrect P&L calculations when closing positions in simulation mode.
Current (Wrong) Behavior:
10 TON β 16.24 USDTwith+13,310%profit50 TON β 16.28 USDTwith-73.53%loss+$1.247net profitExpected (Correct) Behavior:
Based on entry/exit prices:
Position 28 (Entry $1.240, Exit $1.249):
10 TON Γ $1.240 = $12.40β10 TON Γ $1.249 = $12.49Actual P&L: ~+$0.09 (not +$16.24!)
Position 29 (Entry $1.252, Exit $1.251):
50 TON Γ $1.252 = $62.60β50 TON Γ $1.251 = $62.55Actual P&L: ~-$0.05 (not -$45.22!)
Root Cause:
The
ton_trading_record_tradetool (or report generator) is using incorrect formula for P&L calculation. It appears to:amount_in/amount_outvalues in the reportAffected Components:
plugins/ton-tradingor similar)recordTrade/calculatePnLfunctionSteps to Reproduce:
Expected Fix:
P&L should be calculated as:
Report should show:
Priority: High π΄
This breaks trading performance tracking and could lead to wrong decisions in YOLO mode.
Date: 2026-04-09
Reporter: Tony ID (@labtgbot)