|
@@ -378,36 +378,27 @@ public class CoinServiceImpl implements CoinService {
|
|
|
// OKX开仓平仓监控报警
|
|
// OKX开仓平仓监控报警
|
|
|
scheduler.scheduleWithFixedDelay(() -> {
|
|
scheduler.scheduleWithFixedDelay(() -> {
|
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
LocalDateTime endTime = LocalDateTime.now();
|
|
|
- // 全部历史委托列表
|
|
|
|
|
|
|
+ // 查看历史持仓信息
|
|
|
Map<String, String> paramMap = new LinkedHashMap<>();
|
|
Map<String, String> paramMap = new LinkedHashMap<>();
|
|
|
- paramMap.put("productType", "umcbl");
|
|
|
|
|
- paramMap.put("startTime", String.valueOf(DateUtils.localDateTimeToMilliseconds(endTime.minusMinutes(1))));
|
|
|
|
|
- paramMap.put("endTime", String.valueOf(DateUtils.localDateTimeToMilliseconds(endTime)));
|
|
|
|
|
- paramMap.put("pageSize", "100");
|
|
|
|
|
|
|
+ paramMap.put("instType", "SWAP");
|
|
|
|
|
|
|
|
String signQueryString = paramMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
|
|
String signQueryString = paramMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
|
|
|
try {
|
|
try {
|
|
|
- JSONObject response = requestApi4Common("/api/mix/v1/order/historyProductType", signQueryString, null, JsoupUtil.HTTP_GET, paramMap);
|
|
|
|
|
- JSONArray orderList = response.getJSONObject("data").getJSONArray("orderList");
|
|
|
|
|
|
|
+ JSONObject response = requestApi4Common4OKX("/api/v5/account/positions-history", signQueryString, null, JsoupUtil.HTTP_GET, paramMap);
|
|
|
|
|
+ JSONArray orderList = response.getJSONArray("data");
|
|
|
|
|
|
|
|
for (int i = 0; i < orderList.size(); i++) {
|
|
for (int i = 0; i < orderList.size(); i++) {
|
|
|
JSONObject order = orderList.getJSONObject(i);
|
|
JSONObject order = orderList.getJSONObject(i);
|
|
|
- LocalDateTime cTime = DateUtils.longToLocalDateTime(order.getLong("cTime"));
|
|
|
|
|
- String orderId = order.getString("orderId");
|
|
|
|
|
- String symbol = order.getString("symbol");
|
|
|
|
|
- if (Duration.between(cTime, endTime).getSeconds() < 50 && !orderMap.containsKey(orderId)) {
|
|
|
|
|
|
|
+ //LocalDateTime cTime = DateUtils.longToLocalDateTime(order.getLong("cTime"));
|
|
|
|
|
+ String orderId = "okx" + order.getString("posId");
|
|
|
|
|
+ String symbol = order.getString("ccy");
|
|
|
|
|
+ if (!orderMap.containsKey(orderId)) {
|
|
|
orderMap.put(orderId, "1");
|
|
orderMap.put(orderId, "1");
|
|
|
|
|
|
|
|
- String content = "<div class=\"highlight\">交易对:" + order.getString("symbol") + "</div>" +
|
|
|
|
|
- "<div>交易方向:" + InitRunner.publicParamsMap.get("side").getString(order.getString("side")) + "</div>" +
|
|
|
|
|
- "<div>杠杆倍数:" + order.getString("leverage") + "</div>" +
|
|
|
|
|
- "<div>成交均价:" + order.getString("priceAvg") + "</div>" +
|
|
|
|
|
- "<div>委托价格:" + order.getString("price") + "</div>" +
|
|
|
|
|
- "<div>订单状态:" + InitRunner.publicParamsMap.get("state").getString(order.getString("state")) + "</div>" +
|
|
|
|
|
- "<div>订单类型:" + InitRunner.publicParamsMap.get("orderType").getString(order.getString("orderType")) + "</div>" +
|
|
|
|
|
- "<div class=\"gray\">订单时间:" + DateUtils.longToString(order.getLong("cTime")) + "</div>";
|
|
|
|
|
|
|
+ log.warn("okx ={}", order);
|
|
|
|
|
+ String content = "<div class=\"highlight\">交易对:" + symbol + "</div>";
|
|
|
JSONObject params = new JSONObject();
|
|
JSONObject params = new JSONObject();
|
|
|
- params.put("title", (order.getString("side").contains("open") ? "BITGET合约开单" : "BITGET合约平单") + "报警");
|
|
|
|
|
|
|
+ params.put("title", "OKX报警");
|
|
|
params.put("logUrl", "https://jav.lvzhiqiang.top/coin/orderDetail2/" + orderId + "/" + symbol);
|
|
params.put("logUrl", "https://jav.lvzhiqiang.top/coin/orderDetail2/" + orderId + "/" + symbol);
|
|
|
params.put("btnTxt", "订单详情");
|
|
params.put("btnTxt", "订单详情");
|
|
|
SpringUtils.getBean(CoinServiceImpl.class).monitorAlarm4APP_TEXT_CARD(content, params, null);
|
|
SpringUtils.getBean(CoinServiceImpl.class).monitorAlarm4APP_TEXT_CARD(content, params, null);
|
|
@@ -415,7 +406,7 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
}
|
|
}
|
|
|
- }, 0, 2, TimeUnit.SECONDS);
|
|
|
|
|
|
|
+ }, 0, 10, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
scheduler.scheduleAtFixedRate(() -> {
|
|
scheduler.scheduleAtFixedRate(() -> {
|
|
|
// BITGET全部合约仓位信息V2
|
|
// BITGET全部合约仓位信息V2
|
|
@@ -441,6 +432,7 @@ public class CoinServiceImpl implements CoinService {
|
|
|
BigDecimal returnRate = new BigDecimal(mixData.getString("unrealizedPL")).divide(new BigDecimal(margin), 4, RoundingMode.HALF_UP);
|
|
BigDecimal returnRate = new BigDecimal(mixData.getString("unrealizedPL")).divide(new BigDecimal(margin), 4, RoundingMode.HALF_UP);
|
|
|
for (int j = 1; j <= 10; j++) {
|
|
for (int j = 1; j <= 10; j++) {
|
|
|
BigDecimal grid = BigDecimal.valueOf(0.5).multiply(BigDecimal.valueOf(j));
|
|
BigDecimal grid = BigDecimal.valueOf(0.5).multiply(BigDecimal.valueOf(j));
|
|
|
|
|
+ BigDecimal minusGrid = BigDecimal.valueOf(-0.5).multiply(BigDecimal.valueOf(j));
|
|
|
if (returnRate.compareTo(grid) < 0) {
|
|
if (returnRate.compareTo(grid) < 0) {
|
|
|
if (mixMap.containsKey(key)) {
|
|
if (mixMap.containsKey(key)) {
|
|
|
mixMap.get(key).put("returnRate", returnRate);
|
|
mixMap.get(key).put("returnRate", returnRate);
|
|
@@ -552,7 +544,7 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}, 0, 3, TimeUnit.SECONDS);
|
|
}, 0, 3, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
// 星球日报新闻快讯监控报警
|
|
// 星球日报新闻快讯监控报警
|
|
|
- scheduler.scheduleWithFixedDelay(() -> {
|
|
|
|
|
|
|
+ /*scheduler.scheduleWithFixedDelay(() -> {
|
|
|
try {
|
|
try {
|
|
|
Connection.Response response = JsoupUtil.requestBody("https://www.odaily.news/v1/openapi/feeds", JsoupUtil.HTTP_GET, InitRunner.proxy, null, null);
|
|
Connection.Response response = JsoupUtil.requestBody("https://www.odaily.news/v1/openapi/feeds", JsoupUtil.HTTP_GET, InitRunner.proxy, null, null);
|
|
|
JSONObject result = JSONObject.parseObject(response.body());
|
|
JSONObject result = JSONObject.parseObject(response.body());
|
|
@@ -601,7 +593,7 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
}
|
|
}
|
|
|
- }, 0, 3, TimeUnit.SECONDS);
|
|
|
|
|
|
|
+ }, 0, 3, TimeUnit.SECONDS);*/
|
|
|
|
|
|
|
|
// 律动日报新闻快讯监控报警
|
|
// 律动日报新闻快讯监控报警
|
|
|
scheduler.scheduleWithFixedDelay(() -> {
|
|
scheduler.scheduleWithFixedDelay(() -> {
|
|
@@ -871,14 +863,14 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private JSONObject requestApi4Common4OKX(String requestPath, String signQueryString, String signBody, String httpMethod, Map<String, String> paramMap) {
|
|
private JSONObject requestApi4Common4OKX(String requestPath, String signQueryString, String signBody, String httpMethod, Map<String, String> paramMap) {
|
|
|
- String timestamp = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
|
|
+ String timestamp = DateUtils.getUTCTimeStr();
|
|
|
|
|
|
|
|
Map<String, String> headerMap = new HashMap<>();
|
|
Map<String, String> headerMap = new HashMap<>();
|
|
|
headerMap.putAll(basicHeaderMap4OKX);
|
|
headerMap.putAll(basicHeaderMap4OKX);
|
|
|
try {
|
|
try {
|
|
|
- String accessSign = CheckSign4Bitget.generate(timestamp, httpMethod, requestPath, signQueryString, signBody, secretKey4OKX);
|
|
|
|
|
- headerMap.put("ACCESS-TIMESTAMP", timestamp);
|
|
|
|
|
- headerMap.put("ACCESS-SIGN", accessSign);
|
|
|
|
|
|
|
+ String accessSign = CheckSign4OKX.generate(timestamp, httpMethod, requestPath, signQueryString, signBody, secretKey4OKX);
|
|
|
|
|
+ headerMap.put("OK-ACCESS-TIMESTAMP", timestamp);
|
|
|
|
|
+ headerMap.put("OK-ACCESS-SIGN", accessSign);
|
|
|
} catch (CloneNotSupportedException e) {
|
|
} catch (CloneNotSupportedException e) {
|
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
|
} catch (InvalidKeyException e) {
|
|
} catch (InvalidKeyException e) {
|
|
@@ -888,7 +880,7 @@ public class CoinServiceImpl implements CoinService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- String requestUrl = mainUrl + requestPath;
|
|
|
|
|
|
|
+ String requestUrl = "https://www.okx.com" + requestPath;
|
|
|
|
|
|
|
|
if (httpMethod.equals(JsoupUtil.HTTP_GET)) {
|
|
if (httpMethod.equals(JsoupUtil.HTTP_GET)) {
|
|
|
Connection.Response response = JsoupUtil.requestBody(requestUrl, httpMethod, InitRunner.proxy, headerMap, paramMap);
|
|
Connection.Response response = JsoupUtil.requestBody(requestUrl, httpMethod, InitRunner.proxy, headerMap, paramMap);
|