| | |
| | | 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 positionValue = Double.parseDouble(map.get("deposit_open").toString()) * Double.parseDouble(map.get("lever_rate").toString()); |
| | | |
| | | // 计算数量 |
| | | double quantity = positionValue / currentPrice; |
| | | |
| | | // 得到强平价格 |
| | | if(null != map.get("direction")){ |
| | | double liquidationPrice; |
| | | if(map.get("direction").equals("sell")){ |
| | | liquidationPrice = currentPrice + (100 / quantity); |
| | | }else{ |
| | | liquidationPrice = currentPrice - (100 / quantity); |
| | | } |
| | | 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()); |
| | | |