fix importing from Bitcoin.de via API, storing the fees and amounts in the new way
This commit is contained in:
@@ -18,7 +18,7 @@ class ImportBtcDe:
|
|||||||
break
|
break
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
|
|
||||||
# TODO: check if this trade_id does not exist in the database for this user
|
# check if this trade_id does not exist in the database for this user
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
sql = """SELECT trade_id FROM `transaction` WHERE trade_id=%s and owner_id=%s"""
|
sql = """SELECT trade_id FROM `transaction` WHERE trade_id=%s and owner_id=%s"""
|
||||||
cursor.execute(sql, [trade['trade_id'], Owner.id])
|
cursor.execute(sql, [trade['trade_id'], Owner.id])
|
||||||
@@ -37,14 +37,14 @@ class ImportBtcDe:
|
|||||||
if trade['trading_pair'].upper().endswith(f):
|
if trade['trading_pair'].upper().endswith(f):
|
||||||
t.fiat_currency = f
|
t.fiat_currency = f
|
||||||
t.owner = Owner
|
t.owner = Owner
|
||||||
t.amount_before_fee = Decimal(trade['amount'])
|
t.crypto_amount = Decimal(trade['amount'])
|
||||||
t.amount_after_fee = Decimal(trade['amount']) - Decimal(trade['fee_currency'])
|
t.crypto_fee = Decimal(trade['fee_currency'])
|
||||||
t.amount = Decimal(trade['volume'])
|
t.fiat_amount = Decimal(trade['volume'])
|
||||||
|
t.fiat_fee = Decimal(trade['fee_eur'])
|
||||||
if trade['type'] == 'sell':
|
if trade['type'] == 'sell':
|
||||||
t.amount -= Decimal(trade['fee_eur'])
|
t.transaction_type = 'S'
|
||||||
t.amount_before_fee *= -1
|
else:
|
||||||
t.amount_after_fee *= -1
|
t.transaction_type = 'B'
|
||||||
t.amount *= -1
|
|
||||||
t.exchange_rate = trade['price']
|
t.exchange_rate = trade['price']
|
||||||
t.date_valid = trade['created_at']
|
t.date_valid = trade['created_at']
|
||||||
t.save()
|
t.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user