Get the official exchange rate of the SBS
Project description
sbsTC
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2117328cc723e3f5186905349cbd79ee8bf4a2dd4671b57c49386f53d490c9c
|
|
| MD5 |
96ae95a5894508b8b82c23bfc8a4c0ac
|
|
| BLAKE2b-256 |
97778d91b6ee4c58b8c53f345f0c08d127edbd7ce164ecca836e0d587df74d8c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8077165c77a64b1147ae72fa2163b47b959c89c40499fb9ebd77012c944b91c7
|
|
| MD5 |
e5ab5a793a7ab3dbe0c07213b6ed3bf3
|
|
| BLAKE2b-256 |
22f7600ad6c7d28c97cbe68bd4d01253ef6ef4877ed453e3434bfa2e05b5f4e2
|