tujidelv 2 years ago
parent
commit
a5b46f4547

+ 8 - 2
src/main/java/top/lvzhiqiang/service/impl/CoinServiceImpl.java

@@ -145,12 +145,18 @@ public class CoinServiceImpl implements CoinService {
         paramMap.put("productType", "umcbl");
         try {
             String requestUrl = mainUrl + requestPath;
-            //Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 7890));
-            Connection.Response response = JsoupUtil.requestBody(requestUrl, JsoupUtil.HTTP_GET, Proxy.NO_PROXY, headerMap, paramMap);
+            //Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 1080));
+            Proxy proxy = Proxy.NO_PROXY;
+            Connection.Response response = JsoupUtil.requestBody(requestUrl, JsoupUtil.HTTP_GET, proxy, headerMap, paramMap);
 
             return JSONObject.parseObject(response.body());
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
     }
+
+    public static void main(String[] args) {
+        CoinServiceImpl coinService = new CoinServiceImpl();
+        System.out.println(coinService.handleAllPositionV2());
+    }
 }

+ 1 - 1
src/main/java/top/lvzhiqiang/util/CheckSign4Bitget.java

@@ -51,7 +51,7 @@ public class CheckSign4Bitget {
         body = StringUtils.defaultIfBlank(body, StringUtils.EMPTY);
         queryString = StringUtils.isBlank(queryString) ? StringUtils.EMPTY : "?" + queryString;
         String preHash = timestamp + method + requestPath + queryString + body;
-        log.info("preHash:{}", preHash);
+        //log.info("preHash:{}", preHash);
         byte[] secretKeyBytes = secretKey.getBytes(StandardCharsets.UTF_8);
         SecretKeySpec secretKeySpec = new SecretKeySpec(secretKeyBytes, "HmacSHA256");
         Mac mac = (Mac) CheckSign4Bitget.MAC.clone();

+ 21 - 20
src/main/resources/static/coin.html

@@ -38,35 +38,36 @@
 <div id="my" class="dynamic_hide">
     <hr/>
     <div style="margin-right:20px;">
-        <span class="font">获取全部合约仓位信息V2</span>
+        <span class="font aaa">获取全部合约仓位信息V2</span>
         <button id="findAllPositionv2-1">展开</button>
         <button id="findAllPositionv2-2">实时启动</button>
         <button id="findAllPositionv2-3">实时停止</button>
+        <input type="text" style="width: 100px;" class="bbb">
     </div>
     <div id="content" style="display: none;">
         total:<span id="contentSPAN">0</span>
         <table border="1" cellspacing="0">
             <thead>
                 <tr id="contentTH">
-                    <th>币对名称</th>
-                    <th>保证金币种</th>
-                    <th>持仓方向</th>
-                    <th>当前委托待成交的数量</th>
-                    <th>保证金数量</th>
-                    <th>自动追加保证金</th>
-                    <th>仓位可用</th>
-                    <th>仓位冻结</th>
-                    <th>仓位总数量</th>
-                    <th>杠杆倍数</th>
-                    <th>已实现盈亏</th>
-                    <th>平均开仓价</th>
-                    <th>保证金模式</th>
-                    <th>持仓模式</th>
-                    <th>未实现盈亏</th>
-                    <th>预估强平价</th>
-                    <th>维持保证金率</th>
-                    <th>标记价格</th>
-                    <th>最近更新时间</th>
+                    <th ccc="symbol">币对名称</th>
+                    <th ccc="marginCoin">保证金币种</th>
+                    <th ccc="holdSide">持仓方向</th>
+                    <th ccc="openDelegateCount">当前委托待成交的数量</th>
+                    <th ccc="margin">保证金数量</th>
+                    <th ccc="autoMargin">自动追加保证金</th>
+                    <th ccc="available">仓位可用</th>
+                    <th ccc="locked">仓位冻结</th>
+                    <th ccc="total">仓位总数量</th>
+                    <th ccc="leverage">杠杆倍数</th>
+                    <th ccc="achievedProfits">已实现盈亏</th>
+                    <th ccc="averageOpenPrice">平均开仓价</th>
+                    <th ccc="marginMode">保证金模式</th>
+                    <th ccc="holdMode">持仓模式</th>
+                    <th ccc="unrealizedPL">未实现盈亏</th>
+                    <th ccc="liquidationPrice">预估强平价</th>
+                    <th ccc="keepMarginRate">维持保证金率</th>
+                    <th ccc="marketPrice">标记价格</th>
+                    <th ccc="cTime">最近更新时间</th>
                 </tr>
             </thead>
             <tbody id="contentTD">

+ 30 - 8
src/main/resources/static/js/my-coin.js

@@ -1,3 +1,5 @@
+window.cccField = '';
+
 $(function () {
     initOther();
 });
@@ -21,7 +23,7 @@ function initOther() {
     var actualFlag = false;
     $("#findAllPositionv2-2").click(function () {
         if (!actualFlag) {
-            findAllPositionv22Timer = setInterval("searchAllPositionv2()", "1000");
+            findAllPositionv22Timer = setInterval("searchAllPositionv2()", "2000");
             actualFlag = true;
         }
     });
@@ -32,6 +34,13 @@ function initOther() {
             actualFlag = false;
         }
     });
+
+    $("#contentTH").find("th").dblclick(function () {
+        cccField = $(this).attr("ccc");
+    });
+    $(".aaa").dblclick(function () {
+        cccField = '';
+    });
 }
 
 /**
@@ -52,6 +61,7 @@ function searchAllPositionv2() {
                 data = data.data;
                 $("#contentSPAN").html(data.length);
                 var str = '';
+                var title = 'Coin主页|';
                 for (var i = 0; i < data.length; i++) {
                     var dataDetail = data[i];
 
@@ -59,13 +69,23 @@ function searchAllPositionv2() {
                     var unrealizedPL = dataDetail.unrealizedPL;
                     var unrealizedPLStyle = '';
                     if (unrealizedPL < 0) {
-                        unrealizedPLStyle = ' style="color:red;"';
+                        unrealizedPLStyle = ' style="color:#FFFFFF;background-color:#F1493F;"';
                     } else {
-                        unrealizedPLStyle = ' style="color:green;"';
+                        unrealizedPLStyle = ' style="color:#FFFFFF;background-color:#1DA2B4;"';
                     }
                     //币对名称
                     var symbol = dataDetail.symbol;
-                    symbol = '<strong><font color="#808080">' + symbol.replace('USDT_UMCBL', '') + '</font></strong>' + 'USDT_UMCBL';
+
+
+                    var bbbField = $(".bbb").val();
+                    if (cccField.length > 0 && bbbField.length > 0 && symbol.indexOf(bbbField) != -1) {
+                        title += bbbField + '|' + dataDetail[cccField];
+                        $("title").html(title);
+                    }
+
+                    symbol = '<strong' + ' style="background-color:#F1B90d;"' + '><font color="#242A30">' + symbol.replace('USDT_UMCBL', '') + '</font></strong>' + 'USDT_UMCBL';
+                    //标记价格
+                    var marketPriceStyle = ' style="color:#252B31;background-color:#C4ADE9;font-weight:bold;"';
 
                     str += '<tr>';
                     str += '<td>' + symbol + '</td>';
@@ -85,7 +105,7 @@ function searchAllPositionv2() {
                     str += '<td' + unrealizedPLStyle + '>' + dataDetail.unrealizedPL + '</td>';
                     str += '<td>' + dataDetail.liquidationPrice + '</td>';
                     str += '<td>' + dataDetail.keepMarginRate + '</td>';
-                    str += '<td>' + dataDetail.marketPrice + '</td>';
+                    str += '<td' + marketPriceStyle + '>' + dataDetail.marketPrice + '</td>';
                     str += '<td>' + dataDetail.cTime + '</td>';
                     str += '</tr>';
                 }
@@ -93,7 +113,7 @@ function searchAllPositionv2() {
 
                 initContentEvent();
             } else {
-                alert(data.message);
+                //alert(data.message);
             }
         },
         beforeSend: function () {
@@ -102,7 +122,7 @@ function searchAllPositionv2() {
         },
         error: function (data) {
             //请求出错处理
-            alert('error:' + data);
+            //alert('error:' + data);
         }
     });
 }
@@ -111,5 +131,7 @@ function searchAllPositionv2() {
  * 初始化主内容事件
  */
 function initContentEvent() {
-
+    if ($(".bbb").val().length === 0) {
+        $("title").html('Coin主页');
+    }
 }