Showing
14 changed files
with
122 additions
and
298 deletions
.gitignore
deleted
100644 → 0
1 | -node_modules/ | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
README.md
deleted
100644 → 0
File mode changed
... | @@ -6,45 +6,108 @@ var bodyParser = require('body-parser'); | ... | @@ -6,45 +6,108 @@ 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 | -app.get('/price', function(req, res) { | 9 | + |
10 | +app.get('/pumping', function(req, res) { | ||
10 | fs.readFile('coin_name.txt', 'utf8', function(err,data){ | 11 | fs.readFile('coin_name.txt', 'utf8', function(err,data){ |
11 | - arr = data.split(","); | 12 | + coinNameArr = data.split(","); |
12 | - // console.log(arr); | 13 | + |
13 | - var responseList = new Array(); | 14 | + |
14 | - function print_coin(){ | 15 | + var volumePerWeekArr = new Array(); |
15 | - var promise = new Promise(function(resolve,reject){ | 16 | + function getWeekVolume() |
16 | - for(j=0;j<arr.length/10;j++){ | 17 | + { |
17 | - for(i=j*10;i<(j+1)*10;i++){ | 18 | + var promise = new Promise(function(resolve, reject) |
18 | - (function(i){ | 19 | + { |
19 | - setTimeout(function(){ | 20 | + for (i = 0; i < coinNameArr.length; ++i) |
20 | - const url = 'https://api.upbit.com/v1/candles/minutes/1?market='+arr[i]+'&count=1'; | 21 | + { |
22 | + (function (i) | ||
23 | + { | ||
24 | + setTimeout(function () { | ||
25 | + const url = 'https://api.upbit.com/v1/candles/weeks/?market='+coinNameArr[i]+'&count=1'; | ||
26 | + const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
27 | + var coinJson = new Object(); | ||
28 | + fetch(url, options) | ||
29 | + .then(res => res.json()) | ||
30 | + .then(json => { | ||
31 | + coinJson.coin = coinNameArr[i]; | ||
32 | + coinJson.tradeVolumePerWeek = json[0].candle_acc_trade_volume; | ||
33 | + volumePerWeekArr.push(coinJson); | ||
34 | + if (volumePerWeekArr.length >= coinNameArr.length) | ||
35 | + resolve(volumePerWeekArr); | ||
36 | + }) | ||
37 | + .catch(err => console.error('error:' + err)); | ||
38 | + }, i*300); | ||
39 | + })(i); | ||
40 | + } | ||
41 | + }); | ||
42 | + return promise; | ||
43 | + } | ||
44 | + | ||
45 | + | ||
46 | + var volumePerThreeMinArr = new Array(); | ||
47 | + function getThreeMinVolume() | ||
48 | + { | ||
49 | + var promise = new Promise(function(resolve, reject) | ||
50 | + { | ||
51 | + for (i = 0; i < coinNameArr.length; ++i) | ||
52 | + { | ||
53 | + (function (i) | ||
54 | + { | ||
55 | + setTimeout(function () { | ||
56 | + const url = 'https://api.upbit.com/v1/candles/minutes/3?market='+coinNameArr[i]+'&count=1'; | ||
21 | const options = {method: 'GET', headers: {Accept: 'application/json'}}; | 57 | const options = {method: 'GET', headers: {Accept: 'application/json'}}; |
22 | var coinJson = new Object(); | 58 | var coinJson = new Object(); |
23 | fetch(url, options) | 59 | fetch(url, options) |
24 | .then(res => res.json()) | 60 | .then(res => res.json()) |
25 | .then(json => { | 61 | .then(json => { |
26 | - coinJson.coin = arr[i]; | 62 | + coinJson.coin = coinNameArr[i]; |
27 | - coinJson.price = json[0].trade_price; | 63 | + coinJson.tradeVolumePerThreeMin = json[0].candle_acc_trade_volume; |
28 | - responseList.push(coinJson); | 64 | + volumePerThreeMinArr.push(coinJson); |
29 | - console.log(i) | 65 | + if (volumePerThreeMinArr.length >= coinNameArr.length) |
30 | - if(i>115){ | 66 | + resolve(volumePerThreeMinArr); |
31 | - resolve(responseList); | ||
32 | - } | ||
33 | }) | 67 | }) |
34 | .catch(err => console.error('error:' + err)); | 68 | .catch(err => console.error('error:' + err)); |
35 | - },i*180); | 69 | + }, i*300); |
36 | - })(i); | 70 | + })(i); |
37 | - } | ||
38 | } | 71 | } |
39 | - | 72 | + |
40 | }); | 73 | }); |
41 | return promise; | 74 | return promise; |
42 | - } | 75 | + } |
43 | - print_coin().then(function(resList){ | 76 | + |
44 | - res.send(resList); | 77 | + |
45 | - }); | 78 | + var pumpingArr = new Array(); |
46 | - }) | 79 | + function getResultArr(volArr, minArr) |
80 | + { | ||
81 | + var promise = new Promise(function(resolve, reject) | ||
82 | + { | ||
83 | + for (var i = 0; i < coinNameArr.length; i++) | ||
84 | + { | ||
85 | + var coinJson = new Object(); | ||
86 | + coinJson.name = coinNameArr[i]; | ||
87 | + coinJson.pumpingRatio = minArr[i].tradeVolumePerThreeMin / volArr[i].tradeVolumePerWeek * 1000000 | ||
88 | + pumpingArr.push(coinJson); | ||
89 | + console.log(coinJson); | ||
90 | + if (pumpingArr.length >= coinNameArr.length) | ||
91 | + resolve(pumpingArr); | ||
92 | + } | ||
93 | + }) | ||
94 | + return promise; | ||
95 | + } | ||
96 | + | ||
97 | + | ||
98 | + // get | ||
99 | + getWeekVolume().then(function(volArr){ | ||
100 | + getThreeMinVolume().then(function(minArr){ | ||
101 | + getResultArr(volArr, minArr).then(function(result){ | ||
102 | + | ||
103 | + res.send(result); | ||
104 | + | ||
105 | + }) | ||
106 | + }) | ||
107 | + }) | ||
108 | + | ||
109 | + | ||
110 | + }) | ||
47 | }) | 111 | }) |
48 | var server = app.listen(8082); | 112 | var server = app.listen(8082); |
49 | -console.log("Server Created.."); | 113 | +console.log("Server Created.."); |
50 | - | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
index.html
deleted
100644 → 0
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 | + | ||
1 | const fetch = require('node-fetch'); | 27 | const fetch = require('node-fetch'); |
2 | 28 | ||
3 | -const url = 'https://api.upbit.com/v1/candles/minutes/1?market=KRW-XRP&count=1'; | 29 | +const url = 'https://api.upbit.com/v1/candles/minutes/1?market=KRW-BTC&count=1'; |
4 | const options = {method: 'GET', headers: {Accept: 'application/json'}}; | 30 | const options = {method: 'GET', headers: {Accept: 'application/json'}}; |
5 | 31 | ||
6 | fetch(url, options) | 32 | fetch(url, options) |
7 | .then(res => res.json()) | 33 | .then(res => res.json()) |
8 | - .then(json => console.log(json[0].trade_price)) | ||
9 | - .catch(err => console.error('error:' + err)); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
34 | + .then(json => console.log(json)) | ||
35 | + .catch(err => console.error('error:' + err)); | ... | ... |
market.js
deleted
100644 → 0
1 | -const fetch = require('node-fetch'); | ||
2 | -const fs = require('fs'); | ||
3 | -const url = 'https://api.upbit.com/v1/market/all?isDetails=false'; | ||
4 | -const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
5 | - | ||
6 | -fetch(url, options) | ||
7 | - .then(res => res.json()) | ||
8 | - .then(json => { | ||
9 | - var coinName = []; | ||
10 | - var j = 0; | ||
11 | - var file = 'coin_name.txt'; | ||
12 | - fs.open(file,'w',function(err,fd){ | ||
13 | - if(err) throw err; | ||
14 | - }); | ||
15 | - for (i=0;i<json.length;i++) { | ||
16 | - if (json[i].market.indexOf("KRW")>-1){ | ||
17 | - console.log(json[i].market); | ||
18 | - coinName[j] = json[i].market; | ||
19 | - j=j+1; | ||
20 | - } | ||
21 | - } | ||
22 | - console.log(coinName); | ||
23 | - fs.writeFile(file,coinName,'utf8',function(error){ | ||
24 | - console.log('write end') | ||
25 | - }); | ||
26 | - }) | ||
27 | - .catch(err => console.error('error:' + err)); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
package.json
deleted
100644 → 0
1 | -{ | ||
2 | - "name": "Coin-trade-assistant", | ||
3 | - "version": "1.0.0", | ||
4 | - "description": "", | ||
5 | - "main": "index.js", | ||
6 | - "scripts": { | ||
7 | - "test": "echo \"Error: no test specified\" && exit 1", | ||
8 | - "start": "node server.js" | ||
9 | - }, | ||
10 | - "repository": { | ||
11 | - "type": "git", | ||
12 | - "url": "http://khuhub.khu.ac.kr/2018102235/Coin-trade-assistant.git" | ||
13 | - }, | ||
14 | - "keywords": [], | ||
15 | - "author": "", | ||
16 | - "license": "ISC", | ||
17 | - "dependencies": { | ||
18 | - "body-parser": "^1.19.0", | ||
19 | - "express": "^4.17.1", | ||
20 | - "jsonwebtoken": "^8.5.1", | ||
21 | - "node-fetch": "^2.6.1", | ||
22 | - "request": "^2.88.2" | ||
23 | - } | ||
24 | -} |
pumped/app.js
deleted
100644 → 0
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 | - | ||
9 | - | ||
10 | -app.get('/pumping', function(req, res) { | ||
11 | - fs.readFile('coin_name.txt', 'utf8', function(err,data){ | ||
12 | - coinNameArr = data.split(","); | ||
13 | - | ||
14 | - | ||
15 | - var volumePerWeekArr = new Array(); | ||
16 | - function getWeekVolume() | ||
17 | - { | ||
18 | - var promise = new Promise(function(resolve, reject) | ||
19 | - { | ||
20 | - for (i = 0; i < coinNameArr.length; ++i) | ||
21 | - { | ||
22 | - (function (i) | ||
23 | - { | ||
24 | - setTimeout(function () { | ||
25 | - const url = 'https://api.upbit.com/v1/candles/weeks/?market='+coinNameArr[i]+'&count=1'; | ||
26 | - const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
27 | - var coinJson = new Object(); | ||
28 | - fetch(url, options) | ||
29 | - .then(res => res.json()) | ||
30 | - .then(json => { | ||
31 | - coinJson.coin = coinNameArr[i]; | ||
32 | - coinJson.tradeVolumePerWeek = json[0].candle_acc_trade_volume; | ||
33 | - volumePerWeekArr.push(coinJson); | ||
34 | - if (volumePerWeekArr.length >= coinNameArr.length) | ||
35 | - resolve(volumePerWeekArr); | ||
36 | - }) | ||
37 | - .catch(err => console.error('error:' + err)); | ||
38 | - }, i*300); | ||
39 | - })(i); | ||
40 | - } | ||
41 | - }); | ||
42 | - return promise; | ||
43 | - } | ||
44 | - | ||
45 | - | ||
46 | - var volumePerThreeMinArr = new Array(); | ||
47 | - function getThreeMinVolume() | ||
48 | - { | ||
49 | - var promise = new Promise(function(resolve, reject) | ||
50 | - { | ||
51 | - for (i = 0; i < coinNameArr.length; ++i) | ||
52 | - { | ||
53 | - (function (i) | ||
54 | - { | ||
55 | - setTimeout(function () { | ||
56 | - const url = 'https://api.upbit.com/v1/candles/minutes/3?market='+coinNameArr[i]+'&count=1'; | ||
57 | - const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
58 | - var coinJson = new Object(); | ||
59 | - fetch(url, options) | ||
60 | - .then(res => res.json()) | ||
61 | - .then(json => { | ||
62 | - coinJson.coin = coinNameArr[i]; | ||
63 | - coinJson.tradeVolumePerThreeMin = json[0].candle_acc_trade_volume; | ||
64 | - volumePerThreeMinArr.push(coinJson); | ||
65 | - if (volumePerThreeMinArr.length >= coinNameArr.length) | ||
66 | - resolve(volumePerThreeMinArr); | ||
67 | - }) | ||
68 | - .catch(err => console.error('error:' + err)); | ||
69 | - }, i*300); | ||
70 | - })(i); | ||
71 | - } | ||
72 | - | ||
73 | - }); | ||
74 | - return promise; | ||
75 | - } | ||
76 | - | ||
77 | - | ||
78 | - var pumpingArr = new Array(); | ||
79 | - function getResultArr(volArr, minArr) | ||
80 | - { | ||
81 | - var promise = new Promise(function(resolve, reject) | ||
82 | - { | ||
83 | - for (var i = 0; i < coinNameArr.length; i++) | ||
84 | - { | ||
85 | - var coinJson = new Object(); | ||
86 | - coinJson.name = coinNameArr[i]; | ||
87 | - coinJson.pumpingRatio = minArr[i].tradeVolumePerThreeMin / volArr[i].tradeVolumePerWeek * 1000000 | ||
88 | - pumpingArr.push(coinJson); | ||
89 | - console.log(coinJson); | ||
90 | - if (pumpingArr.length >= coinNameArr.length) | ||
91 | - resolve(pumpingArr); | ||
92 | - } | ||
93 | - }) | ||
94 | - return promise; | ||
95 | - } | ||
96 | - | ||
97 | - | ||
98 | - // get | ||
99 | - getWeekVolume().then(function(volArr){ | ||
100 | - getThreeMinVolume().then(function(minArr){ | ||
101 | - getResultArr(volArr, minArr).then(function(result){ | ||
102 | - | ||
103 | - res.send(result); | ||
104 | - | ||
105 | - }) | ||
106 | - }) | ||
107 | - }) | ||
108 | - | ||
109 | - | ||
110 | - }) | ||
111 | -}) | ||
112 | -var server = app.listen(8082); | ||
113 | -console.log("Server Created.."); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
pumped/coin_name.txt
deleted
100644 → 0
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 |
pumped/index.js
deleted
100644 → 0
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)); |
pumped/package-lock.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
test.js
deleted
100644 → 0
1 | -const fetch = require('node-fetch'); | ||
2 | -var fs = require('fs'); | ||
3 | - | ||
4 | - | ||
5 | - | ||
6 | -fs.readFile('coin_name.txt', 'utf8', function(err,data){ | ||
7 | - arr = data.split(","); | ||
8 | - // console.log(arr); | ||
9 | - var responseList = new Array(); | ||
10 | - for(j=0;j<2;j++){ | ||
11 | - for(i=j*10;i<(j+1)*10;i++){ | ||
12 | - (function(i){ | ||
13 | - setTimeout(function(){ | ||
14 | - const url = 'https://api.upbit.com/v1/candles/minutes/1?market='+arr[i]+'&count=1'; | ||
15 | - const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
16 | - var coinJson = new Object(); | ||
17 | - fetch(url, options) | ||
18 | - .then(res => res.json()) | ||
19 | - .then(json => { | ||
20 | - coinJson.coin = arr[i]; | ||
21 | - coinJson.price = json[0].trade_price; | ||
22 | - responseList.push(coinJson); | ||
23 | - // console.log(responseList) | ||
24 | - console.log(i) | ||
25 | - }) | ||
26 | - .catch(err => console.error('error:' + err)); | ||
27 | - },i*180); | ||
28 | - })(i); | ||
29 | - } | ||
30 | - } | ||
31 | - | ||
32 | - | ||
33 | -}) |
test2.js
deleted
100644 → 0
1 | -const delay = () => { | ||
2 | - const randomDelay = Math.floor(Math.random() * 4) * 100 | ||
3 | - return new Promise(resolve => setTimeout(resolve, randomDelay)) | ||
4 | - } | ||
5 | - | ||
6 | -const loop = async (list) => { | ||
7 | -console.log("시작") | ||
8 | -const promises = list.map(async data => { | ||
9 | - return await delay() | ||
10 | - .then(() => data) | ||
11 | -}) | ||
12 | - | ||
13 | -const results = await Promise.all(promises) | ||
14 | -results.forEach(data => console.log(data)) | ||
15 | -console.log("끝") | ||
16 | -} | ||
17 | - | ||
18 | -const list = [1, 2, 3, 4, 5, 6, 7] | ||
19 | -loop(list) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment