|
@@ -7,6 +7,7 @@ const TimeKit = require('../kit/time-kit')
|
|
|
const TableKit = require('../kit/table-kit')
|
|
const TableKit = require('../kit/table-kit')
|
|
|
const Context = require("../libs/context")
|
|
const Context = require("../libs/context")
|
|
|
const assert = require("assert");
|
|
const assert = require("assert");
|
|
|
|
|
+const TickKit = require("../kit/tick-kit");
|
|
|
|
|
|
|
|
const holdingHandler = async function(context, task, token, pair) {
|
|
const holdingHandler = async function(context, task, token, pair) {
|
|
|
const config = context.config
|
|
const config = context.config
|
|
@@ -133,6 +134,8 @@ const showInfo = function(context, task) {
|
|
|
const OneInchPrice = token.OneInchPrice ? token.OneInchPrice : NaN
|
|
const OneInchPrice = token.OneInchPrice ? token.OneInchPrice : NaN
|
|
|
const BinancePrice = token.BinancePrice ? token.BinancePrice : NaN
|
|
const BinancePrice = token.BinancePrice ? token.BinancePrice : NaN
|
|
|
const DiffPrice = token.DiffPrice
|
|
const DiffPrice = token.DiffPrice
|
|
|
|
|
+ const mas = TickKit.MA(token.ticks, config.maPeriod)
|
|
|
|
|
+ const maValue = mas[mas.length - 1]
|
|
|
const percentage = NumKit.getSubFloat((DiffPrice / OneInchPrice) * 100, 2)
|
|
const percentage = NumKit.getSubFloat((DiffPrice / OneInchPrice) * 100, 2)
|
|
|
const orderPrice = token.orderPrice ? token.orderPrice : ''
|
|
const orderPrice = token.orderPrice ? token.orderPrice : ''
|
|
|
const orderPercentage = orderPrice ? NumKit.getSubFloat(((BinancePrice - orderPrice) / orderPrice) * 100, 2) : ''
|
|
const orderPercentage = orderPrice ? NumKit.getSubFloat(((BinancePrice - orderPrice) / orderPrice) * 100, 2) : ''
|
|
@@ -153,6 +156,7 @@ const showInfo = function(context, task) {
|
|
|
const isNoPrevHandleTime = !token.nextHandleTime
|
|
const isNoPrevHandleTime = !token.nextHandleTime
|
|
|
const isTimeCover = new Date().getTime() > token.nextHandleTime
|
|
const isTimeCover = new Date().getTime() > token.nextHandleTime
|
|
|
const timeCondition = isNoPrevHandleTime || isTimeCover
|
|
const timeCondition = isNoPrevHandleTime || isTimeCover
|
|
|
|
|
+ const priceCondition = BinancePrice > maValue
|
|
|
|
|
|
|
|
return priceCondition && percentageCondition && timeCondition
|
|
return priceCondition && percentageCondition && timeCondition
|
|
|
})()
|
|
})()
|
|
@@ -180,10 +184,12 @@ const priceHandler = async function(context, task) {
|
|
|
|
|
|
|
|
const OneInchPrice = NumKit.getSubFloat(await OneInch.price(fromIerc20Token.contract, tokenHash, amount, fromIerc20Token.decimals), priceTick)
|
|
const OneInchPrice = NumKit.getSubFloat(await OneInch.price(fromIerc20Token.contract, tokenHash, amount, fromIerc20Token.decimals), priceTick)
|
|
|
const BinancePrice = NumKit.getSubFloat(await BinanceSpot.realPrice(toToken.exchange.pair), priceTick)
|
|
const BinancePrice = NumKit.getSubFloat(await BinanceSpot.realPrice(toToken.exchange.pair), priceTick)
|
|
|
|
|
+ const ticks = BinanceKit.parseCloseTicks(await BinanceSpot.klines(toToken.exchange.pair))
|
|
|
|
|
|
|
|
toToken.OneInchPrice = OneInchPrice
|
|
toToken.OneInchPrice = OneInchPrice
|
|
|
toToken.BinancePrice = BinancePrice
|
|
toToken.BinancePrice = BinancePrice
|
|
|
toToken.DiffPrice = BinancePrice - OneInchPrice
|
|
toToken.DiffPrice = BinancePrice - OneInchPrice
|
|
|
|
|
+ toToken.ticks = ticks
|
|
|
|
|
|
|
|
if ((() => {
|
|
if ((() => {
|
|
|
return Math.abs(toToken.DiffPrice) < Math.pow(10, -priceTick)
|
|
return Math.abs(toToken.DiffPrice) < Math.pow(10, -priceTick)
|