CRITICAL FIX: TP/SL orders using wrong size calculation
**ROOT CAUSE:** placeExitOrders() calculated position size using TP/SL prices instead of entry price
**Problem:**
- TP1 order size: 85 / TP1_price (00.746) = 2.914 SOL
- Actual position: 80 / entry_price (99.946) = 3.901 SOL
- TP1 should close: 3.901 * 75% = 2.926 SOL
- But it only closed: 2.914 SOL = 74.7% ❌ WRONG!
**Result:** TP1 closed ~25% instead of 75%, no runner left
**Fix:**
- Changed usdToBase() to use entryPrice for ALL size calculations
- Added entryPrice param to PlaceExitOrdersOptions interface
- Updated all API routes to pass entryPrice
**Testing:** Next trade will have correctly sized TP/SL orders
This commit is contained in:
2
.env
2
.env
@@ -61,7 +61,7 @@ PYTH_HERMES_URL=https://hermes.pyth.network
|
||||
# Position sizing
|
||||
# Base position size in USD (default: 50 for safe testing)
|
||||
# Example: 50 with 10x leverage = $500 notional position
|
||||
MAX_POSITION_SIZE_USD=78
|
||||
MAX_POSITION_SIZE_USD=54
|
||||
|
||||
# Leverage multiplier (1-20, default: 10)
|
||||
# Higher leverage = bigger gains AND bigger losses
|
||||
|
||||
Reference in New Issue
Block a user