Showing
3 changed files
with
16 additions
and
18 deletions
... | @@ -6,6 +6,18 @@ var bodyParser = require('body-parser'); | ... | @@ -6,6 +6,18 @@ var bodyParser = require('body-parser'); |
6 | app.use(bodyParser.urlencoded({ extended: false })); | 6 | app.use(bodyParser.urlencoded({ extended: false })); |
7 | app.use(bodyParser.json()); | 7 | app.use(bodyParser.json()); |
8 | 8 | ||
9 | +var sortingArr = function(data, ratio) | ||
10 | +{ | ||
11 | + return data.sort(function(first, second) | ||
12 | + { | ||
13 | + var a = first[ratio]; | ||
14 | + var b = second[ratio]; | ||
15 | + | ||
16 | + return a > b ? -1 : a < b ? 1 : 0; | ||
17 | + }); | ||
18 | +}; | ||
19 | + | ||
20 | + | ||
9 | 21 | ||
10 | app.get('/pumping', function(req, res) { | 22 | app.get('/pumping', function(req, res) { |
11 | fs.readFile('coin_name.txt', 'utf8', function(err,data){ | 23 | fs.readFile('coin_name.txt', 'utf8', function(err,data){ |
... | @@ -86,7 +98,6 @@ app.get('/pumping', function(req, res) { | ... | @@ -86,7 +98,6 @@ app.get('/pumping', function(req, res) { |
86 | coinJson.name = coinNameArr[i]; | 98 | coinJson.name = coinNameArr[i]; |
87 | coinJson.pumpingRatio = minArr[i].tradeVolumePerThreeMin / volArr[i].tradeVolumePerWeek * 1000000 | 99 | coinJson.pumpingRatio = minArr[i].tradeVolumePerThreeMin / volArr[i].tradeVolumePerWeek * 1000000 |
88 | pumpingArr.push(coinJson); | 100 | pumpingArr.push(coinJson); |
89 | - console.log(coinJson); | ||
90 | if (pumpingArr.length >= coinNameArr.length) | 101 | if (pumpingArr.length >= coinNameArr.length) |
91 | resolve(pumpingArr); | 102 | resolve(pumpingArr); |
92 | } | 103 | } |
... | @@ -95,18 +106,21 @@ app.get('/pumping', function(req, res) { | ... | @@ -95,18 +106,21 @@ app.get('/pumping', function(req, res) { |
95 | } | 106 | } |
96 | 107 | ||
97 | 108 | ||
109 | + | ||
98 | // get | 110 | // get |
99 | getWeekVolume().then(function(volArr){ | 111 | getWeekVolume().then(function(volArr){ |
100 | getThreeMinVolume().then(function(minArr){ | 112 | getThreeMinVolume().then(function(minArr){ |
101 | getResultArr(volArr, minArr).then(function(result){ | 113 | getResultArr(volArr, minArr).then(function(result){ |
102 | 114 | ||
103 | - res.send(result); | 115 | + //console.log(sortingArr(result, "pumpingRatio")); |
116 | + res.send(sortingArr(result, "pumpingRatio")); | ||
104 | 117 | ||
105 | }) | 118 | }) |
106 | }) | 119 | }) |
107 | }) | 120 | }) |
108 | 121 | ||
109 | 122 | ||
123 | + | ||
110 | }) | 124 | }) |
111 | }) | 125 | }) |
112 | var server = app.listen(8082); | 126 | var server = app.listen(8082); | ... | ... |
... | @@ -8,22 +8,6 @@ | ... | @@ -8,22 +8,6 @@ |
8 | // .then(json => console.log(json)) | 8 | // .then(json => console.log(json)) |
9 | // .catch(err => console.error('error:' + err)); | 9 | // .catch(err => console.error('error:' + err)); |
10 | 10 | ||
11 | -// const url = 'https://api.upbit.com/v1/candles/weeks/?market=' + data + '&count=1'; | ||
12 | -// var pumpingArr = new Array(); | ||
13 | -// const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
14 | -// var coinJson = new Object(); | ||
15 | -// fetch(url, options) | ||
16 | -// .then(res => res.json()) | ||
17 | -// .then(json => { | ||
18 | -// coinJson.coin = 'KRW-BTC'; | ||
19 | -// coinJson.tradeVolume = json[0].candle_acc_trade_volume; | ||
20 | -// console.log(coinJson); | ||
21 | -// pumpingArr.push(coinJson); | ||
22 | -// console.log(pumpingArr); | ||
23 | -// }) | ||
24 | -// .catch(err => console.error('error:' + err)); | ||
25 | - | ||
26 | - | ||
27 | const fetch = require('node-fetch'); | 11 | const fetch = require('node-fetch'); |
28 | 12 | ||
29 | const url = 'https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=1'; | 13 | const url = 'https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=1'; | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment