瀏覽代碼

使用nextHandleTime,废弃prevHandleTime

龚成明 2 年之前
父節點
當前提交
ba26b81f79
共有 2 個文件被更改,包括 15 次插入22 次删除
  1. 8 14
      config/config.js
  2. 7 8
      scripts/one-pro.js

文件差異過大導致無法顯示
+ 8 - 14
config/config.js


+ 7 - 8
scripts/one-pro.js

@@ -27,7 +27,7 @@ const orderHandler = function(context, task) {
         if (isStopWin) {
           fileLogger.info(`[止盈]${pair}, price: ${token.orderPrice}->${token.BinancePrice}, amount: ${token.orderAmount}.`)
           token.orderPrice = undefined
-          token.prevHandleTime = new Date().getTime()
+          token.nextHandleTime = new Date().getTime() + Config.stopWinHandleSpaceHours * (60 * 60 * 1000)
         }
       } else {
         // 止损逻辑
@@ -35,12 +35,11 @@ const orderHandler = function(context, task) {
         if (isStopLoss) {
           fileLogger.info(`[止损]${pair}, price: ${token.orderPrice}->${token.BinancePrice}, amount: ${token.orderAmount}.`)
           token.orderPrice = undefined
-          token.prevHandleTime = new Date().getTime()
+          token.nextHandleTime = new Date().getTime() + Config.stopLossHandleSpaceHours * (60 * 60 * 1000)
         }
       }
     } else if (token.isLong) {
       // TODO 对接买入交易
-      token.prevHandleTime = new Date().getTime()
       token.orderBaseAmount = Config.baseTokenAmount
 
       // 1. 获取base资产数量
@@ -54,7 +53,7 @@ const orderHandler = function(context, task) {
   })
 }
 
-const table = new TableKit(['pair', 'binance', 'order price', 'profit', 'prev time'], 20)
+const table = new TableKit(['pair', 'binance', 'order price', 'profit', 'next time'], 20)
 const showInfo = function(context, task) {
   const logger = task.logger
   const tokenMap = context.tokenMap
@@ -70,21 +69,21 @@ const showInfo = function(context, task) {
     const percentage = NumKit.getSubFloat((DiffPrice / OneInchPrice) * 100, 2)
     const orderPrice = token.orderPrice ? token.orderPrice : NaN
     const orderPercentage = NumKit.getSubFloat(((BinancePrice - orderPrice) / orderPrice) * 100, 2)
-    const prevTimeStr = token.prevHandleTime ? TimeKit.getTimeByMillisecond(token.prevHandleTime) : ''
+    const nextTimeStr = token.nextHandleTime ? TimeKit.getTimeByMillisecond(token.nextHandleTime) : ''
 
     // 价格非法的就不处理了
     // if ((() => {
     //
     // })()) return
 
-    const rows = [pair.toString(), BinancePrice.toString(), orderPrice.toString(), orderPercentage.toString().concat('%'), prevTimeStr]
+    const rows = [pair.toString(), BinancePrice.toString(), orderPrice.toString(), orderPercentage.toString().concat('%'), nextTimeStr]
 
     // 识别到在拉盘
     token.isLong = (() => {
       const percentageCondition = percentage > Config.percentageLimit
 
-      const isNoPrevHandleTime = !token.prevHandleTime
-      const isTimeCover = new Date().getTime() > token.prevHandleTime + Config.handleSpaceHours * (60 * 60 * 1000)
+      const isNoPrevHandleTime = !token.nextHandleTime
+      const isTimeCover = new Date().getTime() > token.nextHandleTime
       const timeCondition = isNoPrevHandleTime || isTimeCover
 
       return percentageCondition && timeCondition

部分文件因文件數量過多而無法顯示