Skip to content

Python library to work with AZN (Azerbaijani manat) official rates based on CBAR (The Central Bank of the Republic of Azerbaijan)

License

Notifications You must be signed in to change notification settings

TahirJalilov/cbar-rates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CBAR Rates

PyPI - Version PyPI - Python Version PyPI - Downloads License

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
  • requests library

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,
        },
    }
}

You can find all available currency codes on the CBAR website

License

This project is licensed under the MIT License.

About

Python library to work with AZN (Azerbaijani manat) official rates based on CBAR (The Central Bank of the Republic of Azerbaijan)

Topics

Resources

License

Stars

Watchers

Forks

Languages