Skip to main content

A python library to convert currency, prettify price and get various currency info

Project description

A simple currency module to:

  • Retrive various info about currency

  • Format currency price

  • Convert between currencies

Requirements

  • python3

  • Internet connection (optional)

Installation

$ pip install nh-currency

Usage

import currency

Get currency name

currency.name('USD')
currency.name('USD', plural=True)
'US Dollar'
'US dollars'

Symbol

currency.symbol('CAD')
currency.symbol('CAD', native=False)
currency.symbol('NOK')
currency.symbol('NOK', native=False)
'$'
'CA$'
'kr'
'Nkr'

Number of decimal digits

currency.decimals('USD')
currency.decimals('JPY')
2
0

Round to the maximum decimal digits

currency.rounding(100.115735, 'USD')
currency.rounding(2253.12309, 'ISK')
100.12
2253

Currency increment used for rounding

currency.roundto('USD')
currency.roundto('CHF')
0
0.05

Format currency

currency.pretty(10050000.2394, 'USD')
currency.pretty(10050000.2394, 'USD', trim=True)
currency.pretty(10050000.2394, 'USD', abbrev=False)
'$10,050,000.2394'
'$10,050,000.24'
'10,050,000.2394 USD'

Convert to other currency

currency.convert('USD', 'EUR')
currency.convert('USD', 'EUR', 2)
currency.convert('JPY', 'AUD', 100)
0.815797
1.631594
1.1759

Currency info

currency.info('USD')
# Output has been formatted for representation purpose
{
    'symbol': '$',
    'name': 'US Dollar',
    'symbol_native': '$',
    'decimal_digits': 2,
    'rounding': 0,
    'code': 'USD',
    'name_plural': 'US dollars'
}

Testing

$ cd .../py-currency
$ python -m unittest

Resources

https://gist.github.com/Fluidbyte/2973986

https://www.wikipedia.org/

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

nh-currency-1.0.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nh_currency-1.0.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file nh-currency-1.0.1.tar.gz.

File metadata

  • Download URL: nh-currency-1.0.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nh-currency-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ca4ff3d401c7b2f5b94595c82c0ff1b9b21d6303058a7d224f7ce6e309f15f4a
MD5 8793a069418000dc5f3b2676e437fa2c
BLAKE2b-256 e818c7be20a1234a8c6509a1cfa028585d13fce487ccf17775375dcd79ec7fc5

See more details on using hashes here.

File details

Details for the file nh_currency-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nh_currency-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6848d94e1023e9b112551a9067c56459fc294710c702c1fc0c89f1a0e17edaf4
MD5 35c32376d13c134bbfdaf4fbdd2a9ae0
BLAKE2b-256 3e85c10a5b8d423a2661807ce3a6cb1a0b480f0956409d4691f7aab83ecf93a4

See more details on using hashes here.

Supported by

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