Browse Source

修复没有成交的数据帧显示0的bug。

skyffire 1 year ago
parent
commit
2ed999e076
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/utils.js

+ 9 - 1
src/utils.js

@@ -9,7 +9,15 @@ export const extractBidPrices = (data) => {
     if (marketDepth) {
       let buys = marketDepth.buys.map(b => +b.rate);
       let sells = marketDepth.sells.map(b => +b.rate);
-      return buys.concat(sells, [marketDepth.lastBuyQty !== 0 ? +marketDepth.lastBuyPrice : +marketDepth.lastSellPrice]);
+      let result = buys.concat(sells)
+      if (marketDepth.lastBuyQty > 0) {
+        result = result.concat([marketDepth.lastBuyPrice])
+      }
+      if (marketDepth.lastSellQty > 0) {
+        result = result.concat([marketDepth.lastSellPrice])
+      }
+
+      return result
     }
     return [];
   }).reduce((acc, val) => acc.concat(val), []));