Add some comments to Transactions

This commit is contained in:
Mark Veidemanis 2021-12-29 15:32:38 +00:00
parent 4ff6875638
commit 6418c5ecca
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 7 additions and 0 deletions

View File

@ -78,10 +78,12 @@ class Transactions(object):
self.irc.client.msg( self.irc.client.msg(
self.irc.client.channel, f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}" self.irc.client.channel, f"AUTO Incoming transaction: {amount}{currency} ({reference}) - {state} - {description}"
) )
# Try getting the trade by the reference ID given
stored_trade = self.get_ref(reference) stored_trade = self.get_ref(reference)
if not stored_trade: if not stored_trade:
self.log.info(f"No reference in DB for {reference}") self.log.info(f"No reference in DB for {reference}")
self.irc.client.msg(self.irc.client.channel, f"No reference in DB for {reference}") self.irc.client.msg(self.irc.client.channel, f"No reference in DB for {reference}")
# Try getting the trade by the reference, using it as a TXID
ref2 = self.tx_to_ref(reference) ref2 = self.tx_to_ref(reference)
if not ref2: if not ref2:
self.log.info("No TXID in DB for {reference}") self.log.info("No TXID in DB for {reference}")
@ -92,9 +94,13 @@ class Transactions(object):
amount = float(amount) amount = float(amount)
stored_trade["amount"] = float(stored_trade["amount"]) stored_trade["amount"] = float(stored_trade["amount"])
# Make sure it was sent in the expected currency
if not stored_trade["currency"] == currency: if not stored_trade["currency"] == currency:
self.irc.client.msg(self.irc.client.channel, f"Currency mismatch, Agora: {stored_trade['currency']} / Revolut: {currency}") self.irc.client.msg(self.irc.client.channel, f"Currency mismatch, Agora: {stored_trade['currency']} / Revolut: {currency}")
return return
# Make sure the expected amount was sent
if not stored_trade["amount"] == amount: if not stored_trade["amount"] == amount:
# If the amount does not match exactly, get the min and max values for our given acceptable margins for trades # If the amount does not match exactly, get the min and max values for our given acceptable margins for trades
min_amount, max_amount = self.agora.get_acceptable_margins(currency, amount) min_amount, max_amount = self.agora.get_acceptable_margins(currency, amount)
@ -107,6 +113,7 @@ class Transactions(object):
f"Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}", f"Amount mismatch - not in margins: {stored_trade['amount']} (min: {min_amount} / max: {max_amount}",
) )
return return
# Make sure the account type was Revolut, as these are completed instantly
if not account_type == "revolut": if not account_type == "revolut":
self.irc.client.msg(self.irc.client.channel, f"Account type is not Revolut: {account_type}") self.irc.client.msg(self.irc.client.channel, f"Account type is not Revolut: {account_type}")
return return