Implement looking up trade by partial reference message or amount/currency #1

Closed
m wants to merge 2 commits from feature/alternate-reference-check into master
Owner

Implement looking up a transaction's details by:

  • partial reference: "Sent from Revolut XMR-SKKDS" will check each word as "Sent, "from", "Revolut", "XMR-SKKDS" until a value matches an existing reference.
  • amount/currency matching if the amount does not exceed the acceptable limit (currently 100USD)
    Checks for partial reference:
  • if more than one match for reference, abort

Checks for amount/currency lookup:

  • if more than one match with the same amount and currency is found, abort
  • if we cannot find one, abort
  • amount is converted with forex_python by amount / rates[currency], please check logic:
>>> amount
1000
>>> currency
'SEK'
>>> amount / rates[currency]
110.49432699530747
  • if currency is USD, amount_usd = amount
  • if the amount in USD exceeds allowable limit for reference-less lookup, abort
  • do not check acceptable margin (+- 1USD) if we have looked up by amount and currency

Tests:

  • right amount and currency with no reference
  • incorrect amount by less than 1USD with no reference
  • incorrect amount by less than 1USD with reference
  • exact amount with reference
  • incorrect amount by more than 1USD with reference
  • incorrect amount by more than 1USD with no reference
Implement looking up a transaction's details by: * partial reference: "Sent from Revolut XMR-SKKDS" will check each word as "Sent, "from", "Revolut", "XMR-SKKDS" until a value matches an existing reference. * amount/currency matching if the amount does not exceed the acceptable limit (currently 100USD) Checks for partial reference: * if more than one match for reference, abort Checks for amount/currency lookup: * if more than one match with the same amount and currency is found, abort * if we cannot find one, abort * amount is converted with forex_python by amount / rates[currency], please check logic: ``` >>> amount 1000 >>> currency 'SEK' >>> amount / rates[currency] 110.49432699530747 ``` * if currency is USD, amount_usd = amount * if the amount in USD exceeds allowable limit for reference-less lookup, abort * do not check acceptable margin (+- 1USD) if we have looked up by amount and currency Tests: * right amount and currency with no reference * incorrect amount by less than 1USD with no reference * incorrect amount by less than 1USD with reference * exact amount with reference * incorrect amount by more than 1USD with reference * incorrect amount by more than 1USD with no reference
m added 1 commit 2022-01-01 19:32:30 +00:00
m added 1 commit 2022-01-01 19:33:20 +00:00
m added 1 commit 2022-01-01 20:01:05 +00:00
Author
Owner

trade for 2SEK ref XXX

right amount and currency with no reference
2, SEK, XXX
Result:
DRY RUN releasing funds for a27fee4c-adc1-4cba-bfee-4cadc18cba25 / Sent from Revolut

incorrect amount by less than 1USD with no reference
3, SEK, Sent from Revolut
Result:
Failed to get reference by amount and currency: 61d0b74a-be0a-a5ed-9886-5f8369796ee8 SEK 5

incorrect amount by less than 1USD with reference
3, SEK, XXX
DRY RUN releasing funds for a27fee4c-adc1-4cba-bfee-4cadc18cba25 / XMR-ZUYBM

exact amount with reference
2, SEK, XXX
Result:
DRY RUN releasing funds for a27fee4c-adc1-4cba-bfee-4cadc18cba25 / XMR-ZUYBM

exact amount with wrong currency and reference
2, GBP, XXX
Currency mismatch, Agora: SEK / Revolut: GBP

exact amount with wrong currency and no reference
2, GBP, Sent from Revolut
Result:
Checking against amount and currency for TXID 61d0b78b-22d4-ab3f-9a08-34d9919c3ff0
Failed to get reference by amount and currency: 61d0b78b-22d4-ab3f-9a08-34d9919c3ff0 GBP 2

incorrect amount by more than 1USD with reference
20, SEK, XXX
Result:
Amount does not match exactly, trying with margins: min: 5.949761610453824 / max: 24.050238389546177
Amount mismatch - not in margins: 2.0 (min: 5.949761610453824 / max: 24.050238389546177

incorrect amount by more than 1USD with no reference
20, SEK, Sent from Revolut
Result:
Failed to get reference by amount and currency: 61d0b651-8768-a30a-b75b-67b1de14056c SEK 10

trade for 2SEK ref XXX right amount and currency with no reference 2, SEK, XXX Result: DRY RUN releasing funds for a27fee4c-adc1-4cba-bfee-4cadc18cba25 / Sent from Revolut incorrect amount by less than 1USD with no reference 3, SEK, Sent from Revolut Result: Failed to get reference by amount and currency: 61d0b74a-be0a-a5ed-9886-5f8369796ee8 SEK 5 incorrect amount by less than 1USD with reference 3, SEK, XXX DRY RUN releasing funds for a27fee4c-adc1-4cba-bfee-4cadc18cba25 / XMR-ZUYBM exact amount with reference 2, SEK, XXX Result: DRY RUN releasing funds for a27fee4c-adc1-4cba-bfee-4cadc18cba25 / XMR-ZUYBM exact amount with wrong currency and reference 2, GBP, XXX Currency mismatch, Agora: SEK / Revolut: GBP exact amount with wrong currency and no reference 2, GBP, Sent from Revolut Result: Checking against amount and currency for TXID 61d0b78b-22d4-ab3f-9a08-34d9919c3ff0 Failed to get reference by amount and currency: 61d0b78b-22d4-ab3f-9a08-34d9919c3ff0 GBP 2 incorrect amount by more than 1USD with reference 20, SEK, XXX Result: Amount does not match exactly, trying with margins: min: 5.949761610453824 / max: 24.050238389546177 Amount mismatch - not in margins: 2.0 (min: 5.949761610453824 / max: 24.050238389546177 incorrect amount by more than 1USD with no reference 20, SEK, Sent from Revolut Result: Failed to get reference by amount and currency: 61d0b651-8768-a30a-b75b-67b1de14056c SEK 10
m added 1 commit 2022-01-01 20:22:57 +00:00
m added 1 commit 2022-01-01 20:27:33 +00:00
m added 1 commit 2022-01-01 20:31:40 +00:00
m closed this pull request 2022-01-01 20:31:49 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: XF/pluto#1
No description provided.