Skip to main content

Comfortable work with currencies and currencies exchange rates

Project description

Pyrrencies Python Library

Overview

The pyrrencies library provides a convenient way to handle currency conversion and arithmetic operations in Python. It supports a wide range of currencies and allows for easy conversion between them.

Installation

pip install pyrrencies

Usage

Initialization

from pyrrencies import CurrencyAmount

amount_usd = CurrencyAmount(1000, 'USD')   # USD 10.0
amount_uah = CurrencyAmount(10000, 'UAH')  # UAH 100.0

Display

print(amount_usd)  # USD 10.0

Accessing Properties

print(amount_usd.cents)     # 1000
print(amount_usd.currency)  # USD

Currency Conversion

print(amount_usd.to('UAH'))  # UAH 367.44
print(amount_usd.to('EUR'))  # EUR 9.55

Exchange Rates

from pyrrencies import CurrencyRates

print(CurrencyRates.get_rate('USD', 'UAH'))  # 36.744452
print(CurrencyRates.get_rate('PLN', 'EUR'))  # 0.21633

Arithmetic Operations

print(amount_usd + 50)                    # USD 10.5
print(amount_usd + amount_uah)            # ValueError: Currencies must be the same
print(amount_usd + amount_uah.to('USD'))  # USD 12.72
print(amount_usd - amount_uah.to('USD'))  # USD 7.28
print(amount_usd * 7.34)                  # USD 73.4
print(amount_usd / 2)                     # USD 5.0

Comparison

print(amount_usd == amount_uah)  # False
print(amount_usd != amount_uah)  # True
print(amount_usd > amount_uah)   # ValueError: Currencies must be the same
print(amount_usd >= amount_uah)  # ValueError: Currencies must be the same
print(amount_usd < amount_uah)   # ValueError: Currencies must be the same
print(amount_usd <= amount_uah)  # ValueError: Currencies must be the same

Supported Currencies

AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTN, BWP, BYN, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, FOK, GBP, GEL, GGP, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD, IRR, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KID, KMF, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRU, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLE, SLL, SOS, SRD, SSP, STN, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TVD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VES, VND, VUV, WST, XAF, XCD, XDR, XOF, XPF, YER, ZAR, ZMW, ZWL

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

pyrrencies-0.1.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

pyrrencies-0.1.0-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

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