Skip to main content

A Pythonic currency calculator with real-time exchange rates

Project description

Currex

currex version - PyPI PyPI status MIT license - PyPI Python version - PyPI GitHub Actions: Build GitHub Actions: Linting Twitter @pmigdal

A Pythonic currency calculator that makes working with currencies and exchange rates simple and smooth - by Piotr Migdał.

I often use Python as a command-line calculator. Yet, I need to go back to Google Search to convert between currencies. So, for my own convenience, I created this library that makes it easy to add, multiply and change currencies. One of the core features is autocasting - when using a few currencies, automatically convert them to the first one.

It is intended to be used in interactive Python sessions (such as Jupyter Notebook, IPython, etc.) to get ballpark estimates of prices - e.g. when traveling, buying online, etc. Personally, I use it from the command line IPython.

It is a new package, so I'm open to suggestions.

It is NOT intended to be used in production code. Every API design decision I made was to make it as simple as possible to use in interactive sessions. Some of them are consciously at odds with a tool that could be used in a library.

EVEN MORE IMPORTANT: Never use it for any important decisions - taxes, investments, etc. There is no guarantee that the exchange rates are up-to-date and correct. Note that even major players make mistakes, e.g. Google Glitch Undervalues Poland's Zloty By A Fifth. Always use the official exchange rates.

Installation

pip install currex

Usage

from currex import *

# use currencies as if they were numbers
100 * USD  # USD(100.00)
12 * USD(100)  # USD(1200.00)

# convert currencies to other currencies
USD(100).to(EUR)  # EUR(85.30)
USD(100).to(PLN)  # PLN(430.50)

# this syntax is also supported
PLN(EUR(12))  # PLN(51.33)

# add different currencies
USD(100) + EUR(100)  # USD(203.42)
EUR(100) - USD(100)  # EUR(3.22)

# divide currencies
USD(2) / JPY(14)  # 22.531428526365715

# configure decimal digits (default is 2)
currex_config.set_decimal_digits(3)  # show 3 decimal places
USD(123.456789)  # USD(123.457)
currex_config.set_decimal_digits(None)  # show full precision
USD(123.456789)  # USD(123.456789)

Features

  • Arithmetic operations with currencies
  • Currency conversion
  • Autocasting - when using a few currencies, automatically convert them to the first one
  • Configurable decimal places for currency representation

Requirements

  • Python 3.9 or higher
  • Internet connection for real-time exchange rates - it uses HexaRate

TODO

  • Mock API for testing
  • More backends for exchange rates
  • Support for more cryptocurrencies

License

MIT License by Piotr Migdał

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

currex-0.1.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

currex-0.1.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file currex-0.1.2.tar.gz.

File metadata

  • Download URL: currex-0.1.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for currex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 06cb5a49b384fefd1481aa613060436ed3023993e21e2bd913f0eccfde8a9bc6
MD5 c2d15d63d882c4129e4f12152d049cb9
BLAKE2b-256 ff37767af77ca6cc343352a4bc2b85f79bf6f310a60a0214091f2b30dd8268f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for currex-0.1.2.tar.gz:

Publisher: publish.yml on stared/currex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file currex-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: currex-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for currex-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 67caf0f38b0ce0451abffffe9d1b54bead360efc836491dd9206b24f5465daaf
MD5 07b92adb87e888af5298ad74f2e0a825
BLAKE2b-256 03d83e4fe3ccf3cad915f8bbe6d42e410816720be591578fd4172dbb05221f85

See more details on using hashes here.

Provenance

The following attestation bundles were made for currex-0.1.2-py3-none-any.whl:

Publisher: publish.yml on stared/currex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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