Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kucoin
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rongjun
kucoin
Commits
f083068d
Commit
f083068d
authored
Jun 04, 2019
by
zihan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改为rest来请求深度
parent
d740473f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
8 deletions
+38
-8
api_kucoin.js
api_kucoin.js
+4
-2
kucoinCollector.js
kucoinCollector.js
+30
-2
package.json
package.json
+1
-1
test_kucoin.js
test_kucoin.js
+3
-3
No files found.
api_kucoin.js
View file @
f083068d
...
...
@@ -5,7 +5,7 @@ const agent = proxy ? new SocksProxyAgent(proxy) : null;
const
request
=
require
(
'request'
);
const
proHost
=
'https://api.kucoin.com'
;
const
testHost
=
'https://openapi-sandbox.kucoin.com'
;
const
CryptoJS
=
require
(
'crypto-js'
);
//
const CryptoJS = require('crypto-js');
const
crypto
=
require
(
'crypto'
);
const
constants
=
require
(
'./constants'
);
const
{
IPs
,
mergeDepthAsk
,
mergeDepthBids
,
mergeDepth
}
=
require
(
'./util'
);
...
...
@@ -364,7 +364,9 @@ class biboxApi {
}
getOrderbook
(
symbol
,
depth
,
bindIP
,
callback
)
{
this
.
_publicRequest
(
"/api/v1/market/orderbook/level2_100"
,
{
"symbol"
:
symbol
},
callback
,
bindIP
);
this
.
_publicRequest
(
"/api/v1/market/orderbook/level2_20"
,
{
"symbol"
:
symbol
},
(
error
,
result
)
=>
{
callback
(
error
,
result
,
symbol
);
},
bindIP
);
}
}
...
...
kucoinCollector.js
View file @
f083068d
...
...
@@ -2,7 +2,7 @@ const BaseCollector = require('./baseCollector');
const
baseCurrencies
=
[
"ETH"
,
"BTC"
,
"USDT"
];
const
machine
=
process
.
env
[
'MACHINE'
];
const
biboxApi
=
require
(
'./api_kucoin'
);
const
IPs
=
require
(
'./util'
);
const
{
IPs
}
=
require
(
'./util'
);
let
coinInfoMap
=
null
;
// const totalOrderbook = {};
const
Strategy3MaxAmountMap
=
{
...
...
@@ -45,7 +45,35 @@ class KucoinCollector extends BaseCollector{
}
_subscribeSymbols
(
symbols
,
callback
,
subscribeDepth
){
this
.
_fetchDepthByWebsocket
(
symbols
,
subscribeDepth
,
callback
)
const
filteredSymbols
=
symbols
.
filter
((
item
)
=>
{
const
keySymbol
=
this
.
_convertSymbolName
(
item
);
const
mid
=
this
.
getMidCurrency
(
keySymbol
);
if
(
this
.
baseCurrencies
.
includes
(
mid
)){
return
true
;
}
const
array
=
this
.
getSymbols
(
mid
);
return
array
.
length
>
1
}).
sort
();
function
depthCallback
(
error
,
result
,
symbol
){
if
(
error
){
console
.
error
(
error
);
}
else
{
const
timestamp
=
result
.
data
.
time
;
const
bids
=
result
.
data
.
bids
.
slice
(
0
,
subscribeDepth
);
const
asks
=
result
.
data
.
asks
.
slice
(
0
,
subscribeDepth
);
const
version
=
result
.
data
.
sequence
;
callback
(
asks
,
bids
,
symbol
,
timestamp
,
version
);
}
}
console
.
log
(
"共有IP个数:"
+
IPs
.
length
);
const
interval
=
Math
.
round
(
100
/
IPs
.
length
);
let
index
=
0
;
setInterval
(()
=>
{
this
.
api
.
getOrderbook
(
filteredSymbols
[
index
%
filteredSymbols
.
length
],
5
,
IPs
[
index
%
IPs
.
length
],
depthCallback
.
bind
(
this
));
},
interval
);
// this._fetchDepthByWebsocket(symbols,subscribeDepth,callback)
// setTimeout(()=>{
// this._fetchDepthByRest(symbols,subscribeDepth,callback);
// },20000);
...
...
package.json
View file @
f083068d
...
...
@@ -5,7 +5,7 @@
"main"
:
"index.js"
,
"scripts"
:
{
"strategy2"
:
"node $NODE_DEBUG_OPTION strategy2.js"
,
"test"
:
"export MACHINE=K; export http_proxy='http://localhost:8118';export https_proxy='http://localhost:8118';export agent='socks:127.0.0.1:1086';node $NODE_DEBUG_OPTION test_kucoin.js"
,
"test"
:
"export MACHINE=K; export
KEY='123';export SECRET='345';export
http_proxy='http://localhost:8118';export https_proxy='http://localhost:8118';export agent='socks:127.0.0.1:1086';node $NODE_DEBUG_OPTION test_kucoin.js"
,
"strategy3"
:
"export MACHINE=K;export http_proxy='http://localhost:8118';export https_proxy='http://localhost:8118';export agent='socks:127.0.0.1:1086';node $NODE_DEBUG_OPTION kucoinStrategy3.js"
},
"author"
:
""
,
...
...
test_kucoin.js
View file @
f083068d
...
...
@@ -43,7 +43,7 @@ function testCollector(){
// const strategy3 = new BiboxStrategy3(collector);
// strategy3.run();
}
//
testCollector();
testCollector
();
function
printCurrency
(){
const
currentArray
=
[,
'ETH'
,
'BTC'
,
'LTC'
,
'BCH'
,
'USDT'
,
'USD'
,
'RMB'
,
"RCN"
,
"WINGS"
,
"TRX"
,
"LEND"
,
"CMT"
,
"POWR"
,
"HSR"
,
"GAS"
,
"RDN"
,
"TNT"
,
"OAX"
...
...
@@ -121,7 +121,7 @@ function printCurrency(){
}
})
}
printCurrency
()
//
printCurrency()
function
testOrder
(){
const
Order
=
require
(
'./order_kucoin'
);
...
...
@@ -164,7 +164,7 @@ function testOrder(){
// console.log(result);
// })
}
testOrder
();
//
testOrder();
// const amount = (0.0917 * parseFloat(0.00001005)).toFixed(10);
// console.log(amount);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment