@@ -30,7 +30,8 @@ public extension SwiftTrader {
3030 logger. log ( " Offset: \( offset. toDecimalString ( ) ) " )
3131
3232 // E.g.: (0.0747 - 0.0073) = 0.0674 (6,74%)
33- let targetPercentage : Double = profitPercentage - offset
33+ // Use "abs" to filter out negative numbers.
34+ let targetPercentage : Double = abs ( profitPercentage - offset)
3435 logger. log ( " Target percentage: \( targetPercentage. toDecimalString ( ) ) " )
3536
3637 // E.g.: 42000.69 * 0.0674 = 2830.846506
@@ -55,7 +56,7 @@ public extension SwiftTrader {
5556 // "44831.536506" becomes "44831.53".
5657 let charactersToBeRemoved = abs ( targetPriceCount - entryPriceCount)
5758 var targetPriceString = " \( targetPrice. toDecimalString ( ) ) " . dropLast ( charactersToBeRemoved)
58- logger. log ( " Target price normalize : \( targetPriceString) " )
59+ logger. log ( " Target price normalized : \( targetPriceString) " )
5960
6061 // Finally, avoid the following Kucoin error with minimal effort: "The parameter shall be a multiple of ..."
6162 // First, just try replacing the last character by "1". E.g.: "0.00002347" becomes "0.00002341"
@@ -73,6 +74,7 @@ public extension SwiftTrader {
7374 // error when you place the order. The tick size is the smallest price increment in which the prices are quoted.
7475 if let priceDouble = Double ( targetPriceString) , priceDouble > 10 {
7576 targetPriceString = " \( priceDouble. rounded ( . down) . toDecimalString ( ) ) "
77+ logger. log ( " Target price string: \( targetPriceString) " )
7678 }
7779
7880 return KucoinOrderParameters (
0 commit comments