Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

ValueError: math domain error #71

Closed
reall0c opened this issue Dec 3, 2020 · 2 comments
Closed

ValueError: math domain error #71

reall0c opened this issue Dec 3, 2020 · 2 comments

Comments

@reall0c
Copy link

reall0c commented Dec 3, 2020

Hi,
when do
`from peregrinearb import create_weighted_multi_exchange_digraph, bellman_ford_multi, print_profit_opportunity_for_path_multi

graph = create_weighted_multi_exchange_digraph(['hitbtc','exmo','bitfinex','poloniex','kraken', 'bittrex', 'binance'], log=True)
graph, paths = bellman_ford_multi(graph, 'BTC', unique_paths=True)
for path in paths:
print_profit_opportunity_for_path_multi(graph, path)`

its appear 6 times
Task exception was never retrieved future: <Task finished coro=<_add_market_to_multi_digraph() done, defined at /h/z/Documents/Arbitrage program/peregrine/peregrinearb/utils/multi_exchange.py:98> exception=ValueError('math domain error')> Traceback (most recent call last): File "/home/tech/Documents/Arbitrage program/peregrine/peregrinearb/utils/multi_exchange.py", line 135, in _add_market_to_multi_digraph weight=-math.log(fee_scalar*ticker_bid)) ValueError: math domain error
and finish with this:
Starting with 100 in BTC BTC to MEME at 3990000.000000001 = 399000000.0000001 on bittrex for MEME/BTC MEME to USDT at 195.37864091391904 = 77956077724.65372 on poloniex for MEME/USDT USDT to STX at 127.95389048991358 = 9974783432203.533 on hitbtc for STX/USDT STX to BNB at 0.008031959999999998 = 80117061536.12148 on binance for STX/BNB BNB to COCOS at 100909.09090909087 = 8084539845917709.0 on binance for COCOS/BNB COCOS to BTC at 1.6413570000000026e-08 = 132696160.67875974 on hitbtc for COCOS/BTC
Could you tell me why throw error with math domain error ?
Thanks

@edouardkombo
Copy link

Instead of math.log, use math.log1p.
It returns the natural logarithm of 1+x (base e). The result is calculated in a way which is accurate for x near zero.

I created a fork of the project and am updating it.

@edouardkombo
Copy link

@quantk a fix has been added here #77

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants