mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-12 23:36:55 +08:00
feat(kucoin): add order sync and fix price precision
- Add KuCoin order sync with proper API response parsing - Use openFeePay/closeFeePay to determine open/close trades - Get contract multiplier from API for accurate qty calculation - Fix price rounding: 2 decimals -> 8 decimals for low-price coins - Add comprehensive tests for trades, positions, and P&L
This commit is contained in:
@@ -147,7 +147,8 @@ func (pb *PositionBuilder) handleClose(
|
||||
var finalExitPrice float64
|
||||
if totalClosed > 0 {
|
||||
finalExitPrice = (position.ExitPrice*closedBefore + price*closeQty) / totalClosed
|
||||
finalExitPrice = math.Round(finalExitPrice*100) / 100
|
||||
// Use 8 decimal places for price precision (crypto standard)
|
||||
finalExitPrice = math.Round(finalExitPrice*100000000) / 100000000
|
||||
} else {
|
||||
finalExitPrice = price
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user