Closed tiagosiebler closed 6 years ago
Document is prepared here before insert: https://github.com/tiagosiebler/TriangularArbitrage/blob/master/lib/CurrencyCore.js#L130
So in binance, assuming we’re trading with the BTC silo, the tickers follow the xxxBTC format. So for example BNBBTC means you can buy bnb with btc, or sell bnb for btc.
However, by default I’m reading in the opposite format and only switching when no match is found:
var currency = stream.obj[fromCur + toCur];
if(currency){
currency.flipped = false;
currency.rate = currency.a;
// BTCBNB
}else{
currency = stream.obj[toCur + fromCur];
if(!currency){
return false;
}
currency.flipped = true;
currency.rate = (1/currency.b);
// BNBBTC
}
Most of the time it won’t find it the first time, but on some occasions it’s something like BTCBNB where both currencies are tradeable silos, therefore the BNB silo does have a ticker to buy BTC using BNB and will match first.
That’s when this inconsistency is coming from. It doesn’t affect all rows, but it does affect any that involve a transition across one of the main silos.
Example object:
internal stepFrom mismatches external a_step_from, why?