Kaynağa Gözat

更新ask价格

lxf 2 hafta önce
ebeveyn
işleme
968b88cfed
2 değiştirilmiş dosya ile 43 ekleme ve 32 silme
  1. 42 31
      src/App.vue
  2. 1 1
      src/components/abnormal/components/status3.vue

+ 42 - 31
src/App.vue

@@ -156,32 +156,43 @@ export default {
       var msg = JSON.parse(data.data)
       if (msg) {
         if (msg.type == 'depth' && this.updateSymbolList.indexOf(msg.symbol) != -1) {
-          bus.$emit('updateDepth', msg)
-        }
-        if (msg.type == 'price' && this.updateSymbolList.indexOf(msg.symbol) != -1) {
           if (this.productDataObj && this.productDataObj[msg.symbol] !== undefined) {
-            var item = this.productDataObj[msg.symbol]
-            msg.ask = Number(this.$handleDigits(msg.ask, this.productDataObj[msg.symbol].digits))
-            msg.bid = Number(this.$handleDigits(msg.bid, this.productDataObj[msg.symbol].digits))
-            this.$set(this.productDataObj[msg.symbol], 'ask', msg.ask)
-            this.$set(this.productDataObj[msg.symbol], 'bid', msg.bid)
-            this.$set(this.productDataObj[msg.symbol], 'spread', this.$bigDecimal.subtract(msg.ask, item.close))
-            if (item.high < item.ask) {
-              this.$set(this.productDataObj[msg.symbol], 'high', msg.ask)
+            var targetSymbol = this.productDataObj[msg.symbol];
+            var asks = (msg.asks || []).sort((a, b) => Number(a.price) - Number(b.price)).filter(item => Number(item.price))
+            var bids = (msg.bids || []).sort((a, b) => Number(b.price) - Number(a.price)).filter(item => Number(item.price))
+            if (asks[0]) {
+              var ask = asks[0].price
+              this.$set(this.productDataObj[msg.symbol], 'spread', this.$bigDecimal.subtract(ask, targetSymbol.close))
+              this.$set(this.productDataObj[msg.symbol], 'ask', ask)
+              if (targetSymbol.close) {
+                this.$set(this.productDataObj[msg.symbol], 'percentage', ((((ask || targetSymbol.close) - targetSymbol.close) / targetSymbol.close) * 100).toFixed(2))
+              }
             }
-            if (item.low > item.ask) {
-              this.$set(this.productDataObj[msg.symbol], 'low', msg.ask)
+            if (bids[0]) {
+              var bid = bids[0].price
+              this.$set(this.productDataObj[msg.symbol], 'bid', bid)
             }
-            if (item.close) {
-              this.$set(this.productDataObj[msg.symbol], 'percentage', ((((msg.ask || item.close) - item.close) / item.close) * 100).toFixed(2))
-            }
-            bus.$emit('updateChart', msg)
           }
-          if ((new Date().getTime() - this.timerSign) < 1000) {
+          bus.$emit('updateDepth', msg)
+          if ((new Date().getTime() - this.timerSign) < 700) {
             return
           }
           this.timerSign = new Date().getTime()
-          bus.$emit('updateSymbol', msg)
+          bus.$emit('updateSymbol', true)
+        }
+        if (msg.type == 'price' && this.updateSymbolList.indexOf(msg.symbol) != -1) {
+          if (this.productDataObj && this.productDataObj[msg.symbol] !== undefined) {
+            var item = this.productDataObj[msg.symbol]
+            msg.ask = Number(this.$handleDigits(item.ask, item.digits))
+            msg.bid = Number(this.$handleDigits(item.bid, item.digits))
+            // if (item.high < item.ask) {
+            //   this.$set(this.productDataObj[msg.symbol], 'high', msg.ask)
+            // }
+            // if (item.low > item.ask) {
+            //   this.$set(this.productDataObj[msg.symbol], 'low', msg.ask)
+            // }
+            bus.$emit('updateChart', msg)
+          }
         }
       }
     },
@@ -258,12 +269,12 @@ export default {
             } else {
               item.percentage = 100;
             }
-            if (item.high < item.ask) {
-              item.high = item.ask
-            }
-            if (item.low > item.ask) {
-              item.low = item.ask
-            }
+            // if (item.high < item.ask) {
+            //   item.high = item.ask
+            // }
+            // if (item.low > item.ask) {
+            //   item.low = item.ask
+            // }
             item.spread = this.$bigDecimal.subtract(item.ask, item.close)
             item.ask = Number(this.$handleDigits(item.ask, item.digits))
             item.bid = Number(this.$handleDigits(item.bid, item.digits))
@@ -283,12 +294,12 @@ export default {
           } else {
             item.percentage = 100;
           }
-          if (item.high < item.ask) {
-            item.high = item.ask
-          }
-          if (item.low > item.ask) {
-            item.low = item.ask
-          }
+          // if (item.high < item.ask) {
+          //   item.high = item.ask
+          // }
+          // if (item.low > item.ask) {
+          //   item.low = item.ask
+          // }
           item.spread = this.$bigDecimal.subtract(item.ask, item.close)
           item.ask = Number(this.$handleDigits(item.ask, item.digits))
           item.bid = Number(this.$handleDigits(item.bid, item.digits))

+ 1 - 1
src/components/abnormal/components/status3.vue

@@ -29,7 +29,7 @@ export default {
   },
   computed: {
     content() {
-      return ((this.handleList[0] || {}).content || '')
+      return ((this.handleList[0] || {}).comment || '')
     }
   }
 }