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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
111 deletions
pumped/app.js
pumped/app.js
View file @
ce4e34f
...
...
@@ -5,132 +5,109 @@ 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
promise
=
new
Promise
(
function
(
resolve
,
reject
)
var
volumePerWeekArr
=
new
Array
();
function
getWeekVolume
()
{
for
(
j
=
0
;
j
<
coinNameArr
.
length
/
10
;
j
++
){
for
(
i
=
j
*
10
;
i
<
(
j
+
1
)
*
10
&&
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
();
fetch
(
url
,
options
)
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
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
){
resolve
(
volumePerWeekArr
);
}
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
));
},
i
*
180
);
})(
i
);
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
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
();
fetch
(
url
,
options
)
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
coinJson
.
coin
=
coinNameArr
[
i
]
;
coinJson
.
tradeVolumePerWeek
=
json
[
0
].
candle_acc_trade_volume
;
volumePerWeekArr
.
push
(
coinJson
);
if
(
volumePerWeekArr
.
length
>=
coinNameArr
.
length
)
resolve
(
volumePerWeekArr
);
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
));
},
i
*
300
);
})(
i
);
}
}
//if(volumePerWeekArr.length > coinNameArr.length){
// console.log(volumePerThreeMinArr.length)
// resolve(volumePerWeekArr);
//}
});
return
promise
;
}
});
return
promise
;
})
}
function
getThreeMinVolume
()
{
fs
.
readFile
(
'coin_name2.txt'
,
'utf8'
,
function
(
err
,
data
){
coinNameArr
=
data
.
split
(
","
);
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
var
volumePerThreeMinArr
=
new
Array
();
function
getThreeMinVolume
()
{
for
(
j
=
0
;
j
<
coinNameArr
.
length
/
10
;
j
++
){
for
(
i
=
j
*
10
;
i
<
(
j
+
1
)
*
10
&&
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
();
fetch
(
url
,
options
)
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
coinJson
.
coin
=
coinNameArr
[
i
];
coinJson
.
tradeVolumePerThreeMin
=
json
[
0
].
candle_acc_trade_volume
;
volumePerThreeMinArr
.
push
(
coinJson
);
console
.
log
(
coinJson
);
console
.
log
(
i
)
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
));
},
i
*
180
);
})(
i
);
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
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
();
fetch
(
url
,
options
)
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
coinJson
.
coin
=
coinNameArr
[
i
];
coinJson
.
tradeVolumePerThreeMin
=
json
[
0
].
candle_acc_trade_volume
;
volumePerThreeMinArr
.
push
(
coinJson
);
if
(
volumePerThreeMinArr
.
length
>=
coinNameArr
.
length
)
resolve
(
volumePerThreeMinArr
);
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
));
},
i
*
300
);
})(
i
);
}
}
if
(
volumePerThreeMinArr
.
length
>
coinNameArr
.
length
){
console
.
log
(
volumePerThreeMinArr
.
length
)
resolve
(
volumePerThreeMinArr
);
}
});
return
promise
;
})
}
})
;
return
promise
;
}
async
function
getPumpingRatioArr
()
{
await
getWeekVolume
();
await
getThreeMinVolume
();
await
function
()
{
console
.
log
(
"함수 들어옴"
);
console
.
log
(
volumePerWeekArr
);
console
.
log
(
volumePerThreeMinArr
);
}
}
var
pumpingArr
=
new
Array
();
function
getResultArr
(
volArr
,
minArr
)
{
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();
// get
getWeekVolume
().
then
(
function
(
volArr
){
getThreeMinVolume
().
then
(
function
(
minArr
){
getResultArr
(
volArr
,
minArr
).
then
(
function
(
result
){
// fs.readFile('coin_name2.txt', 'utf8', function(err,data){
// coinNameArr = data.split(",");
res
.
send
(
result
);
})
})
})
// async function getPumingRatioArr()
// {
// getThreeMinVolume();
// getWeekVolume();
// await getThreeMinVolume().then(function(volumePerThreeMinArr){ });
// await getWeekVolume().then(function(volumePerWeekArr){ });
// 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.."
);
console
.
log
(
"Server Created.."
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment