|
|
@@ -26,6 +26,7 @@ const holdingHandler = async function(context, task, token, pair) {
|
|
|
const isStopLoss = isHardStopLoss || isTimeOverStopLoss
|
|
|
|
|
|
const isTimeOverStop = isTimeOverStopWin || isTimeOverStopLoss
|
|
|
+ const isHardStop = isHardStopWin || isHardStopLoss
|
|
|
|
|
|
assert.notEqual(isStopWin && isStopLoss, true, '止盈止损逻辑错误,请认真检查。')
|
|
|
|
|
|
@@ -35,7 +36,12 @@ const holdingHandler = async function(context, task, token, pair) {
|
|
|
|
|
|
token.orderPrice = undefined
|
|
|
token.orderAmount = undefined
|
|
|
- token.nextHandleTime = nowTimestamp + config.stopLossHandleSpaceHours * TimeKit.ONE_HOUR
|
|
|
+
|
|
|
+ if (isHardStop) {
|
|
|
+ token.nextHandleTime = nowTimestamp + config.hardStopHandleSpaceHours * TimeKit.ONE_HOUR
|
|
|
+ } else if (isTimeOverStop) {
|
|
|
+ token.nextHandleTime = nowTimestamp + config.normalStopHandleSpaceHours * TimeKit.ONE_HOUR
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
const sellMarketRst = await binanceSpot.sellMarket(pair, orderAmount)
|
|
|
@@ -46,11 +52,11 @@ const holdingHandler = async function(context, task, token, pair) {
|
|
|
// 交易数据持久化
|
|
|
await token.save()
|
|
|
|
|
|
- const log = `[${isTimeOverStop ? '时' : '强'}${isStopWin ? '盈+' : '损-'}]${pair}, `
|
|
|
+ const log = `[${isHardStop ? '强' : '时'}${isStopWin ? '盈+' : '损-'}]${pair}, `
|
|
|
+ `成交额${cummulativeQuoteQty}, 均价${orderPrice}->${price}, 卖出${orderAmount}个.`
|
|
|
fileLogger.info(log)
|
|
|
} catch (e) {
|
|
|
- const log = `[${isTimeOverStop ? '时' : '强'}止${isStopWin ? '盈' : '损'}失败]${pair}, ${e}`
|
|
|
+ const log = `[${isHardStop ? '强' : '时'}${isStopWin ? '盈' : '损'}失败]${pair}, ${e}`
|
|
|
fileLogger.error(log)
|
|
|
}
|
|
|
}
|
|
|
@@ -70,7 +76,7 @@ const noHoldingHandler = async function(context, task, token, pair) {
|
|
|
// 2. 判断余额是否够下单
|
|
|
if (config.baseTokenAmount > baseAssetAmount) {
|
|
|
fileLogger.info(`[余额不足]${pair}, 需要: ${config.baseTokenAmount}, 剩余: ${baseAssetAmount}.`)
|
|
|
- token.nextHandleTime = nowTimestamp + config.stopLossHandleSpaceHours * TimeKit.ONE_HOUR
|
|
|
+ token.nextHandleTime = nowTimestamp + config.normalStopHandleSpaceHours * TimeKit.ONE_HOUR
|
|
|
|
|
|
return
|
|
|
}
|