Python library to work with AZN (Azerbaijani manat) official rates
Project description
CBAR Rates
A Python library to work with Azerbaijani manat (AZN) official exchange rates based on CBAR (The Central Bank of the Republic of Azerbaijan).
Features
- Retrieve official CBAR exchange rates for the Azerbaijani manat (AZN).
- Compare exchange rates between two dates and calculate differences.
- Filter results by specific currency codes (e.g., USD, EUR).
Requirements
- Python 3.7 or higher
requestslibrary
Installation
Install the library using pip:
pip install cbar-rates --upgrade
For isolated installations, use a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install cbar-rates
Examples
Usage of get_rates()
from datetime import date
import cbar
rates_date = date.today()
currencies = ["USD", "EUR"]
rates = cbar.get_rates(rates_date, currencies)
print(rates)
# Output:
{
"date": "18.11.2024",
"currencies": {
"USD": {
"nominal": "1",
"rate": 1.7
},
"EUR": {
"nominal": "1",
"rate": 1.7919
},
}
}
Usage of get_rates_with_diff()
from datetime import date
import cbar
previous_date = date(2024, 11, 25)
date_ = date(2024, 11, 26)
currencies = ["USD", "EUR"]
rates = cbar.get_rates_with_diff(previous_date, date_, currencies)
print(rates)
# Output:
{
"previous_date": "25.11.2024",
"date": "26.11.2024",
"currencies": {
"USD": {
"nominal": "1",
"previous_rate": 1.7,
"rate": 1.7,
"difference": 0.0,
},
"EUR": {
"nominal": "1",
"previous_rate": 1.7814,
"rate": 1.7815,
"difference": 0.0001,
},
}
}
Usage of convert()
from datetime import date
import cbar
amount = 100
from_currency = "USD"
to_currency = "AZN"
conversion_date = date(2024, 11, 25)
converted_amount = cbar.convert(amount, from_currency, to_currency, conversion_date)
print(converted_amount)
# Output:
170.0 # 1 USD = 1.7 AZN
You can find all available currency codes on the CBAR website
License
This project is licensed under the MIT License.
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 cbar_rates-1.3.0.tar.gz.
File metadata
- Download URL: cbar_rates-1.3.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bed8e1a88e421860d193764e66c86ccff4b337ffb32af58352cab1810c95c63
|
|
| MD5 |
f8de6ed1313a7e983a487c45953acef2
|
|
| BLAKE2b-256 |
9dec65580f1aa45547657e49bceab4c4a3a35f8ea8819a0c6f3248b75ca23e4e
|
File details
Details for the file cbar_rates-1.3.0-py3-none-any.whl.
File metadata
- Download URL: cbar_rates-1.3.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e9aacad6261c5f36db0935f6a6c3697106c471e66b3e548dd0b5569eab6227c
|
|
| MD5 |
2b31c010c2372df43adfe58be41aa82b
|
|
| BLAKE2b-256 |
bd30675d2c93b32ee478bd84e19318fc2fcbaa7258e03522f259ddda2ccc120c
|