Skip to main content

Get Exchange Rate Between Different Currencies

Project description

Get-Exchange-Rate-Programatically

Gives currencies upto the previous day

Installing using pip

pip install curr_get_exchange==1.0.0

Using it in your Python Code

from curr_get_exchange import get_exchange

''' METHOD 1 '''
history_check = get_exchange.beginCheck(from_date="2021-01-01", to_date=False, from_currency='EUR', to_currency='KES')
history = history_check.gotten_currency
print(history) #Returns a dictionary

Output{'2021-02-25': {'value': 133.4787, 'details': ['Thursday', '2021-02-25', '1 EUR =133.4787 KES']}, '2021-02-24': {'value': 133.6242, 'details': ['Wednesday', '2021-02-24', '1 EUR =133.6242 KES']}, '2021-02-23': {'value': 133.2971, 'details': ['Tuesday', '2021-02-23', '1 EUR =133.2971 KES']}, '2021-02-22': {'value': 133.3624, 'details': ['Monday', '2021-02-22', '1 EUR =133.3624 KES']}, '2021-02-21': {'value': 133.1358, 'details': ['Sunday', '2021-02-21', '1 EUR =133.1358 KES']}}

yesterday_exchange = history[history_check.correctKey('2021-02-25')] #correctKey formarts dd-mm-yyyy or yyyy-mm-dd to required key /Use any formart
yersterday_value = yesterday_exchange['value']
yersterday_details = yesterday_exchange['details']

print(yesterday_exchange)
print("Values>> ", yersterday_value)
print("Details>> ", yersterday_details)

Output
{'value': 133.4787, 'details': ['Thursday', '2021-02-25', '1 EUR =133.4787 KES']}
Values: 133.4787
Details: ['Thursday', '2021-02-25', '1 EUR =133.4787 KES']

''' METHOD 2 '''
history_checktWO = get_exchange.beginCheck(from_currency='EUR', to_currency='USD') #correctKey formarts dd-mm-yyyy or yyyy-mm-dd to required key /Use any formart
usdValue = history_checktWO.gotten_currency[history_checktWO.correctKey('2021-02-05')]['value']
print("USD value: %s"%(usdValue))

Output {'value': 133.4787, 'details': ['Thursday', '2021-02-25', '1 EUR =133.4787 KES']}
Values: 133.4787
Details: ['Thursday', '2021-02-25', '1 EUR =133.4787 KES']
USD value: 1.2048

OTHER IMPORTANT METHODS

''' OTHER METHODS '''
check = get_exchange.beginCheck()
#Reformarts date to how keys in dictioray are passed, use these and you won't find errors with your date
print(check.correctKey('1-1-2020'),' | ', check.correctKey('01-01-2020'),' | ', check.correctKey('2020-01-01'))
a = check.returnDateSysFormart('01-02-2021')
print("retrun date in system formart: ", a)
b = check.returnDateHumanFormart(a)
print("return date string in human formart: ", b)
c = check.returnDateString(b)
print("return date (string) in system formart: ", c)
f = {'eur': 5, 'kes': 6, "usd": 7}
print("\nDictionary %s returns keys to list: %s"%(f, check.keysToList(f)))

Output 2020-01-01 | 2020-01-01 | 2020-01-01
retrun date in system formart: 2021-02-01 00:00:00
return date string in human formart: 01-02-2021
return date (string) in system formart: 2021-02-01
Dictionary {'eur': 5, 'kes': 6, 'usd': 7} returns keys to list: ['eur', 'kes', 'usd']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curr_get_exchange-1.0.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

curr_get_exchange-1.0.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file curr_get_exchange-1.0.0.tar.gz.

File metadata

  • Download URL: curr_get_exchange-1.0.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.3rc1

File hashes

Hashes for curr_get_exchange-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b014e341e4e3d3549072e1aaf1c7a5db94c378adcc2a8d2a6698160d35e22e25
MD5 2ea26341b3bae8a232b0f3c912534e69
BLAKE2b-256 53b5dda25999b6fcd6d212f8cc20929e14b420e8f58b3e468e4e24f38ca33327

See more details on using hashes here.

File details

Details for the file curr_get_exchange-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: curr_get_exchange-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.3rc1

File hashes

Hashes for curr_get_exchange-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1a69860519b8f044058623c8bf128b9b0312dbf081956cb9ce339c45d06c4fc
MD5 ce8c3a468128f70e09230629ce8c89ae
BLAKE2b-256 f5e9fe4dcd87f75bf9985ae33750c679c625e97470c611c81e2865bd0f776f38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page