-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from duketemon/23.04.23-initial_release
Initial release
- Loading branch information
Showing
22 changed files
with
1,397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.PHONY: init upd fmt style tests verify | ||
|
||
init: | ||
poetry install | ||
|
||
upd: | ||
poetry lock | ||
|
||
shell: | ||
poetry shell | ||
|
||
fmt: | ||
isort . | ||
black . | ||
|
||
style: | ||
isort --check --diff . | ||
black --check --diff . | ||
mypy -p currency_codes | ||
|
||
tests: | ||
pytest tests -vv | ||
|
||
verify: fmt style tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
## Description | ||
Comprehensive Python package for managing currency codes across different types of assets. Having all the currency codes in one package can simplify the development process for applications that involve multiple currencies and assets. This package could also help to ensure consistency and accuracy in managing currency codes across different parts of an application | ||
The package provides currency codes for different types of assets. Such as | ||
- fiat (US dollar, UAE Dirham, ...) | ||
- crypto (Bitcoin, Solana, ...) | ||
- commodity (Palladium, Gold, ...) | ||
- others (WIR Franc, CFP Franc, ...) | ||
|
||
## Sources | ||
- [Coinmarketcap website](https://coinmarketcap.com) for crypto | ||
- [ISO's website](https://www.iso.org/iso-4217-currency-codes.html) for rest | ||
|
||
## Installation | ||
Install the package with the following command: | ||
```shell | ||
pip install currency_codes | ||
``` | ||
|
||
## How to use the package? | ||
### Get a currency info by a currency code | ||
You can get any currency info using the snippet below | ||
```python | ||
from currency_codes import get_currency_by_code, Currency | ||
|
||
currency_code: str = "EUR" | ||
currency: Currency = get_currency_by_code(currency_code) | ||
``` | ||
if the package doesn't know a currency code you can raise a PR to extend the knowledge base but for now the `CurrencyNotFoundError` will be raised. | ||
|
||
```python | ||
from currency_codes import get_currency_by_code, CurrencyNotFoundError | ||
|
||
# non-existent currency code | ||
currency_code: str = "EUR000" | ||
try: | ||
get_currency_by_code(currency_code) | ||
except CurrencyNotFoundError: | ||
print("Non-existent code have been used") | ||
``` | ||
|
||
|
||
### Get a currency info by a currency numeric code | ||
To get a currency info you can also use the numeric code like in the example below | ||
```python | ||
from currency_codes import get_currency_by_numeric_code, Currency | ||
|
||
# Euro has 978 numeric code | ||
currency_numeric_code: str = "978" | ||
currency: Currency = get_currency_by_numeric_code(currency_numeric_code) | ||
``` | ||
if the package doesn't know a currency numeric code you can raise a PR to extend the knowledge base but for now the `CurrencyNotFoundError` will be raised. | ||
|
||
```python | ||
from currency_codes import get_currency_by_numeric_code, CurrencyNotFoundError | ||
|
||
# non-existent currency numeric code | ||
currency_numeric_code: str = "00000000" | ||
try: | ||
get_currency_by_numeric_code(currency_numeric_code) | ||
except CurrencyNotFoundError: | ||
print("Non-existent numeric code have been used") | ||
``` | ||
|
||
|
||
### Get the list of all currencies | ||
If you want to get information about all currencies, you can use `get_all_currencies` function | ||
```python | ||
from currency_codes import get_all_currencies, Currency | ||
|
||
currencies: list[Currency] = get_all_currencies() | ||
``` | ||
|
||
### Get the list of fiat currencies | ||
If you want to get information only about fiat currencies, you can use `get_fiat_currencies` function | ||
```python | ||
from currency_codes import get_fiat_currencies, Currency | ||
|
||
fiat_currencies: list[Currency] = get_fiat_currencies() | ||
``` | ||
|
||
### Get the list of crypto currencies | ||
If you want to get information only about crypto currencies, you can use `get_crypto_currencies` function | ||
```python | ||
from currency_codes import get_crypto_currencies, Currency | ||
|
||
crypto_currencies: list[Currency] = get_crypto_currencies() | ||
``` | ||
|
||
### Get the list of commodity currencies | ||
If you want to get information only about commodity currencies, you can use `get_commodity_currencies` function | ||
```python | ||
from currency_codes import get_commodity_currencies, Currency | ||
|
||
commodity_currencies: list[Currency] = get_commodity_currencies() | ||
``` | ||
|
||
### Get the list of other currencies | ||
If you want to get information only about other currencies, you can use `get_other_currencies` function | ||
```python | ||
from currency_codes import get_other_currencies, Currency | ||
|
||
other_currencies: list[Currency] = get_other_currencies() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from currency_codes.assets.commodity import get_commodity_currencies | ||
from currency_codes.assets.crypto import get_crypto_currencies | ||
from currency_codes.assets.fiat import get_fiat_currencies | ||
from currency_codes.assets.other import get_other_currencies | ||
from currency_codes.exceptions import CurrencyNotFoundError | ||
from currency_codes.main import ( | ||
get_all_currencies, | ||
get_currency_by_code, | ||
get_currency_by_numeric_code, | ||
) | ||
from currency_codes.models import Currency |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from currency_codes.models import Currency | ||
|
||
|
||
def get_commodity_currencies() -> list[Currency]: | ||
return _commodity_currencies | ||
|
||
|
||
_commodity_currencies: list[Currency] = [ | ||
Currency(name="Palladium", code="XPD", numeric_code="964", minor_units=None), | ||
Currency(name="Platinum", code="XPT", numeric_code="962", minor_units=None), | ||
Currency(name="Gold", code="XAU", numeric_code="959", minor_units=None), | ||
Currency(name="Silver", code="XAG", numeric_code="961", minor_units=None), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from currency_codes.models import Currency | ||
|
||
|
||
def get_crypto_currencies() -> list[Currency]: | ||
return _crypto_currencies | ||
|
||
|
||
_crypto_currencies: list[Currency] = [ | ||
Currency(name="Bitcoin", code="BTC", numeric_code=None, minor_units=8), | ||
Currency(name="Ethereum", code="ETH", numeric_code=None, minor_units=18), | ||
Currency(name="Binance Coin", code="BNB", numeric_code=None, minor_units=18), | ||
Currency(name="Cardano", code="ADA", numeric_code=None, minor_units=18), | ||
Currency(name="XRP", code="XRP", numeric_code=None, minor_units=6), | ||
Currency(name="Solana", code="SOL", numeric_code=None, minor_units=9), | ||
Currency(name="Polkadot", code="DOT", numeric_code=None, minor_units=10), | ||
Currency(name="Dogecoin", code="DOGE", numeric_code=None, minor_units=8), | ||
Currency(name="USD Coin", code="USDC", numeric_code=None, minor_units=6), | ||
Currency(name="Terra", code="LUNA", numeric_code=None, minor_units=6), | ||
Currency(name="Uniswap", code="UNI", numeric_code=None, minor_units=18), | ||
Currency(name="Litecoin", code="LTC", numeric_code=None, minor_units=8), | ||
Currency(name="Bitcoin Cash", code="BCH", numeric_code=None, minor_units=8), | ||
Currency(name="Polygon", code="MATIC", numeric_code=None, minor_units=18), | ||
Currency(name="Wrapped Bitcoin", code="WBTC", numeric_code=None, minor_units=8), | ||
Currency(name="Cosmos", code="ATOM", numeric_code=None, minor_units=6), | ||
Currency(name="FTX Token", code="FTT", numeric_code=None, minor_units=18), | ||
Currency(name="Avalanche", code="AVAX", numeric_code=None, minor_units=18), | ||
Currency(name="Chainlink", code="LINK", numeric_code=None, minor_units=18), | ||
Currency(name="SHIBA INU", code="SHIB", numeric_code=None, minor_units=18), | ||
Currency(name="Ethereum Classic", code="ETC", numeric_code=None, minor_units=18), | ||
Currency(name="TRON", code="TRX", numeric_code=None, minor_units=6), | ||
Currency(name="Internet Computer", code="ICP", numeric_code=None, minor_units=8), | ||
Currency(name="Bitcoin SV", code="BSV", numeric_code=None, minor_units=8), | ||
Currency(name="PancakeSwap", code="CAKE", numeric_code=None, minor_units=18), | ||
Currency(name="Fantom", code="FTM", numeric_code=None, minor_units=18), | ||
Currency(name="Filecoin", code="FIL", numeric_code=None, minor_units=18), | ||
Currency(name="Dai", code="DAI", numeric_code=None, minor_units=18), | ||
Currency(name="UNUS SED LEO", code="LEO", numeric_code=None, minor_units=2), | ||
Currency(name="Huobi Token", code="HT", numeric_code=None, minor_units=18), | ||
Currency(name="Aave", code="AAVE", numeric_code=None, minor_units=18), | ||
Currency(name="OKB", code="OKB", numeric_code=None, minor_units=2), | ||
Currency(name="The Open Network", code="TON", numeric_code=None, minor_units=2), | ||
Currency(name="Kusama", code="KSM", numeric_code=None, minor_units=12), | ||
Currency(name="Theta Network", code="THETA", numeric_code=None, minor_units=18), | ||
Currency(name="Compound", code="COMP", numeric_code=None, minor_units=18), | ||
Currency(name="NEO", code="NEO", numeric_code=None, minor_units=0), | ||
Currency(name="Binance USD", code="BUSD", numeric_code=None, minor_units=18), | ||
Currency(name="Elrond", code="EGLD", numeric_code=None, minor_units=18), | ||
Currency(name="Dash", code="DASH", numeric_code=None, minor_units=8), | ||
Currency(name="Zcash", code="ZEC", numeric_code=None, minor_units=8), | ||
Currency(name="Bitcoin Cash ABC", code="BCHA", numeric_code=None, minor_units=8), | ||
Currency(name="Chiliz", code="CHZ", numeric_code=None, minor_units=8), | ||
Currency(name="Telcoin", code="TEL", numeric_code=None, minor_units=2), | ||
Currency(name="Waves", code="WAVES", numeric_code=None, minor_units=8), | ||
Currency(name="TrueUSD", code="TUSD", numeric_code=None, minor_units=18), | ||
Currency(name="BitTorrent", code="BTT", numeric_code=None, minor_units=6), | ||
Currency(name="Decred", code="DCR", numeric_code=None, minor_units=8), | ||
Currency(name="Hedera Hashgraph", code="HBAR", numeric_code=None, minor_units=8), | ||
Currency(name="SushiSwap", code="SUSHI", numeric_code=None, minor_units=18), | ||
Currency(name="Helium", code="HNT", numeric_code=None, minor_units=18), | ||
Currency(name="Qtum", code="QTUM", numeric_code=None, minor_units=8), | ||
Currency(name="Holo", code="HOT", numeric_code=None, minor_units=18), | ||
Currency(name="Paxos Standard", code="PAX", numeric_code=None, minor_units=18), | ||
Currency(name="Stacks", code="STX", numeric_code=None, minor_units=6), | ||
Currency(name="UMA", code="UMA", numeric_code=None, minor_units=18), | ||
Currency(name="Ravencoin", code="RVN", numeric_code=None, minor_units=8), | ||
Currency(name="Nano", code="NANO", numeric_code=None, minor_units=30), | ||
Currency(name="Zilliqa", code="ZIL", numeric_code=None, minor_units=12), | ||
Currency(name="Kava.io", code="KAVA", numeric_code=None, minor_units=6), | ||
Currency(name="Bitcoin Gold", code="BTG", numeric_code=None, minor_units=8), | ||
Currency(name="renBTC", code="RENBTC", numeric_code=None, minor_units=8), | ||
Currency(name="Hive", code="HIVE", numeric_code=None, minor_units=3), | ||
Currency(name="Horizen", code="ZEN", numeric_code=None, minor_units=8), | ||
Currency(name="Monero", code="XMR", numeric_code=None, minor_units=12), | ||
Currency(name="Nexus Mutual", code="NXM", numeric_code=None, minor_units=18), | ||
Currency(name="Arweave", code="AR", numeric_code=None, minor_units=12), | ||
Currency(name="Curve DAO Token", code="CRV", numeric_code=None, minor_units=18), | ||
Currency(name="Ocean Protocol", code="OCEAN", numeric_code=None, minor_units=18), | ||
Currency(name="MaidSafeCoin", code="MAID", numeric_code=None, minor_units=8), | ||
Currency(name="Storj", code="STORJ", numeric_code=None, minor_units=8), | ||
Currency(name="Siacoin", code="SC", numeric_code=None, minor_units=24), | ||
Currency(name="Enzyme", code="MLN", numeric_code=None, minor_units=18), | ||
Currency(name="NKN", code="NKN", numeric_code=None, minor_units=18), | ||
Currency(name="HUSD", code="HUSD", numeric_code=None, minor_units=8), | ||
Currency(name="iExec RLC", code="RLC", numeric_code=None, minor_units=9), | ||
Currency(name="Bancor", code="BNT", numeric_code=None, minor_units=18), | ||
Currency(name="Livepeer", code="LPT", numeric_code=None, minor_units=18), | ||
Currency(name="Algorand", code="ALGO", numeric_code=None, minor_units=6), | ||
Currency(name="Ardor", code="ARDR", numeric_code=None, minor_units=8), | ||
Currency(name="Golem", code="GLM", numeric_code=None, minor_units=18), | ||
Currency(name="The Graph", code="GRT", numeric_code=None, minor_units=18), | ||
Currency(name="Ren", code="REN", numeric_code=None, minor_units=18), | ||
Currency(name="IoTeX", code="IOTX", numeric_code=None, minor_units=18), | ||
Currency(name="Fetch.ai", code="FET", numeric_code=None, minor_units=18), | ||
Currency(name="Staked Ether", code="STETH", numeric_code=None, minor_units=18), | ||
Currency(name="Nexo", code="NEXO", numeric_code=None, minor_units=18), | ||
Currency(name="BakeryToken", code="BAKE", numeric_code=None, minor_units=18), | ||
Currency(name="Measurable Data Token", code="MDT", numeric_code=None, minor_units=18), | ||
] |
Oops, something went wrong.