Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정홍주
/
Coin-trade-assistant
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
전현진
2021-06-04 04:26:02 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ce4e34fab3f52db1937f31191a3bfc00b8bfea32
ce4e34fa
1 parent
5e757e96
Add pumping ratio
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
78 deletions
pumped/app.js
pumped/app.js
View file @
ce4e34f
...
...
@@ -5,20 +5,23 @@ const fetch = require('node-fetch');
var
bodyParser
=
require
(
'body-parser'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParser
.
json
());
var
pumpingArr
=
new
Array
();
var
volumePerWeekArr
=
new
Array
();
var
volumePerThreeMinArr
=
new
Array
();
function
getWeekVolume
()
{
fs
.
readFile
(
'coin_name
2
.txt'
,
'utf8'
,
function
(
err
,
data
){
app
.
get
(
'/pumping'
,
function
(
req
,
res
)
{
fs
.
readFile
(
'coin_name.txt'
,
'utf8'
,
function
(
err
,
data
){
coinNameArr
=
data
.
split
(
","
);
var
volumePerWeekArr
=
new
Array
();
function
getWeekVolume
()
{
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
for
(
j
=
0
;
j
<
coinNameArr
.
length
/
10
;
j
++
){
for
(
i
=
j
*
10
;
i
<
(
j
+
1
)
*
10
&&
i
<
coinNameArr
.
length
;
i
++
){
(
function
(
i
){
setTimeout
(
function
(){
for
(
i
=
0
;
i
<
coinNameArr
.
length
;
++
i
)
{
(
function
(
i
)
{
setTimeout
(
function
()
{
const
url
=
'https://api.upbit.com/v1/candles/weeks/?market='
+
coinNameArr
[
i
]
+
'&count=1'
;
const
options
=
{
method
:
'GET'
,
headers
:
{
Accept
:
'application/json'
}};
var
coinJson
=
new
Object
();
...
...
@@ -28,37 +31,28 @@ function getWeekVolume()
coinJson
.
coin
=
coinNameArr
[
i
];
coinJson
.
tradeVolumePerWeek
=
json
[
0
].
candle_acc_trade_volume
;
volumePerWeekArr
.
push
(
coinJson
);
console
.
log
(
coinJson
);
console
.
log
(
i
)
if
(
volumePerWeekArr
.
length
>
coinNameArr
.
length
){
if
(
volumePerWeekArr
.
length
>=
coinNameArr
.
length
)
resolve
(
volumePerWeekArr
);
}
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
));
},
i
*
180
);
},
i
*
300
);
})(
i
);
}
}
//if(volumePerWeekArr.length > coinNameArr.length){
// console.log(volumePerThreeMinArr.length)
// resolve(volumePerWeekArr);
//}
});
return
promise
;
})
}
}
function
getThreeMinVolume
()
{
fs
.
readFile
(
'coin_name2.txt'
,
'utf8'
,
function
(
err
,
data
){
coinNameArr
=
data
.
split
(
","
);
var
volumePerThreeMinArr
=
new
Array
();
function
getThreeMinVolume
()
{
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
for
(
j
=
0
;
j
<
coinNameArr
.
length
/
10
;
j
++
){
for
(
i
=
j
*
10
;
i
<
(
j
+
1
)
*
10
&&
i
<
coinNameArr
.
length
;
i
++
){
(
function
(
i
){
setTimeout
(
function
(){
for
(
i
=
0
;
i
<
coinNameArr
.
length
;
++
i
)
{
(
function
(
i
)
{
setTimeout
(
function
()
{
const
url
=
'https://api.upbit.com/v1/candles/minutes/3?market='
+
coinNameArr
[
i
]
+
'&count=1'
;
const
options
=
{
method
:
'GET'
,
headers
:
{
Accept
:
'application/json'
}};
var
coinJson
=
new
Object
();
...
...
@@ -68,69 +62,52 @@ function getThreeMinVolume()
coinJson
.
coin
=
coinNameArr
[
i
];
coinJson
.
tradeVolumePerThreeMin
=
json
[
0
].
candle_acc_trade_volume
;
volumePerThreeMinArr
.
push
(
coinJson
);
console
.
log
(
coinJson
);
console
.
log
(
i
)
if
(
volumePerThreeMinArr
.
length
>=
coinNameArr
.
length
)
resolve
(
volumePerThreeMinArr
);
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
));
},
i
*
180
);
},
i
*
300
);
})(
i
);
}
}
if
(
volumePerThreeMinArr
.
length
>
coinNameArr
.
length
){
console
.
log
(
volumePerThreeMinArr
.
length
)
resolve
(
volumePerThreeMinArr
);
}
});
});
return
promise
;
})
}
}
async
function
getPumpingRatioArr
()
{
await
getWeekVolume
();
await
getThreeMinVolume
();
await
function
()
var
pumpingArr
=
new
Array
();
function
getResultArr
(
volArr
,
minArr
)
{
console
.
log
(
"함수 들어옴"
);
console
.
log
(
volumePerWeekArr
);
console
.
log
(
volumePerThreeMinArr
);
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
for
(
var
i
=
0
;
i
<
coinNameArr
.
length
;
i
++
)
{
var
coinJson
=
new
Object
();
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
);
}
})
return
promise
;
}
}
app
.
get
(
'/pumping'
,
function
(
req
,
res
)
{
getPumpingRatioArr
();
//getThreeMinVolume();
//getWeekVolume();
// fs.readFile('coin_name2.txt', 'utf8', function(err,data){
// coinNameArr = data.split(",");
// get
getWeekVolume
().
then
(
function
(
volArr
){
getThreeMinVolume
().
then
(
function
(
minArr
){
getResultArr
(
volArr
,
minArr
).
then
(
function
(
result
){
// async function getPumingRatioArr()
// {
// getThreeMinVolume();
// getWeekVolume();
// await getThreeMinVolume().then(function(volumePerThreeMinArr){ });
// await getWeekVolume().then(function(volumePerWeekArr){ });
res
.
send
(
result
);
// var coinJson = new Object();
// for (var i = 0; i < coinNameArr.length; i++)
// {
// coinJson.name = coinNameArr[i];
// coinJson.pumpingRatio = volumePerThreeMinArr[i].tradeVolumePerThreeMin / volumePerWeekArr[i].tradeVolumePerWeek * 100
// pumpingArr.push(coinJson);
// console.log(coinJson);
// }
// }
})
})
})
// getPumingRatioArr().then(function(pumpingArr){
// res.send(pumpingArr);
// });
// })
})
})
var
server
=
app
.
listen
(
8082
);
console
.
log
(
"Server Created.."
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment