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-07 14:16:17 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
90da99a2914736fe847fde5ef5356b640143a2ee
90da99a2
1 parent
6a144567
Deleete app.js for merging
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
127 deletions
app.js
app.js
deleted
100644 → 0
View file @
6a14456
var
express
=
require
(
'express'
);
var
app
=
express
();
var
fs
=
require
(
'fs'
);
const
fetch
=
require
(
'node-fetch'
);
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
){
coinNameArr
=
data
.
split
(
","
);
var
volumePerWeekArr
=
new
Array
();
function
getWeekVolume
()
{
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
);
}
});
return
promise
;
}
var
volumePerThreeMinArr
=
new
Array
();
function
getThreeMinVolume
()
{
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
);
}
});
return
promise
;
}
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
);
if
(
pumpingArr
.
length
>=
coinNameArr
.
length
)
resolve
(
pumpingArr
);
}
})
return
promise
;
}
// get
getWeekVolume
().
then
(
function
(
volArr
){
getThreeMinVolume
().
then
(
function
(
minArr
){
getResultArr
(
volArr
,
minArr
).
then
(
function
(
result
){
//console.log(sortingArr(result, "pumpingRatio"));
res
.
send
(
sortingArr
(
result
,
"pumpingRatio"
));
})
})
})
})
})
var
server
=
app
.
listen
(
8082
);
console
.
log
(
"Server Created.."
);
\ No newline at end of file
Please
register
or
login
to post a comment