瀏覽代碼

orderPercentage

龚成明 2 年之前
父節點
當前提交
5280265ef9
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      scripts/one-pro.js

+ 5 - 4
scripts/one-pro.js

@@ -31,7 +31,7 @@ const orderHandler = function(context, task) {
           fileLogger.info(`[止损]${pair}, price: ${token.orderPrice}, amount: ${token.orderAmount}.`)
         }
       }
-    } else {
+    } else if (token.isLong) {
       // TODO 对接买入交易
       token.orderPrice = token.BinancePrice
       token.orderBaseAmount = Config.baseTokenAmount
@@ -42,7 +42,7 @@ const orderHandler = function(context, task) {
   })
 }
 
-const table = new TableKit(['pair', 'binance', 'order price'], 25)
+const table = new TableKit(['pair', 'binance', 'order price', '%'], 25)
 
 const pricesHandler = function(context, task) {
   const logger = task.logger
@@ -58,14 +58,15 @@ const pricesHandler = function(context, task) {
     const BinancePrice = token.BinancePrice ? token.BinancePrice : NaN
     const DiffPrice = token.DiffPrice
     const percentage = NumKit.getSubFloat((DiffPrice / OneInchPrice) * 100, 2)
-    const orderPrice = token.orderPrice ? token.orderPrice : 0
+    const orderPrice = token.orderPrice ? token.orderPrice : NaN
+    const orderPercentage = NumKit.getSubFloat(((BinancePrice - orderPrice) / orderPrice) * 100, 2)
 
     // 价格非法的就不处理了
     // if ((() => {
     //
     // })()) return
 
-    const rows = [pair.toString(), BinancePrice.toString(), orderPrice.toString()]
+    const rows = [pair.toString(), BinancePrice.toString(), orderPrice.toString(), orderPercentage.toString()]
 
     // 识别到在拉盘
     token.isLong = (() => {