| | |
| | | package project.project.web.api; |
| | | package project.web.api; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.DecimalFormat; |
| | |
| | | if (map.get("direction") != null) { |
| | | String direction = map.get("direction").toString(); |
| | | double liquidationPrice; |
| | | double deposit = depositOpen + profit; |
| | | double deposit = profit; |
| | | |
| | | if(leverRate == 1){ |
| | | liquidationPrice = 0; |
| | | }else { |
| | | if ("sell".equals(direction)) { |
| | | liquidationPrice = tradeAvgPrice + (deposit / div); |
| | | double lossPercentage = deposit / Double.parseDouble(map.get("amount").toString()); |
| | | double priceIncrease = lossPercentage * tradeAvgPrice; |
| | | liquidationPrice = tradeAvgPrice + priceIncrease; |
| | | } else { |
| | | liquidationPrice = (mul * tradeAvgPrice) / (deposit + mul); |
| | | double lossPercentage = deposit / Double.parseDouble(map.get("amount").toString()); |
| | | double priceDrop = lossPercentage * tradeAvgPrice; |
| | | liquidationPrice = tradeAvgPrice - priceDrop; |
| | | } |
| | | } |
| | | |
| | | DecimalFormat dfs = new DecimalFormat("#.#####"); |
| | | String formattedPrice = dfs.format(liquidationPrice); |
| | | // 检查是否为负数 |
| | | if (Double.parseDouble(formattedPrice) < 0) { |
| | | formattedPrice = "0"; |
| | | } |
| | | map.put("qiangPing", formattedPrice); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // 标记价格 |
| | | Realtime realtime = realtimeMap.get(map.get("symbol")); |
| | | if (null == realtime) { |