Skip to main content

Get the official exchange rate of the SBS

Project description

sbsTC

Python 3.11 PyPI version

Description

Retrieves the official exchange rate for Peru within a specified date range from SBS. This library is written in Python 3.11

Installation

pip install sbsTC

Basic Code

from sbsTC import SbsTC

tc = SbsTC()
data = tc.get_exchange('USD','25/09/2023','30/09/2023')
print(data)

The following result is obtained:

{
    '25/09/2023': {'buy': '3.765', 'sell': '3.773'},
    '26/09/2023': {'buy': '3.779', 'sell': '3.787'},
    '27/09/2023': {'buy': '3.793', 'sell': '3.799'},
    '28/09/2023': {'buy': '3.801', 'sell': '3.806'},
    '29/09/2023': {'buy': '3.790', 'sell': '3.797'}
}

Settings

Option Description Default Allowed values
date_format Date format %d/%m/%Y http://strftime.org

Example

from sbsTC import SbsTC
tc = SbsTC(date_format='%Y-%m-%d')
data = tc.get_exchange('USD','25/09/2023')
print(data)

The following result is obtained:

{'2023-09-25': {'buy': '3.765', 'sell': '3.773'}}

If no information is found:

DataNotFound: No hay información disponible para el rango seleccionado

Currencies

Permitted currencies:

Currency Code
American dollar USD
Euro EUR
Japan Yen JPY
Canadian dollar CAD
Swedish Krona SEK
Swiss Franc CHF
British Pound GBP

Methods

get_exchange(currency,from_date,to_date=None)

Obtains the currency exchange rate for the provided currency based on a given date range. The result will be a dictionary of exchange rates. (https://docs.python.org/3/tutorial/datastructures.html#dictionaries).

Considerations

  • The information is available from the year 2000 onwards.
  • The obtained exchange rate is as of the previous day.

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

sbsTC-0.0.3.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

sbsTC-0.0.3-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file sbsTC-0.0.3.tar.gz.

File metadata

  • Download URL: sbsTC-0.0.3.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for sbsTC-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a2117328cc723e3f5186905349cbd79ee8bf4a2dd4671b57c49386f53d490c9c
MD5 96ae95a5894508b8b82c23bfc8a4c0ac
BLAKE2b-256 97778d91b6ee4c58b8c53f345f0c08d127edbd7ce164ecca836e0d587df74d8c

See more details on using hashes here.

File details

Details for the file sbsTC-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sbsTC-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for sbsTC-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8077165c77a64b1147ae72fa2163b47b959c89c40499fb9ebd77012c944b91c7
MD5 e5ab5a793a7ab3dbe0c07213b6ed3bf3
BLAKE2b-256 22f7600ad6c7d28c97cbe68bd4d01253ef6ef4877ed453e3434bfa2e05b5f4e2

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