Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Crypto
/
Crypto-auto-trading
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
June
2021-11-28 12:19:26 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d490040beb1d27d9d2913010c84efa2c91a5c313
d490040b
1 parent
e369aa7d
Modify transaction function
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
index.js
index.js
View file @
d490040
...
...
@@ -51,7 +51,15 @@ function get_asset(market) {
if
(
err
)
throw
new
Error
(
err
)
var
empty
=
new
Object
();
data
=
JSON
.
parse
(
body
);
resolve
(
data
);
data
.
filter
(
function
(
item
)
{
if
(
item
.
currency
==
market
.
split
(
'-'
)[
1
])
{
// resolve(item);
empty
.
market
=
item
;
}
else
if
(
item
.
currency
==
"KRW"
)
{
empty
.
KRW
=
item
}
resolve
(
empty
);
})
})
})
return
result
(
market
);
...
...
@@ -69,7 +77,7 @@ async function get_marketName() {
})
return
data
;
}
async
function
transaction_coin
(
coin_name
,
side
,
volume
,
price
,
ord_type
)
{
async
function
transaction_coin
(
coin_name
,
side
,
volume
,
price
,
ord_type
,
first
=
false
)
{
var
volume
=
volume
;
if
(
side
==
"ask"
){
await
User
.
findOne
({
uid
:
1
}).
then
((
result
)
=>
{
...
...
@@ -109,6 +117,16 @@ async function transaction_coin(coin_name, side, volume, price, ord_type) {
},
delay
)
})
var
my_asset
=
await
asset
(
1000
);
if
(
side
==
"bid"
){
const
user
=
new
User
({
uid
:
1
,
krw_balance
:
my_asset
.
KRW
.
balance
,
market
:
coin_name
,
count
:
1
,
avg_price
:
my_asset
.
market
.
avg_buy_price
,
volume
:
my_asset
.
market
.
balance
});
await
user
.
save
().
then
(()
=>
{
isuser
=
true
})
}
else
if
(
side
==
"ask"
){
User
.
deleteOne
({
uid
:
1
},(
err
,
res
)
=>
{
if
(
err
){
console
.
log
(
err
);
}
});
}
}).
catch
((
err
)
=>
{
console
.
log
(
err
.
error
)
})
}
async
function
get_marketInfo
()
{
...
...
@@ -256,8 +274,12 @@ app.listen(5000, async () => {
console
.
log
(
'server start'
)
//coin 이름,가격,거래대금 저장 , DB 최신화 1시간마다 반복
//5분마다 현재 가격 가져와서 db랑 비교후 매수 매도 기준잡기
var
t1
=
new
Array
();
test_data
=
await
(
latest_repeat
(
t1
));
//
var t1 = new Array();
//
test_data = await (latest_repeat(t1));
//계좌 정보 db 최신화
// console.log(await get_asset());
//매도
await
transaction_coin
(
"KRW-BTC"
,
"ask"
,
""
,
null
,
"market"
);
//매수
// await transaction_coin("KRW-BTC", "bid", null, divided_money, "price");
})
\ No newline at end of file
...
...
Please
register
or
login
to post a comment