Skip to main content

async-cb-rate

Асинхронная библиотека для парсинга курса валют с сайта ЦБ РФ.

Библиотеку можно использовать для:

  • мониторинга за курсом валют
  • построения графиков изменения курса

Установка c pip

pip install async-cb-rate

Краткий обзор функциональности

  • Библиотека позволяет получить курс валюты на любой день. По умолчанию курс ищется на сегодняшний день.
  • Функции возвращают объекты Currency, с которыми удобно далее работать.
import asyncio

from async_cb_rate.parser import get_rate, get_codes, get_all_rates


async def main():
    usd_rate = await get_rate("USD")
    print(f"USD rate for today={usd_rate.price}₽")  # USD rate for today=55.2987₽

    euro_rate = await get_rate("EUR")  # EUR rate for today=52.7379₽
    print(f"EUR rate for today={euro_rate.price}₽")

    codes = await get_codes()
    print(f"Available codes: {codes}") # ['AUD', 'AZN', 'GBP', 'AMD', 'BYN', 'BGN', 'BRL', 'HUF', 'HKD', 'DKK', 'USD', 
    # 'EUR', 'INR', 'KZT', 'CAD', 'KGS', 'CNY', 'MDL', 'NOK', 'PLN', 'RON', 'XDR', 'SGD', 'TJS', 'TRY', 'TMT', 'UZS', 
    # 'UAH', 'CZK', 'SEK', 'CHF', 'ZAR', 'KRW', 'JPY']

    all_rates = await get_all_rates()
    print(f"All rates for today: {all_rates}")  # [Currency(name='Австралийский доллар', code='AUD', price=35.9552, 
    # date=datetime.datetime(2022, 10, 3, 23, 45, 29, 145779)), ...]


asyncio.run(main())

Доступные асинхронные функции библиотеки:

  • get_codes(date) - получить все доступные коды валют на определённую дату:
    codes = await get_codes() # Коды валют
  • get_rate(code, date) - получить курс определённой валюты по её коду на определённую дату:
    usd_rate = await get_rate("USD") # Курс доллара на сегодня
  • get_all_rates(date) - получить курс всех доступных валют от ЦБ на определённую дату:
    all_rates = await get_all_rates() # Все курсы валют на сегодня
    ! По умолчанию поле date - это сегодня.

Ошибки, которые можно получить при работе с библиотекой:

  • NoValidDateError - функция была вызвана с датой, которая ещё не наступила.
  • CurrencyRateNotFoundError - курс для данного кода валюты не найден.

Metadata

Release files for async-cb-rate 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for async-cb-rate 1.0.1
File Size Uploaded Provenance
async-cb-rate-1.0.1.tar.gz 3.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for async-cb-rate 1.0.1
File Interpreter ABI Platform
async_cb_rate-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / async-cb-rate-1.0.1.tar.gz

Download URL async-cb-rate-1.0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0d333fba739d5d115eed44bb786df066d944116b13903fc4307b44a0bbf19e56
BLAKE2b-256 checksum
How to use checksums
a9b4fa4a4aed7b95f83a3890dc7c688ff0d68e64dfb5181cf46ab11f370e16da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / async_cb_rate-1.0.1-py3-none-any.whl

Download URL async_cb_rate-1.0.1-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58144ce5f62c1b1909473ebd3b11ebf124b794f65ccd5c38b693ab491041fd28
BLAKE2b-256 checksum
How to use checksums
f5bb1449fe1797b666b2f6d77f51aa7487bb64bd1effc0eb4ae86f1ff5fbcd9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.4

Security for async-cb-rate 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page