fix: 4 bugfixes for production readiness
1. GetHLSize: add minimum size checks (prevent size=0 when price > amount) 2. executeEntry: orphan position warning when leg1 close also fails after leg2 3. checkExit: keep position as close_failed on failure, retryClose on each Tick 4. persistTrade: sync instead of goroutine (prevent data loss on exit)
This commit is contained in:
@@ -178,21 +178,39 @@ func GetHLSize(coin string, amountUSD, price float64) string {
|
||||
switch coin {
|
||||
case "DOGE":
|
||||
sz = math.Floor(sz) // step=1, szDecimals=0
|
||||
if sz < 1 {
|
||||
sz = 1
|
||||
}
|
||||
return fmt.Sprintf("%.0f", sz)
|
||||
case "LINK":
|
||||
sz = math.Floor(sz*10) / 10 // step=0.1, szDecimals=1
|
||||
if sz < 0.1 {
|
||||
sz = 0.1
|
||||
}
|
||||
return fmt.Sprintf("%.1f", sz)
|
||||
case "ONDO":
|
||||
sz = math.Floor(sz) // step=1, szDecimals=0
|
||||
if sz < 1 {
|
||||
sz = 1
|
||||
}
|
||||
return fmt.Sprintf("%.0f", sz)
|
||||
case "OP":
|
||||
sz = math.Floor(sz*10) / 10 // step=0.1, szDecimals=1
|
||||
if sz < 0.1 {
|
||||
sz = 0.1
|
||||
}
|
||||
return fmt.Sprintf("%.1f", sz)
|
||||
case "WIF":
|
||||
sz = math.Floor(sz) // step=1, szDecimals=0
|
||||
if sz < 1 {
|
||||
sz = 1
|
||||
}
|
||||
return fmt.Sprintf("%.0f", sz)
|
||||
case "ARB":
|
||||
sz = math.Floor(sz*10) / 10 // step=0.1, szDecimals=1
|
||||
if sz < 0.1 {
|
||||
sz = 0.1
|
||||
}
|
||||
return fmt.Sprintf("%.1f", sz)
|
||||
default:
|
||||
return fmt.Sprintf("%.4f", sz)
|
||||
|
||||
Reference in New Issue
Block a user