From c47543cbe3f6683567c9398a204a86dc192a9608 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Sat, 10 Aug 2024 00:47:08 +0800
Subject: [PATCH] 1

---
 src/main/java/project/project/web/admin/AdminContractOrderController.java |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/main/java/project/project/web/admin/AdminContractOrderController.java b/src/main/java/project/project/web/admin/AdminContractOrderController.java
index 29114ab..94acd11 100644
--- a/src/main/java/project/project/web/admin/AdminContractOrderController.java
+++ b/src/main/java/project/project/web/admin/AdminContractOrderController.java
@@ -113,19 +113,14 @@
 				}
 				double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString());
 
-				// 计算仓位总价
-				double positionValue = Double.parseDouble(map.get("deposit_open").toString()) * Double.parseDouble(map.get("lever_rate").toString());
-
-				// 计算数量
-				double quantity = positionValue / currentPrice;
-
-				// 得到强平价格
+				double leve = Double.parseDouble(map.get("lever_rate").toString());
+				//得到强平价格
 				if(null != map.get("direction")){
 					double liquidationPrice;
 					if(map.get("direction").equals("sell")){
-						liquidationPrice = currentPrice + (100 / quantity);
+						liquidationPrice = currentPrice * (1 + (1 / leve));
 					}else{
-						liquidationPrice = currentPrice - (100 / quantity);
+						liquidationPrice = currentPrice * (1 - 1 / leve);
 					}
 					DecimalFormat df = new DecimalFormat("#.#####");
 					String formattedPrice = df.format(liquidationPrice);
@@ -224,19 +219,14 @@
 				}
 				double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString());
 
-				// 计算仓位总价
-				double positionValue = Double.parseDouble(map.get("deposit_open").toString()) * Double.parseDouble(map.get("lever_rate").toString());
-
-				// 计算数量
-				double quantity = positionValue / currentPrice;
-
-				// 得到强平价格
+				double leve = Double.parseDouble(map.get("lever_rate").toString());
+				//得到强平价格
 				if(null != map.get("direction")){
 					double liquidationPrice;
 					if(map.get("direction").equals("sell")){
-						liquidationPrice = currentPrice + (100 / quantity);
+						liquidationPrice = currentPrice * (1 + (1 / leve));
 					}else{
-						liquidationPrice = currentPrice - (100 / quantity);
+						liquidationPrice = currentPrice * (1 - 1 / leve);
 					}
 					DecimalFormat df = new DecimalFormat("#.#####");
 					String formattedPrice = df.format(liquidationPrice);

--
Gitblit v1.9.3