유동성 이유로 인해 시장에서 많은 양의 스메이싱과 당기는 일이있을 때 필연적으로 큰 가격 변동이 발생할 것이며 거래소 사이에 즉각적인 가격 차이가 형성 될 것이며 전략은 빠른 거래가 실행되는 이러한 순간을 포착하여 낮은 가격으로 구매하고 높은 가격으로 판매하는 과정을 완료하는 것입니다. 어떤 고객들은 왜 이렇게 많은 교환을 해야 하는지 물어봤습니다. 이것은 피할 수 없습니다. 우리가 얻는 것은 교환 사이의 즉각적인 가격 차이입니다. 더 많은 교환, 크로스오버 후에 형성된 가격 차이에 대한 더 많은 기회입니다.
function createOrders(depths, askOrders, bidOrders) {
let asksIndex = 0;
let bidIndex = 0;
for (let i = 0; i < depths.length; i++) {
let exchangeTariff = getExchangeTariff(i);
let asks = depths[i].Asks;
let bids = depths[i].Bids;
for (let j = 0; j < Math.min(asks.length, bids.length, 20); j++) {
if (asks[j].Amount >= minTakerAmount) {
askOrders[asksIndex] = {
"Price": asks[j].Price,
"Amount": asks[j].Amount,
"Fee": asks[j].Price * exchangeTariff,
"RealPrice": asks[j].Price * (1 + exchangeTariff),
"Index": i,
};
asksIndex++;
}
if (bids[j].Amount >= minTakerAmount) {
bidOrders[bidIndex] = {
"Price": bids[j].Price,
"Amount": bids[j].Amount,
"Fee": bids[j].Price * exchangeTariff,
"RealPrice": bids[j].Price * (1 - exchangeTariff),
"Index": i,
};
bidIndex++;
}
}
}
askOrders.sort(function (a, b) {
return a.RealPrice - b.RealPrice;
});
bidOrders.sort(function (a, b) {
return b.RealPrice - a.RealPrice;
});
}
function getArbitrageOrders(askOrders, bidOrders) {
let ret = [];
for (let i = 0; i < askOrders.length; i++) {
for (let j = 0; j < bidOrders.length; j++) {
let bidOrder = bidOrders[j];
let askOrder = askOrders[i];
if (bidOrder.Index === askOrder.Index) {
continue
}
let minMigrateDiffPrice = ((askOrder.Price + bidOrder.Price) / 2 * minMigrateDiffPricePercent / 100);
if (bidOrder.RealPrice - askOrder.RealPrice > minMigrateDiffPrice) {
ret.push({
"Ask": askOrder,
"Bid": bidOrder,
})
}
}
}
if (ret.length === 0) {
ret.push({
"Ask": askOrders[0],
"Bid": bidOrders[0],
});
}
//Sort by best spread
ret.sort((a, b) => {
return (b.Bid.RealPrice - b.Ask.RealPrice) - (a.Bid.RealPrice - a.Ask.RealPrice);
});
return ret;
}
var askOrder = arbitrageOrder.Ask;
var bidOrder = arbitrageOrder.Bid;
var perAmountFee = arbitrageOrder.Ask.Fee + arbitrageOrder.Bid.Fee;
var minRealDiffPrice = (askOrder.Price + bidOrder.Price) / 2 * minDiffPricePercent / 100;
var minMigrateDiffPrice = ((askOrder.Price + bidOrder.Price) / 2 * minMigrateDiffPricePercent / 100);
var curRealDiffPrice = arbitrageOrder.Bid.RealPrice - arbitrageOrder.Ask.RealPrice;
var buyExchange = exchanges[arbitrageOrder.Ask.Index];
var sellExchange = exchanges[arbitrageOrder.Bid.Index];
var buySellAmount = 0;
if (curRealDiffPrice > minRealDiffPrice) {
buySellAmount = math.min(
bidOrder.Amount,
askOrder.Amount,
maxTakerAmount,
runningInfo.Accounts[bidOrder.Index].CurStocks,
runningInfo.Accounts[askOrder.Index].CurBalance / askOrder.Price
);
} else if (bidOrder.Index !== askOrder.Index) {
if (migrateCoinEx == -1) {
if (curRealDiffPrice > minMigrateDiffPrice && runningInfo.Accounts[bidOrder.Index].CurStocks - runningInfo.Accounts[askOrder.Index].CurStocks > maxAmountDeviation) {
buySellAmount = math.min(
bidOrder.Amount,
askOrder.Amount,
maxTakerAmount,
runningInfo.Accounts[bidOrder.Index].CurStocks,
runningInfo.Accounts[askOrder.Index].CurBalance / askOrder.Price,
runningInfo.Accounts[bidOrder.Index].CurStocks - ((runningInfo.Accounts[bidOrder.Index].CurStocks + runningInfo.Accounts[askOrder.Index].CurStocks) / 2)
);
if (buySellAmount >= minTakerAmount) {
Log("Start exchange balancing!");
}
}
} else if (migrateCoinEx == askOrder.Index) {
if (curRealDiffPrice > minMigrateDiffPrice && runningInfo.Accounts[bidOrder.Index].CurStocks > 0) {
buySellAmount = math.min(
bidOrder.Amount,
askOrder.Amount,
maxTakerAmount,
runningInfo.Accounts[bidOrder.Index].CurStocks,
runningInfo.Accounts[askOrder.Index].CurBalance / askOrder.Price
);
if (buySellAmount >= minTakerAmount) {
Log("Initiate currency migration:", exchanges[bidOrder.Index].GetName(), "-->", exchanges[askOrder.Index].GetName());
}
}
}
}
var buyWait = buyExchange.Go("Buy", _N(askOrder.Price * (1.01), pricePrecision), buySellAmount);
var sellWait = sellExchange.Go("Sell", _N(bidOrder.Price * (0.99), pricePrecision), buySellAmount);
var startWaitTime = new Date().getTime()
Sleep(3000);
var buyOrder = buyWait.wait()
var sellOrder = sellWait.wait()
https://www.fmz.com/robot/464965
마지막으로, 라오키우 양적 교환 의사 소통에 참여하는 것을 환영합니다.https://t.me/laoqiu_arbitrage