Skip to content

Commit 55a0ad2

Browse files
authored
the exchanes api endpoint has a code=[base] to convert to another coin (#43)
retrieved from https://github.com/decred/dcrdata#endpoint-list
1 parent 9c0e0eb commit 55a0ad2

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

utils/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ def build_menu(buttons,
1414

1515

1616
def convert_dcr(dcr_amount: float, target_currency: str):
17-
endpoint = "exchanges"
18-
dcr_to_usd_value = request_dcr_data(endpoint)
19-
dcr_to_usd_value = dcr_to_usd_value.get("price")
17+
endpoint = f"exchanges?code={target_currency}"
18+
dcr_to_target_value = request_dcr_data(endpoint)
19+
dcr_to_target_value = dcr_to_target_value.get("price")
2020

21-
if target_currency == 'USD':
22-
return dcr_amount * dcr_to_usd_value
21+
return dcr_amount * dcr_to_target_value

0 commit comments

Comments
 (0)