provinzio / CoinTaxman

Calculate your taxes from cryptocurrency gains
GNU Affero General Public License v3.0
142 stars 31 forks source link

Divide by zero exception #149

Closed g4m3r0 closed 9 months ago

g4m3r0 commented 1 year ago

I've encountered a divide by zero exception in src/book.py (Line 1676) which appears to happen when the price could not be retrieved.

In my fork I just set the buy_op.buying_cost to 1 as hotfix (see https://github.com/g4m3r0/CoinTaxman/commit/612a6764f59909915f3337cbecb53b3e83169fb8#diff-484c46f73c8e2db2113b8975f07e98907bdc9ccd12e7f8dd47b4a53ed1eb8d26L1676).

# Divide by zero hotfix (seems to happen when the price could not be retrieved)
if (buy_op.buying_cost == 0):
   buy_op.buying_cost = 1
provinzio commented 1 year ago

I think that we shouldn't silently assume the price if it couldn't been retrieved. A warning might be in order.

But eventhough, just guessing the price seems like a bad idea.