Skip to main content

CLI tool for displaying exchange rates for Croatian Kuna

Project description

Displays exchange rates for Croatian Kuna (HRK) from the Croatian National Bank (HNB). Data is fetched from the [HNB API](https://api.hnb.hr/).

https://img.shields.io/badge/author-%40ihabunek-blue.svg?maxAge=3600&style=flat-square https://img.shields.io/github/license/ihabunek/hnbex-cli.svg?maxAge=3600&style=flat-square https://img.shields.io/pypi/v/hnbex-cli.svg?maxAge=3600&style=flat-square

Installation

Requires Python 3.7 or greater.

Drawing charts requires gnuplot.

Install from the Python Package Index:

pip install hnbex-cli

Usage

Commands:

  • daily - Show daily exchange rates for all currencies

  • range - Show exchange rates for a single currency in the given date range

  • chart - Draw exchange rate chart for a single currency

  • convert - Convert between currencies

Daily

Show rates for all currencies on a given date (if not given, date defaults to today):

$ hnbex daily 2017-07-03
HNB exchange rates on 2017-07-03

Currency  Unit    Buying    Median   Selling
--------  ----  --------  --------  --------
AUD          1  4.974959  4.989929  5.004899
CAD          1  4.984697  4.999696  5.014695
CZK          1  0.281550  0.282397  0.283244
DKK          1  0.993132  0.996120  0.999108
HUF        100  2.390306  2.397498  2.404690
JPY        100  5.783341  5.800743  5.818145
NOK          1  0.772153  0.774476  0.776799
SEK          1  0.764812  0.767113  0.769414
CHF          1  6.756313  6.776643  6.796973
GBP          1  8.410575  8.435883  8.461191
USD          1  6.474949  6.494432  6.513915
EUR          1  7.385326  7.407549  7.429772
PLN          1  1.748834  1.754096  1.759358

Range

Show rates for a single currency, for range of days.

The range defaults to the last 30 days, and can be changed by giving one or more of:

  • --start or -s - the first day of the range (default calculated as end - days)

  • --end or -e - the last day of the range (defaults to tomorrow)

  • --days or -d - number of days in the range (defaults to 30)

$ hnbex range usd -d 10
HNB exchange rates for USD from 2021-08-26 to 2021-09-04

      Date  Unit    Buying    Median   Selling    Diff
----------  ----  --------  --------  --------  ------
2021-08-26     1  6.353770  6.372889  6.392008
2021-08-27     1  6.341215  6.360296  6.379377  -0.20%
2021-08-28     1  6.346328  6.365424  6.384520  +0.08%
2021-08-29     1  6.346328  6.365424  6.384520   0.00%
2021-08-30     1  6.346328  6.365424  6.384520   0.00%
2021-08-31     1  6.323093  6.342119  6.361145  -0.37%
2021-09-01     1  6.314960  6.333962  6.352964  -0.13%
2021-09-02     1  6.315040  6.334042  6.353044  +0.00%
2021-09-03     1  6.294947  6.313889  6.332831  -0.32%
2021-09-04     1  6.291559  6.310490  6.329421  -0.05%

Chart

This command requires gnuplot to be installed.

Draw a chart of exchange rate movement for range of days. Options are identical as hnbex range.

$ hnbex chart usd
                              USD Exchange Rates

6.42 +-+--+-+-+-+--+-+-+-+--+-+-+-+--+-+-+--+-+-+-+--+-+-+-+--+-+-+-+--+-+
     |             +              +               +    x*x*x**    +      |
 6.4 +-+                                              *                +-+
6.38 +-+                                      x*x*    *       x        +-+
     |                            x**x       *    x**x         *         |
6.36 +-+                          *   *      *                 *       +-+
     |                           *     x*x**x                   x*x    x*x
6.34 +-+                         *                                 * **+-+
     |                          x                                   x    |
6.32 +-+                       *                                       +-+
 6.3 +-+                       *                                       +-+
     |                        x                                          |
6.28 +-+             x        *                                        +-+
     x*x**x*x*       **      *                                           |
6.26 +-+      x*    * *      *                                         +-+
6.24 +-+        x** *  *    *                                          +-+
     |             *   x*x**x     +               +               +      |
6.22 +-+--+-+-+-+--x-+-+-+--+-+-+-+--+-+-+--+-+-+-+--+-+-+-+--+-+-+-+--+-+
                 09/21          09/28           10/05           10/12
                                     Date

Also supports graphical charts:

$ hnbex chart usd --template qt

Which displays the chart:

./chart_qt.png

Convert

Convert between HRK and anouther currency:

$ hnbex convert 150 hrk usd
150.0 HRK = 23.82 USD

Using the median rate 1 USD = 6.296589 HRK defined on 2017-08-21

When converting to HRK, the target currency can be ommited:

$ hnbex convert 500 jpy
500.0 JPY = 28.85 HRK

Using the median rate 100 JPY = 5.769743 HRK defined on 2017-08-21

If --value-only or -v option is used, only the resulting value will be output.

$ hnbex convert 500 jpy
28.85

The resulting value is rounded to 2 decimal places by default but can be changed by using the -p or --precision option:

$ hnbex convert 500 jpy -p 10
28.8487150000

License

Copyright © 2017-2021 Ivan Habunek <ivan@habunek.com>

Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html

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

hnbex_cli-2.1.0.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

hnbex_cli-2.1.0-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file hnbex_cli-2.1.0.tar.gz.

File metadata

  • Download URL: hnbex_cli-2.1.0.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for hnbex_cli-2.1.0.tar.gz
Algorithm Hash digest
SHA256 0c14c96fbd7f6a4142db06bb8eea93d471cc3cf65c8e969003e999d736c8d11e
MD5 9b01dba58f2f424d2d41b42c1f9c3646
BLAKE2b-256 3dc42984f901d6b097ba0ec2f030259e37d7f8745b325dd6af42b6527151e52b

See more details on using hashes here.

File details

Details for the file hnbex_cli-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: hnbex_cli-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for hnbex_cli-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50b4579c43418aa24cf37931a562ee234e3327bea59f527310e8b8723e91a4c3
MD5 6d958bfc5eeb70d49ea6866a5b5c9973
BLAKE2b-256 c177a5be061d043cc8807994ec14e6a12654b4b01cf8fa1289f544003588b3ac

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