django-historical-currencies


Namedjango-historical-currencies JSON
Version 0.0.2.post1 PyPI version JSON
download
home_page
SummaryDjango currencies with historical exchange rates
upload_time2024-03-13 17:32:33
maintainer
docs_urlNone
author
requires_python>=3.7
licenseISC
keywords django currencies exchange xe
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django currencies with historical exchange rates

This is a fairly minimal Django app that renders amounts of currencies,
stores historical exchange rates in the database, and performs currency
conversion.

When working with any historical multi-currency data, one often needs to
be able to perform exchange rate calculations with historical rates.
This allows the conversion to be accurately reproduced in the future.

Exchange Rates are stored in a simple database table, with 1 row per
rate per date.
Conversions can be done directly, or across a base currency using 2
rates.

Formatting is defined by [`iso4217`](https://pypi.org/project/iso4217/).
Exchange Rate data can be sourced from:

* The [European ECB Reference Rates](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html).
  Public, provides rates for 41 currencies against EUR.
* [openexchangerates.org](https://openexchangerates.org/).
  Requires (free) registration, provides 169 currencies against USD.

## Installation

1. Install `django-historical-currencies` in your Python environment.
1. Add `historical_currencies` to `INSTALLED_APPS` in your
   `settings.py`.
1. Import yesterday's exchange rates to get started:
   `manage.py import_ecb_exchangerates --daily`.
1. Configure a periodic task (e.g. cron, systemd timer, celery beat) to
   import daily exchange rates.

## Settings

* `MAX_EXCHANGE_RATE_AGE`: How many days old can an exchange rate be
  treated as current?

Optional settings, only required for OpenExchangeRates.org import:

* `OPEN_EXCHANGE_RATES_APP_ID`: OpenExchangeRates App ID.
* `OPEN_EXCHANGE_RATES_BASE_CURRENCY`: Base currency.

## Usage

In code, amounts can be converted using the
`historical_currencies.exchange.exchange()` method.

In templates, this module represents financial amounts as tuple of
`(Decimal, str(currency-code))`. The recommended approach is to add
properties to your Django models to return this tuple for amounts.

In a template the amount can be displayed or converted:

```
{% load currency_format %}

Assuming my_amount = (Decimal(10), 'USD')
Display:
{{ my_amount|currency }}
-> 10.00 USD

Exchange at the latest rate:
{{ my_amount|exchange:"EUR" }}
-> 9.06 EUR
```

### Currency Selectors:

There are two template tags to help render currency selectors. A
high-level one that renders HTML:

```
{% load currency_choices %}

<select>
  {% currency_choices_options selected="USD" %}
</select>
```

And a low-level one that returns a list of currencies:

```
{% load currency_choices %}

<select>
  {% currency_choices_list as currency_choices %}
  {% for code, name in currency_choices %}
    <option value="{{ code }}">{{ name }}</option>
  {% endfor %}
</select>
```

## License

This Django app is available under the terms of the ISC license, see
`LICENSE`.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-historical-currencies",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "django,currencies,exchange,xe",
    "author": "",
    "author_email": "Stefano Rivera <stefano@rivera.za.net>",
    "download_url": "https://files.pythonhosted.org/packages/9c/d6/a78a94866ee010c12fff68e9da958c93112be0c020980195249913339b8b/django-historical-currencies-0.0.2.post1.tar.gz",
    "platform": null,
    "description": "# Django currencies with historical exchange rates\n\nThis is a fairly minimal Django app that renders amounts of currencies,\nstores historical exchange rates in the database, and performs currency\nconversion.\n\nWhen working with any historical multi-currency data, one often needs to\nbe able to perform exchange rate calculations with historical rates.\nThis allows the conversion to be accurately reproduced in the future.\n\nExchange Rates are stored in a simple database table, with 1 row per\nrate per date.\nConversions can be done directly, or across a base currency using 2\nrates.\n\nFormatting is defined by [`iso4217`](https://pypi.org/project/iso4217/).\nExchange Rate data can be sourced from:\n\n* The [European ECB Reference Rates](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html).\n  Public, provides rates for 41 currencies against EUR.\n* [openexchangerates.org](https://openexchangerates.org/).\n  Requires (free) registration, provides 169 currencies against USD.\n\n## Installation\n\n1. Install `django-historical-currencies` in your Python environment.\n1. Add `historical_currencies` to `INSTALLED_APPS` in your\n   `settings.py`.\n1. Import yesterday's exchange rates to get started:\n   `manage.py import_ecb_exchangerates --daily`.\n1. Configure a periodic task (e.g. cron, systemd timer, celery beat) to\n   import daily exchange rates.\n\n## Settings\n\n* `MAX_EXCHANGE_RATE_AGE`: How many days old can an exchange rate be\n  treated as current?\n\nOptional settings, only required for OpenExchangeRates.org import:\n\n* `OPEN_EXCHANGE_RATES_APP_ID`: OpenExchangeRates App ID.\n* `OPEN_EXCHANGE_RATES_BASE_CURRENCY`: Base currency.\n\n## Usage\n\nIn code, amounts can be converted using the\n`historical_currencies.exchange.exchange()` method.\n\nIn templates, this module represents financial amounts as tuple of\n`(Decimal, str(currency-code))`. The recommended approach is to add\nproperties to your Django models to return this tuple for amounts.\n\nIn a template the amount can be displayed or converted:\n\n```\n{% load currency_format %}\n\nAssuming my_amount = (Decimal(10), 'USD')\nDisplay:\n{{ my_amount|currency }}\n-> 10.00 USD\n\nExchange at the latest rate:\n{{ my_amount|exchange:\"EUR\" }}\n-> 9.06 EUR\n```\n\n### Currency Selectors:\n\nThere are two template tags to help render currency selectors. A\nhigh-level one that renders HTML:\n\n```\n{% load currency_choices %}\n\n<select>\n  {% currency_choices_options selected=\"USD\" %}\n</select>\n```\n\nAnd a low-level one that returns a list of currencies:\n\n```\n{% load currency_choices %}\n\n<select>\n  {% currency_choices_list as currency_choices %}\n  {% for code, name in currency_choices %}\n    <option value=\"{{ code }}\">{{ name }}</option>\n  {% endfor %}\n</select>\n```\n\n## License\n\nThis Django app is available under the terms of the ISC license, see\n`LICENSE`.\n",
    "bugtrack_url": null,
    "license": "ISC",
    "summary": "Django currencies with historical exchange rates",
    "version": "0.0.2.post1",
    "project_urls": {
        "Changelog": "https://github.com/stefanor/django-historical-currencies/blob/master/CHANGELOG.md",
        "Repository": "https://github.com/stefanor/django-historical-currencies/"
    },
    "split_keywords": [
        "django",
        "currencies",
        "exchange",
        "xe"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d2bce9645ba041ddc3b44ff7103c906ef159bc77fa796493dc0356fed4cb0107",
                "md5": "6f3e0314d7e63c76854e7ab877454db0",
                "sha256": "e1b0e26e23f27d42688cb3f0c80bde425838967bcb3b7286028040ffa0955bfb"
            },
            "downloads": -1,
            "filename": "django_historical_currencies-0.0.2.post1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f3e0314d7e63c76854e7ab877454db0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17853,
            "upload_time": "2024-03-13T17:32:32",
            "upload_time_iso_8601": "2024-03-13T17:32:32.526986Z",
            "url": "https://files.pythonhosted.org/packages/d2/bc/e9645ba041ddc3b44ff7103c906ef159bc77fa796493dc0356fed4cb0107/django_historical_currencies-0.0.2.post1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9cd6a78a94866ee010c12fff68e9da958c93112be0c020980195249913339b8b",
                "md5": "35b6070441e84df8a5fdd6845327682b",
                "sha256": "40e7ff1a87a10e0ed96f231abb0f39af2abf2a016f52d346deca0694d900d3d7"
            },
            "downloads": -1,
            "filename": "django-historical-currencies-0.0.2.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "35b6070441e84df8a5fdd6845327682b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11739,
            "upload_time": "2024-03-13T17:32:33",
            "upload_time_iso_8601": "2024-03-13T17:32:33.597063Z",
            "url": "https://files.pythonhosted.org/packages/9c/d6/a78a94866ee010c12fff68e9da958c93112be0c020980195249913339b8b/django-historical-currencies-0.0.2.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-13 17:32:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "stefanor",
    "github_project": "django-historical-currencies",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-historical-currencies"
}
        
Elapsed time: 0.27846s