wardbradt / peregrine

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

Loss route suggested #55

Closed parthi2929 closed 3 years ago

parthi2929 commented 5 years ago

Hi

Often I also observe, the route ends up in loss as below. How to avoid that?

Code:

import asyncio
from peregrinearb import load_exchange_graph, print_profit_opportunity_for_path, bellman_ford

loop = asyncio.get_event_loop()
graph = loop.run_until_complete(load_exchange_graph('bitfinex', fees=True))
paths = bellman_ford(graph, 'BTC', unique_paths=True)
for path in paths:
    print_profit_opportunity_for_path(graph, path)

Output:
image

wardbradt commented 3 years ago

This is due to imprecision in floating point operations and the problems it causes are not severe enough to warrant e.g. using a different arithmetic implementation.