d crypto gateway interface ready to use
Project description
fastexchange
A type stated library, to handle crypto and currency exchange Right now very few currencies and cryptos are supported, but you can help with that with contribution.
- Github repository: https://github.com/ManiMozaffar/fastexchange/
Getting started
You can see the examples in examples/ folder, the library is type stated, which helps you alot with code interface. Make sure if you're using the library, your IDE's static type checker is on, otherwise you might get confused and take too much effort into debugging when you don't really need it. This is most advanced use case right now.
import asyncio
from rich import print
from fastexchange.converter.clients import CurrencyMeUkClient
from fastexchange.crypto.usdt import Trc20Gateway
from fastexchange.currency import EURCurrency
SOME_WALLET = ""
async def fn():
trc_client = Trc20Gateway()
transactions = await trc_client.check_transaction(SOME_WALLET)
this_transaction = transactions.token_transfers[1]
print(this_transaction) # show you the first transaction in API
usdt = this_transaction.to_token()
print(usdt) # show you the USDT value with type
usd = this_transaction.to_usd()
print(usd) # show you the USD value with type
exchange_client = CurrencyMeUkClient()
euro = await exchange_client.exchange(from_=usd, to=EURCurrency)
print(euro) # Converted value to EUR with type
if __name__ == "__main__":
asyncio.run(fn())
Crypto gateways, are gateway used to read from the blockchain. They might also offer support to determain value of a crypto currency. This is not yet implemented, but if you see the code, you'd see figure out how to implement it. DM me if you need help. Exchange clients are the clients used to
Contribution
Right now very few currencies and cryptos are supported, but you can help with that with contribution. Please make sure you're adherencing to the library principle, when contributing. The idea is that codes should be type stated, and you should avoid illegal state by using typing. You can read more about this here
Runtime Errors
Since library is type stated, that means if your IDE/static type checker doesn't complaint about your type, then it's gonna be ran fun. But there's only 1 edge case, which is when you're using converter client. You should explictly check if it's in mapping or not.
exchange_client = CurrencyMeUkClient()
euro = await exchange_client.exchange(from_=usd, to=NotSupportedCurrency)
Since this is a mapping inside each implementation of client, and each client may not support few currencies, then you'd run into exception ConverterNotMapped
. If you find a work-around, for this edge case, I'd happy to learn that from you :)
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 fastexchange-0.0.1.tar.gz
.
File metadata
- Download URL: fastexchange-0.0.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50e11a9e1bdedd86faa58a92396ac41994958cea21602ae803ec1e1f651a0efe |
|
MD5 | 545da166ae6f03b0a0a94d5299dc8635 |
|
BLAKE2b-256 | 624c5456835b4352e47430908ead85fcb08736bc6cb44bbf051fabcca13a4607 |
File details
Details for the file fastexchange-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: fastexchange-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.8 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d94c9f0bc1f619e009c0d8a9755b377c8137e2894802d19910253dc32accb3a4 |
|
MD5 | 068b87aeb23f91816371b0908b4dbda6 |
|
BLAKE2b-256 | 9153f0b303fbb3ce04077d01afdb3b428932ff62be5fd1ae8c497d95db7b74d6 |