| | |
| | | } |
| | | } |
| | | |
| | | public static String initAccountName(String accountName, String posSide) { |
| | | return accountName+"_"+ posSide; |
| | | } |
| | | |
| | | public static void initEvent(JSONObject response, String accountName) { |
| | | // log.info("订阅成功,数据初始化: {}", response.getJSONObject("arg")); |
| | | JSONObject arg = response.getJSONObject("arg"); |
| | | initParam(arg, accountName); |
| | | initParam(arg, accountName,CoinEnums.POSSIDE_LONG.getCode()); |
| | | initParam(arg, accountName,CoinEnums.POSSIDE_SHORT.getCode()); |
| | | } |
| | | |
| | | public static void handleEvent(JSONObject response, String accountName) { |
| | |
| | | if (dataArray == null || dataArray.isEmpty()) { |
| | | // log.info("账户持仓频道数据为空,已当前价买入,并且初始化网格"); |
| | | JSONObject posData = new JSONObject(); |
| | | initParam(posData, accountName); |
| | | initParam(posData, accountName,CoinEnums.POSSIDE_LONG.getCode()); |
| | | initParam(posData, accountName,CoinEnums.POSSIDE_SHORT.getCode()); |
| | | return; |
| | | } |
| | | |
| | |
| | | last, idxPx, bePx, realizedPnl, settledPnl, |
| | | markPx,fee,fundingFee |
| | | ); |
| | | |
| | | initParam(posData, accountName); |
| | | initParam(posData, accountName,posSide); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | private static void initParam(JSONObject posData, String accountName) { |
| | | Map<String, BigDecimal> accountMap = getAccountMap(accountName); |
| | | private static void initParam(JSONObject posData, String accountName,String posSide) { |
| | | String accountNamePositons = initAccountName(accountName, posSide); |
| | | Map<String, BigDecimal> accountMap = getAccountMap(accountNamePositons); |
| | | WsMapBuild.saveBigDecimalToMap(accountMap, "avgPx", WsMapBuild.parseBigDecimalSafe(posData.getString("avgPx"))); |
| | | WsMapBuild.saveBigDecimalToMap(accountMap, "pos", WsMapBuild.parseBigDecimalSafe(posData.getString("pos"))); |
| | | WsMapBuild.saveBigDecimalToMap(accountMap, "upl", WsMapBuild.parseBigDecimalSafe(posData.getString("upl"))); |