wardbradt / peregrine

Detects arbitrage opportunities across 131 cryptocurrency exchanges in 50 countries
MIT License
1.18k stars 339 forks source link

limit to a triangle #40

Closed jackyflyer closed 5 years ago

jackyflyer commented 5 years ago

Hello, multiple_coins_one_exchange.py is working fine on my config, not the other examples. In multiple_coins_one_exchange.py, I would like to limit the arb path to a triangle (3 transactions). I am new to graph theory and a small help would be great. I guess it would be somewhere in NegativeWeightFinder::bellman_ford but then I'm getting lost. Thank you

wardbradt commented 5 years ago

I am not sure if there is an "efficient" way to do this. The easiest solution is, given a list x by bellman_ford, check if len(x) == 4. Unless something goes wrong in an exchange's matching engine, it will never be < 4 (4 indicates 3 transactions).