Commit 4d029083 by zihan

发现同一深度出现3次,也损失率高也可以尝试去抢

parent eac14b27
......@@ -14,6 +14,8 @@ class BiboxStrategy3 extends Strategy3 {
constructor(collector) {
super(collector, machine);
this.orderService = new Order();
this.lastPrice = -1;
this.samePriceCount = 0;
}
_doTrade(baseCurrency1, midCurrency, baseCurrency2, buyPrice, sellPrice, returnPrice, amount, returnAmount, doSaveOrder) {
......@@ -142,7 +144,13 @@ class BiboxStrategy3 extends Strategy3 {
if(sellDepth ===1){
const sellPrices = this.collector.getDepth(midCurrency, baseCurrency2, 2);
const possibleLoss = (sellPrices[0][0] - sellPrices[1][0])/sellPrices[0][0];
if(possibleLoss*100 > 3){
if(sellPrices[0][0] === this.lastPrice){
this.samePriceCount ++;
}else{
this.lastPrice = sellPrices[0][0];
this.samePriceCount = 0;
}
if(possibleLoss*100 > 3 && this.samePriceCount <3){
console.log(`此单风险过高,放弃。买一:${sellPrices[0][0]},买二:${sellPrices[1][0]},损失率${(possibleLoss * 100).toFixed(4)},利差:${totalMarginRate.toFixed(4)}`);
return true;
}
......
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