From 5db3c5850561c9e6337805837209d4a9c275e1f0 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Fri, 8 Jan 2021 07:13:00 +0100 Subject: [PATCH] fix an issue with BCH, because we bought for 0 Euro when it was split from BTC --- apps/monitor/calc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/monitor/calc.py b/apps/monitor/calc.py index 54f1194..80a2124 100644 --- a/apps/monitor/calc.py +++ b/apps/monitor/calc.py @@ -25,10 +25,10 @@ class Calc: out["crypto"] = crypto with connection.cursor() as cursor: - sql = """SELECT SUM(amount_after_fee) as after_fee, SUM(amount) as amount FROM `transaction` WHERE amount >= 0 and crypto_currency=%s and owner_id=%s""" + sql = """SELECT SUM(amount_after_fee) as after_fee, SUM(amount) as amount FROM `transaction` WHERE amount_after_fee > 0 and crypto_currency=%s and owner_id=%s""" cursor.execute(sql, [crypto, userid]) bought = cursor.fetchone() - if bought[1]: + if bought[0]: out["bought"] = bought[1] total_investment += Decimal(bought[1]) amount_kept += Decimal(bought[0]) @@ -36,10 +36,10 @@ class Calc: out["bought"] = None with connection.cursor() as cursor: - sql = """SELECT SUM(amount_before_fee) as before_fee, SUM(amount) as amount FROM `transaction` WHERE amount < 0 and crypto_currency=%s and owner_id=%s""" + sql = """SELECT SUM(amount_before_fee) as before_fee, SUM(amount) as amount FROM `transaction` WHERE amount_before_fee < 0 and crypto_currency=%s and owner_id=%s""" cursor.execute(sql, [crypto, userid]) sold = cursor.fetchone() - if sold[1]: + if sold[0]: out["sold"] = sold[1] total_investment += Decimal(sold[1]) amount_kept += Decimal(sold[0])