zj
2025-05-02 01830e44921b187b448d8cce9c9a46b9ad55af43
src/main/java/project/contract/internal/ContractOrderServiceImpl.java
@@ -1,13 +1,8 @@
package project.contract.internal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
@@ -465,14 +460,16 @@
   }
   public Map<String, Object> bulidOne(ContractOrder order) {
      SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      simpleDateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
      DecimalFormat df = new DecimalFormat("#.##");
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("order_no", order.getOrder_no());
      map.put("name", itemService.cacheBySymbol(order.getSymbol(), false).getName());
      map.put("symbol", order.getSymbol());
      map.put("create_time", DateUtils.format(order.getCreate_time(), DateUtils.DF_yyyyMMddHHmmss));
      map.put("create_time", simpleDateFormat.format(order.getCreate_time()));
      if (order.getClose_time() != null) {
         map.put("close_time", DateUtils.format(order.getClose_time(), DateUtils.DF_yyyyMMddHHmmss));
         map.put("close_time", simpleDateFormat.format(order.getClose_time()));
      } else {
         map.put("close_time", "");
      }
@@ -504,7 +501,21 @@
      } else {
         map.put("profit", df.format(Arith.sub(Arith.add(order.getAmount_close(), order.getDeposit()), order.getDeposit_open())));
      }
      double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString());
      double leve = Double.parseDouble(map.get("lever_rate").toString());
      //得到强平价格
      if(null != map.get("direction")){
         double liquidationPrice;
         if(map.get("direction").equals("sell")){
            liquidationPrice = currentPrice * (1 + (1 / leve));
         }else{
            liquidationPrice = currentPrice * (1 - 1 / leve);
         }
         DecimalFormat dfs = new DecimalFormat("#.#####");
         String formattedPrice = dfs.format(liquidationPrice);
         map.put("qiangPing",formattedPrice);
      }
      map.put("volume", order.getVolume());
      map.put("volume_open", order.getVolume_open());