전현진

Add descending ordered pumpingRatio

......@@ -6,6 +6,18 @@ var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
var sortingArr = function(data, ratio)
{
return data.sort(function(first, second)
{
var a = first[ratio];
var b = second[ratio];
return a > b ? -1 : a < b ? 1 : 0;
});
};
app.get('/pumping', function(req, res) {
fs.readFile('coin_name.txt', 'utf8', function(err,data){
......@@ -86,7 +98,6 @@ app.get('/pumping', function(req, res) {
coinJson.name = coinNameArr[i];
coinJson.pumpingRatio = minArr[i].tradeVolumePerThreeMin / volArr[i].tradeVolumePerWeek * 1000000
pumpingArr.push(coinJson);
console.log(coinJson);
if (pumpingArr.length >= coinNameArr.length)
resolve(pumpingArr);
}
......@@ -94,19 +105,22 @@ app.get('/pumping', function(req, res) {
return promise;
}
// get
getWeekVolume().then(function(volArr){
getThreeMinVolume().then(function(minArr){
getResultArr(volArr, minArr).then(function(result){
res.send(result);
//console.log(sortingArr(result, "pumpingRatio"));
res.send(sortingArr(result, "pumpingRatio"));
})
})
})
})
})
var server = app.listen(8082);
......
......@@ -8,22 +8,6 @@
// .then(json => console.log(json))
// .catch(err => console.error('error:' + err));
// const url = 'https://api.upbit.com/v1/candles/weeks/?market=' + data + '&count=1';
// var pumpingArr = new Array();
// const options = {method: 'GET', headers: {Accept: 'application/json'}};
// var coinJson = new Object();
// fetch(url, options)
// .then(res => res.json())
// .then(json => {
// coinJson.coin = 'KRW-BTC';
// coinJson.tradeVolume = json[0].candle_acc_trade_volume;
// console.log(coinJson);
// pumpingArr.push(coinJson);
// console.log(pumpingArr);
// })
// .catch(err => console.error('error:' + err));
const fetch = require('node-fetch');
const url = 'https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=1';
......
This diff is collapsed. Click to expand it.