|
@@ -156,32 +156,43 @@ export default {
|
|
var msg = JSON.parse(data.data)
|
|
var msg = JSON.parse(data.data)
|
|
if (msg) {
|
|
if (msg) {
|
|
if (msg.type == 'depth' && this.updateSymbolList.indexOf(msg.symbol) != -1) {
|
|
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) {
|
|
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
|
|
return
|
|
}
|
|
}
|
|
this.timerSign = new Date().getTime()
|
|
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 {
|
|
} else {
|
|
item.percentage = 100;
|
|
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.spread = this.$bigDecimal.subtract(item.ask, item.close)
|
|
item.ask = Number(this.$handleDigits(item.ask, item.digits))
|
|
item.ask = Number(this.$handleDigits(item.ask, item.digits))
|
|
item.bid = Number(this.$handleDigits(item.bid, item.digits))
|
|
item.bid = Number(this.$handleDigits(item.bid, item.digits))
|
|
@@ -283,12 +294,12 @@ export default {
|
|
} else {
|
|
} else {
|
|
item.percentage = 100;
|
|
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.spread = this.$bigDecimal.subtract(item.ask, item.close)
|
|
item.ask = Number(this.$handleDigits(item.ask, item.digits))
|
|
item.ask = Number(this.$handleDigits(item.ask, item.digits))
|
|
item.bid = Number(this.$handleDigits(item.bid, item.digits))
|
|
item.bid = Number(this.$handleDigits(item.bid, item.digits))
|