Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idlesign/pycbrf
Tools to query Bank of Russia
https://github.com/idlesign/pycbrf
bank currency exchange-rates python python2 python3 russia
Last synced: 12 days ago
JSON representation
Tools to query Bank of Russia
- Host: GitHub
- URL: https://github.com/idlesign/pycbrf
- Owner: idlesign
- License: bsd-3-clause
- Created: 2016-06-27T12:05:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-09-25T05:11:53.000Z (about 3 years ago)
- Last Synced: 2024-10-10T12:07:22.074Z (about 1 month ago)
- Topics: bank, currency, exchange-rates, python, python2, python3, russia
- Language: Python
- Homepage: https://github.com/idlesign/pycbrf
- Size: 2.69 MB
- Stars: 57
- Watchers: 8
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
pycbrf
======
https://github.com/idlesign/pycbrf.. image:: https://img.shields.io/pypi/v/pycbrf.svg
:target: https://pypi.python.org/pypi/pycbrf.. image:: https://img.shields.io/pypi/l/pycbrf.svg
:target: https://pypi.python.org/pypi/pycbrf.. image:: https://img.shields.io/coveralls/idlesign/pycbrf/master.svg
:target: https://coveralls.io/r/idlesign/pycbrfDescription
-----------*Tools to query Bank of Russia*
Provides methods to get the following information:
1. Exchange rates on various dates (including basic currencies data)
2. Banks information (requisites, codes, numbers, etc.)Requirements
------------* Python 3.6+
* ``requests`` Python package
* ``dbf_light`` Python package (to support legacy Bank format)
* ``click`` package (optional, for CLI)Usage
-----CLI
~~~.. code-block:: bash
$ pycbrf --help
$ pycbrf rates
$ pycbrf rates -d 2016-06-26 -c USD$ pycbrf banks
$ pycbrf banks -b 045004641CLI requires ``click`` package to be installed. Can be installed with ``pycbrf`` using:
.. code-block:: bash
$ pip install pycbrf[cli]
Python
~~~~~~.. code-block:: python
from pycbrf import ExchangeRates, Banks
rates = ExchangeRates('2016-06-26', locale_en=True)
rates.date_requested # 2016-06-26 00:00:00
rates.date_received # 2016-06-25 00:00:00
rates.dates_match # False
# Note: 26th of June was a holiday, data is taken from the 25th.# Various indexing is supported:
rates['USD'].name # US Dollar
rates['R01235'].name # US Dollar
rates['840'].name # US Dollarrates['USD']
'''
ExchangeRate(
id='R01235',
name='US Dollar',
code='USD',
num='840',
value=Decimal('65.5287'),
par=Decimal('1'),
rate=Decimal('65.5287'),
date=datetime(2016, 06, 25),
currency=Currency(
id='R01235',
name_eng='US Dollar',
name_ru='Доллар США',
num='840',
code='USD',
par=Decimal('1')
)
)
'''banks = Banks()
bank = banks['045004641']
assert bank
bank.swift # SABRRUMMNH1
bank.corr # 30101810500000000641bank_annotated = Banks.annotate([bank])[0]
for title, value in bank_annotated.items():
print(f'{title}: {value}')