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
166d7a62
Commit
166d7a62
authored
Sep 24, 2018
by
zihan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用多ip获取深度
parent
852d5481
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
4 deletions
+31
-4
api_kucoin.js
api_kucoin.js
+5
-3
kucoinCollector.js
kucoinCollector.js
+4
-1
util.js
util.js
+22
-0
No files found.
api_kucoin.js
View file @
166d7a62
...
@@ -75,7 +75,7 @@ class biboxApi {
...
@@ -75,7 +75,7 @@ class biboxApi {
return
newObj
;
//返回排好序的新对象
return
newObj
;
//返回排好序的新对象
}
}
_publicRequest
(
path
,
params
,
callback
)
{
_publicRequest
(
path
,
params
,
bindIP
,
callback
)
{
if
(
!
this
.
allowRequest
){
if
(
!
this
.
allowRequest
){
callback
({
code
:
"-2"
,
message
:
"出现超频情况,暂停提交请求"
});
callback
({
code
:
"-2"
,
message
:
"出现超频情况,暂停提交请求"
});
return
;
return
;
...
@@ -96,6 +96,8 @@ class biboxApi {
...
@@ -96,6 +96,8 @@ class biboxApi {
method
:
'GET'
,
method
:
'GET'
,
timeout
:
8000
,
timeout
:
8000
,
forever
:
true
,
forever
:
true
,
localAddress
:
bindIP
,
};
};
request
(
options
,
(
error
,
response
,
body
)
=>
{
request
(
options
,
(
error
,
response
,
body
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
@@ -232,8 +234,8 @@ class biboxApi {
...
@@ -232,8 +234,8 @@ class biboxApi {
};
};
this
.
_request
(
"POST"
,
"/v1/orderpending"
,
"orderpending/pendingHistoryList"
,
params
,
callback
);
this
.
_request
(
"POST"
,
"/v1/orderpending"
,
"orderpending/pendingHistoryList"
,
params
,
callback
);
}
}
getOrderbook
(
symbol
,
depth
,
callback
){
getOrderbook
(
symbol
,
depth
,
bindIP
,
callback
){
this
.
_publicRequest
(
"/v1/open/orders"
,{
"symbol"
:
symbol
},
callback
);
this
.
_publicRequest
(
"/v1/open/orders"
,{
"symbol"
:
symbol
},
bindIP
,
callback
);
}
}
}
}
...
...
kucoinCollector.js
View file @
166d7a62
...
@@ -4,6 +4,7 @@ const restCurrencies = ["PRA","AAC","AT","RED","BU","QTUM","EOSDAC","HPB","ORME"
...
@@ -4,6 +4,7 @@ const restCurrencies = ["PRA","AAC","AT","RED","BU","QTUM","EOSDAC","HPB","ORME"
const
machine
=
process
.
env
[
'MACHINE'
];
const
machine
=
process
.
env
[
'MACHINE'
];
const
biboxApi
=
require
(
'./api_kucoin'
);
const
biboxApi
=
require
(
'./api_kucoin'
);
const
zlib
=
require
(
'zlib'
);
const
zlib
=
require
(
'zlib'
);
const
IPReader
=
require
(
'./util'
);
let
coinInfoMap
=
null
let
coinInfoMap
=
null
const
Strategy3MaxAmountMap
=
{
const
Strategy3MaxAmountMap
=
{
USDT
:
300
,
USDT
:
300
,
...
@@ -69,14 +70,16 @@ class BiboxCollector extends BaseCollector{
...
@@ -69,14 +70,16 @@ class BiboxCollector extends BaseCollector{
// }
// }
const
perInterval
=
8
;
const
perInterval
=
8
;
const
totalInterval
=
perInterval
*
restSymbols
.
length
;
const
totalInterval
=
perInterval
*
restSymbols
.
length
;
const
IPs
=
IPReader
.
allIps
;
setInterval
(()
=>
{
setInterval
(()
=>
{
const
sortedSymbols
=
restSymbols
.
sort
(()
=>
{
const
sortedSymbols
=
restSymbols
.
sort
(()
=>
{
return
Math
.
random
()
>
0.5
return
Math
.
random
()
>
0.5
});
});
for
(
let
i
=
0
;
i
<
sortedSymbols
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
sortedSymbols
.
length
;
i
++
){
const
symbol
=
sortedSymbols
[
i
];
const
symbol
=
sortedSymbols
[
i
];
const
ipAddress
=
IPs
[
i
%
IPs
.
length
];
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
api
.
getOrderbook
(
symbol
,
depth
,(
error
,
result
)
=>
{
this
.
api
.
getOrderbook
(
symbol
,
depth
,
ipAddress
,
(
error
,
result
)
=>
{
if
(
error
){
if
(
error
){
console
.
error
(
"get depth by rest error:"
);
console
.
error
(
"get depth by rest error:"
);
console
.
error
(
error
);
console
.
error
(
error
);
...
...
util.js
0 → 100644
View file @
166d7a62
const
os
=
require
(
'os'
);
function
getLocalIpv4s
()
{
var
ifaces
=
os
.
networkInterfaces
();
var
ips
=
[];
var
func
=
function
(
details
)
{
if
(
details
.
family
===
'IPv6'
||
details
.
internal
)
{
return
;
}
ips
.
push
(
details
.
address
);
};
for
(
var
dev
in
ifaces
)
{
ifaces
[
dev
].
forEach
(
func
);
}
return
ips
;
};
const
ips
=
getLocalIpv4s
();
exports
.
allIps
=
ips
;
\ No newline at end of file
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