Browse Source

简化交易信息,准备对接交易

龚成明 2 years ago
parent
commit
874f11d499
1 changed files with 18 additions and 5 deletions
  1. 18 5
      scripts/one-pro.js

+ 18 - 5
scripts/one-pro.js

@@ -5,7 +5,18 @@ const Config = require('../config/config')
 const NumKit = require('../kit/num-kit')
 const TableKit = require('../kit/table-kit')
 
-const table = new TableKit(['pair', '1inch', 'binance', 'diff', 'percentage'])
+const orderHandler = function(context, task) {
+  const fileLogger = task.fileLogger
+  const tokenMap = context.tokenMap
+
+  // 逐对处理交易信息
+  Object.keys(tokenMap).forEach((tokenHash) => {
+    const token = tokenMap[tokenHash]
+    const pair = token.exchange.pair
+  })
+}
+
+const table = new TableKit(['pair', 'binance'], 25)
 
 const pricesHandler = function(context, task) {
   const logger = task.logger
@@ -27,10 +38,10 @@ const pricesHandler = function(context, task) {
     //
     // })()) return
 
-    const rows = [pair.toString(), OneInchPrice.toString(), BinancePrice.toString(), DiffPrice.toString(), percentage.toString()]
+    const rows = [pair.toString(), BinancePrice.toString()]
 
     // 识别到在拉盘
-    const isLong = (() => {
+    token.isLong = (() => {
       const percentageCondition = percentage > Config.percentageLimit
 
       const isNoPrevHandleTime = !token.prevHandleTime
@@ -40,11 +51,11 @@ const pricesHandler = function(context, task) {
       return percentageCondition && timeCondition
     })()
 
-    if (isLong) {
+    if (token.isLong) {
       token.prevHandleTime = new Date().getTime()
     }
     // 打印表格
-    table.showLine(rows, isLong ? fileLogger : undefined)
+    table.showLine(rows, token.isLong ? fileLogger : undefined)
   })
   table.printEndLine(logger)
 }
@@ -80,6 +91,8 @@ const onTickFun = async function() {
 
   // 价格处理帧
   pricesHandler(context, task)
+  // 交易、订单处理
+  orderHandler(context, task)
 }
 
 const onePro = new OneTask('OnePro', Config.delay, OneTask.baseInit, onTickFun)