bmino / binance-triangle-arbitrage

Detect in-market cryptocurrency arbitrage
MIT License
1.07k stars 336 forks source link

Calculation #90

Closed pichha closed 4 years ago

pichha commented 4 years ago

i've tested your arbi bot out, it seems all good but the calculations are off a bit. i will attach screenshot 2020-03-07 19_47_57-root@arbitrage1_ ~_binance-triangle-arbitrage

Its says that it has to make 0.4753% profit on the investment. As you can see i've investment 0.00499408 BTC and i made 0.00495731 BTC, that is -0,73628% not 0,4753% as it calculated.

I have a server in Japan and the ms should be okay. Is it possible that market execution is not the right mode to use, what about limits? Have you think about that?

My settings are default,

Maybe i am doing something wrong?

bmino commented 4 years ago

Thanks for the interest!

I would recommend you run the bot with LOG.LEVEL of "debug" to better understand what happened. fyi the next release will set this log level as the default. This mode would have shown the expected calculation vs. the actual execution step by step.

I definitely recommend having a server with as low latency to the binance exchange as possible. In the example you showed, the total execution took 599 ms which is quite long. The market likely drifted by the time the final trade was executed.

I have had a few conversations about limit orders vs market orders and believe market orders are the best for this use case. That's a lengthy topic, however.

pichha commented 4 years ago

Okay, will do that and send you the log..

what would you suggest about decreasing ms? i have a vps with a good location, what more can i do?

Thank you for reply

pichha commented 4 years ago

["3/8/2020, 3:43:41 AM"] ^[[32mINFO ^[[39m: ^[[36m--------------------------------------^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mAttempting to execute BTC-WRX-BNB with an age of 180 ms and expected profit of 0.3764%^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mBuying 689 WRXBTC @ market price^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mSuccessfully bought 689.00000000 WRXBTC @ a quote of 0.01497886 in 39 ms^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mSelling 689 WRXBNB @ market price^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mSuccessfully sold 689.00000000 WRXBNB @ a quote of 6.65841000 in 24 ms^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mSelling 6.65 BNBBTC @ market price^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mSuccessfully sold 6.65000000 BNBBTC @ a quote of 0.01486093 in 74 ms^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mExecuted BTC-WRX-BNB position in 143 ms^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mWRXBTC Stats:^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mExpected Conversion: 0.01499264 BTC into 689.00000000 WRX^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mObserved Conversion: 0.01497886 BTC into 689.00000000 WRX^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mPrice Error: -0.09191176%^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mWRXBNB Stats:^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mBC Expected Conversion: 689.00000000 WRX into 6.75220000 BNB^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mBC Observed Conversion: 689.00000000 WRX into 6.65841000 BNB^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mBC Price Error: 1.40859454%^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mBNBBTC Stats:^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mExpected Conversion: 6.75000000 BNB into 0.01508506 BTC^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mObserved Conversion: 6.65000000 BNB into 0.01486093 BTC^[[39m ["3/8/2020, 5:40:27 AM"] ^[[34mDEBUG^[[39m: ^[[36mPrice Error: 0.00436456%^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mBTC delta: -0.00011793 (-0.7873%)^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mWRX delta: 0.00000000 ( 0.0000%)^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mBNB delta: 0.00841000 ( 0.1265%)^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m: ^[[36mBNB commission: -0.01503617^[[39m ["3/8/2020, 5:40:27 AM"] ^[[32mINFO ^[[39m:

another transaction that didn't end with positive % gain

bmino commented 4 years ago

Looks like the initial data was 180 ms old. That's important because the first trade (WRXBTC) experienced a market drift.

180 ms might seem small, but keep in mind that in the arbitrage world milliseconds are critical. You and I are competing vs. people with better hardware and better connections working with < 5ms latency.