bmino / binance-triangle-arbitrage

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

Improper Prices Displayed in Post Calculation Report #117

Closed bmino closed 3 years ago

bmino commented 3 years ago
["10/19/2020, 2:29:34 PM"] INFO : Attempting to execute BTC-DASH-ETH with an age of 68 ms and expected profit of 0.0727%
["10/19/2020, 2:29:34 PM"] INFO : Buying 5.725 DASHBTC @ market price
["10/19/2020, 2:29:34 PM"] INFO : Successfully bought 5.72500000 DASHBTC @ a quote of 0.03417825 in 44 ms
["10/19/2020, 2:29:34 PM"] INFO : Selling 5.725 DASHETH @ market price
["10/19/2020, 2:29:34 PM"] INFO : Successfully sold 5.72500000 DASHETH @ a quote of 1.04212175 in 23 ms
["10/19/2020, 2:29:34 PM"] INFO : Selling 1.042 ETHBTC @ market price
["10/19/2020, 2:29:34 PM"] INFO : Successfully sold 1.04200000 ETHBTC @ a quote of 0.03399837 in 23 ms
["10/19/2020, 2:29:34 PM"] INFO : Executed BTC-DASH-ETH position in 97 ms
["10/19/2020, 2:29:34 PM"] DEBUG: DASHBTC Stats:
["10/19/2020, 2:29:34 PM"] DEBUG: Expected Conversion: 0.03399505 BTC into 5.72500000 DASH @ 0.00593800
["10/19/2020, 2:29:34 PM"] DEBUG: Observed Conversion: 0.03417825 BTC into 5.72500000 DASH @ 0.00597000
["10/19/2020, 2:29:34 PM"] DEBUG: Conversion Error: 0.53890199%
["10/19/2020, 2:29:34 PM"] DEBUG:
["10/19/2020, 2:29:34 PM"] DEBUG: DASHETH Stats:
["10/19/2020, 2:29:34 PM"] DEBUG: Expected Conversion: 5.72500000 DASH into 1.04504150 ETH @ 5.47825134
["10/19/2020, 2:29:34 PM"] DEBUG: Observed Conversion: 5.72500000 DASH into 1.04212175 ETH @ 5.49359996
["10/19/2020, 2:29:34 PM"] DEBUG: Conversion Error: 0.28017360%
["10/19/2020, 2:29:34 PM"] DEBUG:
["10/19/2020, 2:29:34 PM"] DEBUG: ETHBTC Stats:
["10/19/2020, 2:29:34 PM"] DEBUG: Expected Conversion: 1.04500000 ETH into 0.03409626 BTC @ 30.64852274
["10/19/2020, 2:29:34 PM"] DEBUG: Observed Conversion: 1.04200000 ETH into 0.03399837 BTC @ 30.64852815
["10/19/2020, 2:29:34 PM"] DEBUG: Conversion Error: 0.00001765%
["10/19/2020, 2:29:34 PM"] INFO :
["10/19/2020, 2:29:34 PM"] INFO : BTC delta: -0.00017988 (-0.5263%)
["10/19/2020, 2:29:34 PM"] INFO : DASH delta: 0.00000000 ( 0.0000%)
["10/19/2020, 2:29:34 PM"] INFO : ETH delta: 0.00012175 ( 0.0117%)
["10/19/2020, 2:29:34 PM"] INFO : BNB fees: -0.02931882
["10/19/2020, 2:29:34 PM"] INFO :

The price of BC and CA is incorrect: 5.47825134 should be 0.18254 30.64852274 should be 0.032628

This doesn't reflect improper calculations, just bad logging

dlasher commented 3 years ago

Got another one for you, is this still cosmetic, or did it really lose half a percent in 77ms?

["10/25/2020, 5:45:29 AM"] INFO : Attempting to execute BTC-EOS-ETH with an age of 89 ms and expected profit of 0.2854%`
["10/25/2020, 5:45:29 AM"] INFO : Buying 143.06 EOSBTC @ market price
["10/25/2020, 5:45:29 AM"] INFO : Successfully bought 143.06000000 EOSBTC @ a quote of 0.02929868 in 29 ms
["10/25/2020, 5:45:29 AM"] INFO : Selling 143.06 EOSETH @ market price
["10/25/2020, 5:45:29 AM"] INFO : Successfully sold 143.06000000 EOSETH @ a quote of 0.91930356 in 22 ms
["10/25/2020, 5:45:29 AM"] INFO : Selling 0.919 ETHBTC @ market price
["10/25/2020, 5:45:29 AM"] INFO : Successfully sold 0.91900000 ETHBTC @ a quote of 0.02909921 in 19 ms
["10/25/2020, 5:45:29 AM"] INFO : Executed BTC-EOS-ETH position in 77 ms
["10/25/2020, 5:45:29 AM"] DEBUG: EOSBTC Stats:
["10/25/2020, 5:45:29 AM"] DEBUG: Expected Conversion:  0.02899826 BTC into 143.06000000 EOS @ 0.00020270
["10/25/2020, 5:45:29 AM"] DEBUG: Observed Conversion:  0.02929868 BTC into 143.06000000 EOS @ 0.00020480
["10/25/2020, 5:45:29 AM"] DEBUG: Price Change:         1.03598623%
["10/25/2020, 5:45:29 AM"] DEBUG:
["10/25/2020, 5:45:29 AM"] DEBUG: EOSETH Stats:
["10/25/2020, 5:45:29 AM"] DEBUG: Expected Conversion:  143.06000000 EOS into 0.91901744 ETH @ 155.66625156
["10/25/2020, 5:45:29 AM"] DEBUG: Observed Conversion:  143.06000000 EOS into 0.91930356 ETH @ 155.61780268
["10/25/2020, 5:45:29 AM"] DEBUG: Price Change:         -0.03112356%
["10/25/2020, 5:45:29 AM"] DEBUG:
["10/25/2020, 5:45:29 AM"] DEBUG: ETHBTC Stats:
["10/25/2020, 5:45:29 AM"] DEBUG: Expected Conversion:  0.91900000 ETH into 0.02914628 BTC @ 31.53061475
["10/25/2020, 5:45:29 AM"] DEBUG: Observed Conversion:  0.91900000 ETH into 0.02909921 BTC @ 31.58161338
["10/25/2020, 5:45:29 AM"] DEBUG: Price Change:         0.16174322%
["10/25/2020, 5:45:29 AM"] INFO :
["10/25/2020, 5:45:29 AM"] INFO : BTC delta:      -0.00019947 (-0.6808%)
["10/25/2020, 5:45:29 AM"] INFO : EOS delta:       0.00000000 ( 0.0000%)
["10/25/2020, 5:45:29 AM"] INFO : ETH delta:       0.00030356 ( 0.0330%)
["10/25/2020, 5:45:29 AM"] INFO : BNB fees:       -0.02783064
bmino commented 3 years ago

The percentage gain/loss has always been accurate.

Unfortunately this trade had an age of 89 ms from existence to the beginning of execution which is huge. The execution portion then took a total of 77 ms. However, the trade execution times themselves look decent from what I've seen ~ 20ms per leg.

The price logging ie "ETH @ 155.66625156" looks to be incorrect. Are you running v6.0.1?

I would also highly recommend running with trace level logging to see the depth cache used for calculations. This often explains exactly what happened between detection and execution

dlasher commented 3 years ago

yes, I'm running 6.0.1 - I think I have the trace level up high. Here's another one:

["10/27/2020, 12:22:35 PM"] INFO : Attempting to execute BTC-NANO-ETH with an age of 84 ms and expected profit of 0.9942%
["10/27/2020, 12:22:35 PM"] INFO : Buying 115.7 NANOBTC @ market price
["10/27/2020, 12:22:35 PM"] INFO : Successfully bought 115.70000000 NANOBTC @ a quote of 0.00711239 in 33 ms
["10/27/2020, 12:22:35 PM"] INFO : Selling 115.7 NANOETH @ market price
["10/27/2020, 12:22:35 PM"] INFO : Successfully sold 115.70000000 NANOETH @ a quote of 0.23487100 in 22 ms
["10/27/2020, 12:22:35 PM"] INFO : Selling 0.234 ETHBTC @ market price
["10/27/2020, 12:22:35 PM"] INFO : Successfully sold 0.23400000 ETHBTC @ a quote of 0.00702514 in 21 ms
["10/27/2020, 12:22:35 PM"] INFO : Executed BTC-NANO-ETH position in 82 ms
["10/27/2020, 12:22:35 PM"] DEBUG: NANOBTC Stats:
["10/27/2020, 12:22:35 PM"] DEBUG: Expected Conversion:  0.00699985 BTC into 115.70000000 NANO @ 0.00006050
["10/27/2020, 12:22:35 PM"] DEBUG: Observed Conversion:  0.00711239 BTC into 115.70000000 NANO @ 0.00006147
["10/27/2020, 12:22:35 PM"] DEBUG: Price Change:         1.60774874%
["10/27/2020, 12:22:35 PM"] DEBUG:
["10/27/2020, 12:22:35 PM"] DEBUG: NANOETH Stats:
["10/27/2020, 12:22:35 PM"] DEBUG: Expected Conversion:  115.70000000 NANO into 0.23602800 ETH @ 0.00204000
["10/27/2020, 12:22:35 PM"] DEBUG: Observed Conversion:  115.70000000 NANO into 0.23487100 ETH @ 0.00203000
["10/27/2020, 12:22:35 PM"] DEBUG: Price Change:         -0.49019608%
["10/27/2020, 12:22:35 PM"] DEBUG:
["10/27/2020, 12:22:35 PM"] DEBUG: ETHBTC Stats:
["10/27/2020, 12:22:35 PM"] DEBUG: Expected Conversion:  0.23600000 ETH into 0.00708519 BTC @ 0.03002200
["10/27/2020, 12:22:35 PM"] DEBUG: Observed Conversion:  0.23400000 ETH into 0.00702514 BTC @ 0.03002197
["10/27/2020, 12:22:35 PM"] DEBUG: Price Change:         -0.00011388%
["10/27/2020, 12:22:35 PM"] INFO :
["10/27/2020, 12:22:35 PM"] INFO : BTC delta:     -0.00008725 (-1.2267%)
["10/27/2020, 12:22:35 PM"] INFO : NANO delta:     0.00000000 ( 0.0000%)
["10/27/2020, 12:22:35 PM"] INFO : ETH delta:      0.00087100 ( 0.3722%)
["10/27/2020, 12:22:35 PM"] INFO : BNB fees:      -0.00681735
["10/27/2020, 12:22:35 PM"] INFO :
bmino commented 3 years ago

Yeah those prices are logged correctly ie:

NANOBTC ~ 0.00006 NANOETH ~ 0.002 ETHBTC ~ 0.03

bmino commented 3 years ago

In that example as well, your age is 84. This is then followed by another 82 ms to execute the position. Realistically this is too much.

You can lower that initial age by setting your timeout to 0 and lowering the threshold to something much lower. The trade times however are the biggest hurdle at the moment