Skip to content

A library to get currency exchange rates by CentroBank of Russian Federation

License

Notifications You must be signed in to change notification settings

KOLANICH-libs/cbrf.py

Repository files navigation

cbrf.py Unlicensed work

wheel (GHA via nightly.link) GitHub Actions Libraries.io Status Code style: antiflash

We have moved to https://codeberg.org/KOLANICH-libs/cbrf.py, grab new versions there.

Under the disguise of "better security" Micro$oft-owned GitHub has discriminated users of 1FA passwords while having commercial interest in success and wide adoption of FIDO 1FA specifications and Windows Hello implementation which it promotes as a replacement for passwords. It will result in dire consequencies and is competely inacceptable, read why.

If you don't want to participate in harming yourself, it is recommended to follow the lead and migrate somewhere away of GitHub and Micro$oft. Here is the list of alternatives and rationales to do it. If they delete the discussion, there are certain well-known places where you can get a copy of it. Read why you should also leave GitHub.


Gets currency exchange rates from the official API of CentroBank of the Russian Federation .

Disclaimer

I AM NOT AFFILIATED WITH THE CENTROBANK. I'M JUST A CITIZEN AND RESIDENT OF RUSSIA SO I HAVE TO TRANSLATE PRICES USING THE CENTROBANK EXCHANGE RATE WHEN PROVIDING MY BOSS WITH THE RATIONALE THAT SOMETHING IS NEEDED. NEITHER CREATING NOR PUBLISHING OF THIS LIBRARY CAN BE UNDERSTOOD AS PROMOTING ANY POLITICS, THE BANK, ITS EXCHANGE RATES OR ITS POSITION OR ANY FINANCIAL ADVISE. THE LIBRARY IS POSTED HERE ONLY FOR CONVENIENCE FOR THE PEOPLE WHO HAVE TO USE THE EXCHANGE RATES BY CB RF. NO GUARANTEE IS PROVIDED. I HOLD NO LIABILITY FOR ITS ACTIONS, QUALITY, CORRECTNESS OF DATA, EXCHANGE RATES, OR ANY OTHER LOSSES, LOST OR IMPLIED OR ASSUMED PROFIT, OR ANYTHING ELSE. PLEASE, SEE THE (UN)LICENSE FILE FOR MORE INFO ABOUT THE LICENSE.

Getting the rates

from cbrf import CentroBank
cb=CentroBank()
print(cb.byISO["USD"])

money integration

import money
from cbrf import MoneyBackend
money.xrates.install(MoneyBackend())
money.Money(1, "USD").to("RUB")

pint integration

!!! WARNING: FOR NOW IT DOESN'T USE Decimal type. Precision loss is likely to occur !!!

import pint
from cbrf import populatePintUnitRegistry
ureg = pint.UnitRegistry(None)
populatePintUnitRegistry(ureg, cb.byISO.values())
ureg("1 USD").to(ureg.RUB)

About

A library to get currency exchange rates by CentroBank of Russian Federation

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages