No project description provided
Project description
Documentation
Description:
This Python library provides functionalities to get cryptocurrency prices and perform conversions between Iranian Toman (IRT) and USD, for all supported cryptocurrencies.
Key Features:
-
Get the current price of various cryptocurrencies in IRT or USD.
-
Convert between IRT and USD for any of the supported cryptocurrencies.
-
Get country currencies price
-
Get chart of crypto prices
-
Smart crypto calculator
-
Donate to the library developer (optional).
Installation
pip install YnExchangePY
Functionality
The library provides functions for retrieving the price of all cryptocurrencies. Each function takes 3 arguments:
-
currency (str): This argument specifies the desired currency (either "IRT" or "USD").
-
grouping (bool, optional): This argument is optional (defaults to False). If set to True, the function will format the price with comma separators for readability.
-
crypto_name (str) : This argument is for the name of the desired crypto to get its price
Here's a list of all the available functions:
-
YN_Exchange.CRYPTO_PRICES(crypto_name : str,currency:str,grouping : bool = False)
-
YN_Exchange.GOLD_PRICE(carat : int,mass : str="gram")
-
YN_Exchange.CURRENCY_PRICE(currency : str,price_currency : str = "IRT")
-
YN_Exchange.USD_PRICE()
-
YN_Exchange.CRYPTO_CHART(crypto : str,timeout : int=5,currency : str="usd")
-
YN_Exchange.CALCULATOR(value:float,currency:str,crypto:str,grouping : bool=False,calculat_mode : str="CV2C",other_crypto : str = None)
-
YN_Exchange.DONATE()
Example Usage
Get crypto live prices:
import YN_Exchange
# Get Bitcoin price in USD with grouping
bitcoin_usd_price = YN_Exchange.CRYPTO_PRICES(crypto_name="BTC",currency="USD",grouping=True)
print(f"Bitcoin price in USD: ${bitcoin_usd_price}")
# Get Ethereum price in IRT(no grouping)
ethereum_irt_price = YN_Exchange.CRYPTO_PRICES(crypto_name="ETH",currency="IRT")
print(f"Ethereum price in IRT: {ethereum_irt_price}")
Get gold price (Only IRT currency):
import YN_Exchange
# Get 18k ct gold with gram:
_18k_gold=YN_Exchange.GOLD_PRICE(carat=18,mass="gram") # You can give "kilo" parameter to mass to calculate kilograms
print(_18k_gold)
# Get 24k ct gold with gram:
_24k_gold=YN_Exchange.GOLD_PRICE(carat=24,mass="gram") # You can give "kilo" parameter to mass to calculate kilograms
print(_24k_gold)
Get price of ounce metals (Only USD currency):
This method is being updated
Get currency prices:
import YN_Exchange
# Get USD(united state dollar) price (Only IRT):
usd_price=YN_Exchange.USD_PRICE()
print(usd_prices)
# Get EUR(europe euro) price:
eur_price=YN_Exchange.CURRENCY_PRICE(currency="EUR",price_currency="USD") # You can use "IRT" parameter instead of "USD" parameter
print(eur_price)
The USD function is separated from the main function due to differences
Get chart of crypto prices:
import YN_Exchange
#Get bitcoin price chart
YN_Exchange.CRYPTO_CHART(crypto="BTC",timeout=7,currency="USD")
-
After executing this method, a file named "{your crypto} chart.png" will be created.
-
Some cryptocurrencies do not have a table with USD currency, so you have to use IRT currency.
-
If there is a problem in displaying the table, it will be displayed in the photo.
-
The "timeout" argument is the amount of time the page takes to load.
-
If you have a weak internet, set the "timeout" argument to a number above 7
-
After completing the operation, the message "SAVED!" It will be printed
Crypto calculator
import YN_Exchange
# Converting an amount of a crypto to the total price
print(CALCULATOR(value=10,currency="USD",crypto="USDT",grouping=False,calculat_mode="CV2C"))
# Converting an amount from one crypto to another
print(CALCULATOR(value=10,currency="USD",crypto="USDT",grouping=False,calculat_mode="CV2OC",other_crypto="TON"))
-
calculat_mode : An argument related to the type of calculation ( CV2C : Crypto Value To Currency | CV2OC : Crypto Value To Other Crypto )
-
other_crypto : An argument that is only for "CV2OC" mode to perform the calculation
Error Handling
If the function encounters an error, such as an invalid currency or a network issue, it will raise a ValueError
exception. You can handle this exception using a try-except block.
Limitations
-
The library relies on scraping data from a website, which may be subject to changes or become unavailable.
-
The library only supports a limited number of cryptocurrencies.
Additional notes
Here are some ways you can contribute to the YN_Exchange project:
- Donate: If you've found my library to be useful, I would greatly appreciate it if you would consider making a donation. Your donation will help me to continue to develop and maintain the library, and to add new features in the future.
Donate function
YN_Exchange.DONATE()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file YnExchangePY-5.0.1.tar.gz
.
File metadata
- Download URL: YnExchangePY-5.0.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5590e87343c95a34978c8ec27b54aeb09b579fc2a23b515cb14fb8f09209b5cd |
|
MD5 | 83dc2e8682d893ffb742983462598d59 |
|
BLAKE2b-256 | 5b612ffc8370719ffe1d86de5af21fbbff265476759c6d971541be9599a6d540 |
File details
Details for the file YnExchangePY-5.0.1-py3-none-any.whl
.
File metadata
- Download URL: YnExchangePY-5.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24b36daae8f7bb42f8a08c2319713ff138790403b4db3751d36f24cd78fe04ab |
|
MD5 | d23354f6a08be9d01a5cd8c92344e35b |
|
BLAKE2b-256 | b16dbfe01734a582bd2af10e4e5283af792916ed34303b99fd8705c5f0007885 |