|
@@ -20,12 +20,14 @@ const showPrices = function(context, task) {
|
|
|
const pair = token.exchange.pair
|
|
const pair = token.exchange.pair
|
|
|
const OneInchPrice = token.OneInchPrice
|
|
const OneInchPrice = token.OneInchPrice
|
|
|
const BinancePrice = token.BinancePrice
|
|
const BinancePrice = token.BinancePrice
|
|
|
|
|
+ const PrevOneInchPrice = token.PrevOneInchPrice
|
|
|
|
|
+ const PrevBinancePrice = token.PrevBinancePrice
|
|
|
const DiffPrice = token.DiffPrice
|
|
const DiffPrice = token.DiffPrice
|
|
|
const percentage = NumKit.getSubFloat((DiffPrice / OneInchPrice) * 100, 2)
|
|
const percentage = NumKit.getSubFloat((DiffPrice / OneInchPrice) * 100, 2)
|
|
|
|
|
|
|
|
// 价格非法的就不输出了
|
|
// 价格非法的就不输出了
|
|
|
if ((() => {
|
|
if ((() => {
|
|
|
- return !OneInchPrice || !BinancePrice
|
|
|
|
|
|
|
+ return !OneInchPrice || !BinancePrice || PrevOneInchPrice === OneInchPrice || PrevBinancePrice === BinancePrice
|
|
|
})()) return
|
|
})()) return
|
|
|
|
|
|
|
|
const rows = [pair.toString(), OneInchPrice.toString(), BinancePrice.toString(), DiffPrice.toString(), percentage.toString()]
|
|
const rows = [pair.toString(), OneInchPrice.toString(), BinancePrice.toString(), DiffPrice.toString(), percentage.toString()]
|
|
@@ -70,6 +72,14 @@ const onTickFun = async function() {
|
|
|
|
|
|
|
|
// 绘制帧
|
|
// 绘制帧
|
|
|
showPrices(context, task)
|
|
showPrices(context, task)
|
|
|
|
|
+
|
|
|
|
|
+ // 赋予prev价格值
|
|
|
|
|
+ Object.keys(tokenMap).forEach((tokenHash) => {
|
|
|
|
|
+ const token = tokenMap[tokenHash]
|
|
|
|
|
+
|
|
|
|
|
+ token.PrevOneInchPrice = token.OneInchPrice
|
|
|
|
|
+ token.PrevBinancePrice = token.BinancePrice
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const priceMonitor = new OneTask('PriceMonitor',5 * 1000, OneTask.baseInit, onTickFun)
|
|
const priceMonitor = new OneTask('PriceMonitor',5 * 1000, OneTask.baseInit, onTickFun)
|