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
5f8e40b6
Commit
5f8e40b6
authored
Oct 23, 2018
by
rongjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
92451abe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
13 deletions
+22
-13
kucoinStrategy3.js
kucoinStrategy3.js
+21
-12
strategy3.js
strategy3.js
+1
-1
No files found.
kucoinStrategy3.js
View file @
5f8e40b6
...
...
@@ -140,18 +140,27 @@ class BiboxStrategy3 extends Strategy3 {
_getMinMargin
(){
return
0.08
;
}
_giveUpOrder
(
baseCurrency1
,
midCurrency
,
baseCurrency2
,
totalMarginRate
,
buyDepth
,
sellDepth
){
if
(
sellDepth
===
1
){
const
sellPrices
=
this
.
collector
.
getDepth
(
midCurrency
,
baseCurrency2
,
2
);
const
possibleLoss
=
(
sellPrices
[
0
][
0
]
-
sellPrices
[
1
][
0
])
/
sellPrices
[
0
][
0
];
if
(
sellPrices
[
0
][
0
]
===
this
.
lastPrice
){
this
.
samePriceCount
++
;
}
else
{
this
.
lastPrice
=
sellPrices
[
0
][
0
];
this
.
samePriceCount
=
0
;
}
if
(
possibleLoss
*
100
-
totalMarginRate
>
3
){
console
.
log
(
`此单风险过高,放弃。买一:
${
sellPrices
[
0
][
0
]}
,买二:
${
sellPrices
[
1
][
0
]}
,损失率
${(
possibleLoss
*
100
).
toFixed
(
4
)}
,利差:
${
totalMarginRate
.
toFixed
(
4
)}
`
);
_giveUpOrder
(
baseCurrency1
,
midCurrency
,
baseCurrency2
,
totalMarginRate
,
buyDepth
,
sellDepth
,
returnAmount
,
returnAmountCurrency
){
// if(sellDepth ===1){
// const sellPrices = this.collector.getDepth(midCurrency, baseCurrency2, 2);
// const possibleLoss = (sellPrices[0][0] - sellPrices[1][0])/sellPrices[0][0];
// if(sellPrices[0][0] === this.lastPrice){
// this.samePriceCount ++;
// }else{
// this.lastPrice = sellPrices[0][0];
// this.samePriceCount = 0;
// }
// if(possibleLoss*100-totalMarginRate > 3){
// console.log(`此单风险过高,放弃。买一:${sellPrices[0][0]},买二:${sellPrices[1][0]},损失率${(possibleLoss * 100).toFixed(4)},利差:${totalMarginRate.toFixed(4)}`);
// return true;
// }
// }
if
(
sellDepth
<
5
){
const
possibleDepth
=
this
.
collector
.
getDepth
(
midCurrency
,
baseCurrency2
,
sellDepth
+
1
);
const
possibleLossRate
=
(
possibleDepth
[
sellDepth
-
1
][
0
]
-
possibleDepth
[
sellDepth
][
0
])
/
possibleDepth
[
sellDepth
-
1
][
0
]
-
totalMarginRate
/
100
;
const
possibleLossMoney
=
possibleLossRate
*
returnAmount
*
this
.
collector
.
getPrice
(
returnAmountCurrency
,
'USDT'
)
if
(
possibleLossMoney
>
30
){
console
.
log
(
'此单风险过高,放弃;可能损失金钱是:'
+
possibleLossMoney
)
return
true
;
}
}
...
...
strategy3.js
View file @
5f8e40b6
...
...
@@ -324,7 +324,7 @@ class Strategy3 {
}
return_amount
=
this
.
collector
.
processAmount
(
baseCurrency2
,
baseCurrency1
,
return_amount
);
if
(
profit
>
0
&&
profit
>
bestProfit
&&
return_amount
>
this
.
_getMinReturnAmount
(
returnAmountCurrency
))
{
if
(
this
.
_giveUpOrder
(
baseCurrency1
,
midCurrency
,
baseCurrency2
,
totalMarginRate
,
buyDepth
,
sellDepth
)){
if
(
this
.
_giveUpOrder
(
baseCurrency1
,
midCurrency
,
baseCurrency2
,
totalMarginRate
,
buyDepth
,
sellDepth
,
returnAmount
,
returnAmountCurrency
)){
return
[
0
,
0
,
-
3
,
0
,
0
,
0
,
0
,
0
,
0
];
}
bestReturnAmount
=
return_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