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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file pyrrencies-0.1.0.tar.gz.

File metadata

  • Download URL: pyrrencies-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for pyrrencies-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8009f123c077af08ed2dbf9558cb5dcc2bc2250cea3fbb4d2021e5d2923db25d
MD5 a6fe7ba0e2c7ab8a633d7b401189a18b
BLAKE2b-256 eaecf329b6bc67946d48c035bb2ee8cc0e27c8a1d871f506221eefe6b87c6d9d

See more details on using hashes here.

File details

Details for the file pyrrencies-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyrrencies-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for pyrrencies-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f424703f559038a501109a085e74870253f99e827834c7a6546a0096d6d762d5
MD5 1a3c669e284e2fb81a5d907692bf9032
BLAKE2b-256 d1af09566d8b6a36e97064f200384690a5803839e2c650133f23f70a2a0365b8

See more details on using hashes here.

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