전현진

add volumePerWeek, volumePerThreeMinute

1 +var express = require('express');
2 +var app = express();
3 +var fs = require('fs');
4 +const fetch = require('node-fetch');
5 +var bodyParser = require('body-parser');
6 +app.use(bodyParser.urlencoded({ extended: false }));
7 +app.use(bodyParser.json());
8 +var pumpingArr = new Array();
9 +var volumePerWeekArr = new Array();
10 +var volumePerThreeMinArr = new Array();
11 +
12 +function getWeekVolume()
13 +{
14 + fs.readFile('coin_name2.txt', 'utf8', function(err,data){
15 + coinNameArr = data.split(",");
16 + var promise = new Promise(function(resolve, reject)
17 + {
18 + for(j = 0; j < coinNameArr.length / 10; j++){
19 + for(i = j * 10; i < (j + 1) * 10 && i < coinNameArr.length; i++){
20 + (function(i){
21 + setTimeout(function(){
22 + const url = 'https://api.upbit.com/v1/candles/weeks/?market='+coinNameArr[i]+'&count=1';
23 + const options = {method: 'GET', headers: {Accept: 'application/json'}};
24 + var coinJson = new Object();
25 + fetch(url, options)
26 + .then(res => res.json())
27 + .then(json => {
28 + coinJson.coin = coinNameArr[i];
29 + coinJson.tradeVolumePerWeek = json[0].candle_acc_trade_volume;
30 + volumePerWeekArr.push(coinJson);
31 + console.log(coinJson);
32 + console.log(i)
33 + if(volumePerWeekArr.length>coinNameArr.length){
34 + resolve(volumePerWeekArr);
35 + }
36 + })
37 + .catch(err => console.error('error:' + err));
38 + },i*180);
39 + })(i);
40 + }
41 + }
42 + //if(volumePerWeekArr.length > coinNameArr.length){
43 + // console.log(volumePerThreeMinArr.length)
44 + // resolve(volumePerWeekArr);
45 + //}
46 +
47 + });
48 + return promise;
49 + })
50 +}
51 +
52 +function getThreeMinVolume()
53 +{
54 + fs.readFile('coin_name2.txt', 'utf8', function(err,data){
55 + coinNameArr = data.split(",");
56 + var promise = new Promise(function(resolve, reject)
57 + {
58 + for(j = 0; j < coinNameArr.length / 10; j++){
59 + for(i = j * 10; i < (j + 1) * 10 && i < coinNameArr.length; i++){
60 + (function(i){
61 + setTimeout(function(){
62 + const url = 'https://api.upbit.com/v1/candles/minutes/3?market='+coinNameArr[i]+'&count=1';
63 + const options = {method: 'GET', headers: {Accept: 'application/json'}};
64 + var coinJson = new Object();
65 + fetch(url, options)
66 + .then(res => res.json())
67 + .then(json => {
68 + coinJson.coin = coinNameArr[i];
69 + coinJson.tradeVolumePerThreeMin = json[0].candle_acc_trade_volume;
70 + volumePerThreeMinArr.push(coinJson);
71 + console.log(coinJson);
72 + console.log(i)
73 + })
74 + .catch(err => console.error('error:' + err));
75 + },i*180);
76 + })(i);
77 + }
78 + }
79 + if(volumePerThreeMinArr.length > coinNameArr.length){
80 + console.log(volumePerThreeMinArr.length)
81 + resolve(volumePerThreeMinArr);
82 + }
83 + });
84 +
85 + return promise;
86 + })
87 +}
88 +
89 +async function getPumpingRatioArr()
90 +{
91 + await getWeekVolume();
92 + await getThreeMinVolume();
93 +
94 + await function()
95 + {
96 + console.log("함수 들어옴");
97 + console.log(volumePerWeekArr);
98 + console.log(volumePerThreeMinArr);
99 + }
100 +}
101 +
102 +app.get('/pumping', function(req, res) {
103 +
104 + getPumpingRatioArr();
105 + //getThreeMinVolume();
106 + //getWeekVolume();
107 +
108 + // fs.readFile('coin_name2.txt', 'utf8', function(err,data){
109 + // coinNameArr = data.split(",");
110 +
111 +
112 + // async function getPumingRatioArr()
113 + // {
114 + // getThreeMinVolume();
115 + // getWeekVolume();
116 + // await getThreeMinVolume().then(function(volumePerThreeMinArr){ });
117 + // await getWeekVolume().then(function(volumePerWeekArr){ });
118 +
119 + // var coinJson = new Object();
120 + // for (var i = 0; i < coinNameArr.length; i++)
121 + // {
122 + // coinJson.name = coinNameArr[i];
123 + // coinJson.pumpingRatio = volumePerThreeMinArr[i].tradeVolumePerThreeMin / volumePerWeekArr[i].tradeVolumePerWeek * 100
124 + // pumpingArr.push(coinJson);
125 + // console.log(coinJson);
126 + // }
127 + // }
128 +
129 +
130 + // getPumingRatioArr().then(function(pumpingArr){
131 + // res.send(pumpingArr);
132 + // });
133 + // })
134 +})
135 +var server = app.listen(8082);
136 +console.log("Server Created..");
1 +KRW-BTC,KRW-ETH,KRW-NEO,KRW-MTL,KRW-LTC,KRW-XRP,KRW-ETC,KRW-OMG,KRW-SNT,KRW-WAVES,KRW-XEM,KRW-QTUM,KRW-LSK,KRW-STEEM,KRW-XLM,KRW-ARDR,KRW-KMD,KRW-ARK,KRW-STORJ,KRW-GRS,KRW-REP,KRW-EMC2,KRW-ADA,KRW-SBD,KRW-POWR,KRW-BTG,KRW-ICX,KRW-EOS,KRW-TRX,KRW-SC,KRW-IGNIS,KRW-ONT,KRW-ZIL,KRW-POLY,KRW-ZRX,KRW-LOOM,KRW-BCH,KRW-ADX,KRW-BAT,KRW-IOST,KRW-DMT,KRW-RFR,KRW-CVC,KRW-IQ,KRW-IOTA,KRW-MFT,KRW-ONG,KRW-GAS,KRW-UPP,KRW-ELF,KRW-KNC,KRW-BSV,KRW-THETA,KRW-EDR,KRW-QKC,KRW-BTT,KRW-MOC,KRW-ENJ,KRW-TFUEL,KRW-MANA,KRW-ANKR,KRW-AERGO,KRW-ATOM,KRW-TT,KRW-CRE,KRW-SOLVE,KRW-MBL,KRW-TSHP,KRW-WAXP,KRW-HBAR,KRW-MED,KRW-MLK,KRW-STPT,KRW-ORBS,KRW-VET,KRW-CHZ,KRW-PXL,KRW-STMX,KRW-DKA,KRW-HIVE,KRW-KAVA,KRW-AHT,KRW-LINK,KRW-XTZ,KRW-BORA,KRW-JST,KRW-CRO,KRW-TON,KRW-SXP,KRW-LAMB,KRW-HUNT,KRW-MARO,KRW-PLA,KRW-DOT,KRW-SRM,KRW-MVL,KRW-PCI,KRW-STRAX,KRW-AQT,KRW-BCHA,KRW-GLM,KRW-QTCON,KRW-SSX,KRW-META,KRW-OBSR,KRW-FCT2,KRW-LBC,KRW-CBK,KRW-SAND,KRW-HUM,KRW-DOGE,KRW-STRK,KRW-PUNDIX,KRW-FLOW,KRW-DAWN,KRW-AXS,KRW-STX
...\ No newline at end of file ...\ No newline at end of file
1 +// const fetch = require('node-fetch');
2 +
3 +// const url = 'https://api.upbit.com/v1/candles/weeks/?market=KRW-BTC&count=1';
4 +// const options = {method: 'GET', headers: {Accept: 'application/json'}};
5 +
6 +// fetch(url, options)
7 +// .then(res => res.json())
8 +// .then(json => console.log(json))
9 +// .catch(err => console.error('error:' + err));
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');
28 +
29 +const url = 'https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=1';
30 +const options = {method: 'GET', headers: {Accept: 'application/json'}};
31 +
32 +fetch(url, options)
33 + .then(res => res.json())
34 + .then(json => console.log(json))
35 + .catch(err => console.error('error:' + err));
This diff is collapsed. Click to expand it.