Commit 5f8e40b6 by rongjun

bug

parent 92451abe
......@@ -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;
}
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment