Crypto Unified Exchange Adapters — async-first unified models and modular exchange adapters.
Project description
cuea — Crypto Unified Exchange Adapters
Lightweight async adapters that present a small, unified interface over exchange REST/WS endpoints. Designed for algorithmic trading tools and integration tests.
Install
pip install cuea
Quick start (async)
import asyncio
from cuea.registry import get_exchange_adapter
async def main():
# create adapter for binance (spot + futures available)
adapter = get_exchange_adapter("binance", api_key="...", secret="...")
ticker = await adapter.spot.fetch_ticker("BTC/USDT")
print(ticker)
await adapter.close()
asyncio.run(main())
Unified client helper (recommended)
import asyncio
from cuea import UnifiedClient
async def example():
async with UnifiedClient("binance", api_key="k", secret="s") as c:
t = await c.fetch_ticker("BTC/USDT")
print(t)
# place a limit order (spot)
# await c.place_limit_order("BTC/USDT", "buy", qty="0.001", price="30000")
asyncio.run(example())
You can also import the class directly:
from cuea import UnifiedClient
async with UnifiedClient("binance") as c:
...
Features
- Async HTTP transport with retries, backoff and optional token-bucket rate limiter.
- Adapters for
binanceandbybit(spot and futures stubs exist). - Canonical models:
Ticker,OrderRequest,Order,Balance,Trade,Position. - Private user-data websocket helpers with listen-key lifecycle managed.
API highlights
get_exchange_adapter(name, api_key=None, secret=None, config=None) -> ExchangeAdapterlist_adapters() -> list[str]UnifiedClient(exchange, api_key=None, secret=None, config=None)— convenience wrapperfetch_ticker(symbol)place_limit_order(market, side, qty, price, market_type="spot")place_market_order(...)fetch_open_orders(symbol=None, market_type="spot")fetch_positions(symbol=None, market_type="futures")subscribe_trades(symbols, market_type="spot") -> AsyncIterator[Trade]- async context manager and
close()support
See inline docstrings in src/cuea for more details.
Configuration
- Environment helper:
cuea.config.get_exchange_adapter_from_env(...) .envexample:configs/.env.example- Per-exchange config example:
configs/default.yaml- override
base_url,rate_limit,max_retries, etc.
- override
Tests & linters
Run locally:
pip install -e . pytest ruff mypy
pytest -q
ruff check .
mypy src
Contributing
See CONTRIBUTING.md for the contribution workflow, design notes and testing expectations.
Notes & roadmap
- Options adapters are stubs. Implement only when you need options mappings.
marketspecintegration is optional and applied at runtime if available.- Models use
pydanticfor clear validation.
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cuea-0.1.1.tar.gz.
File metadata
- Download URL: cuea-0.1.1.tar.gz
- Upload date:
- Size: 37.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7332500dd36db2f93f401ebfeb5acb42066d263445d6fde58ce9a3760fe019bd
|
|
| MD5 |
73868737103330ca841bb7fb4effb9aa
|
|
| BLAKE2b-256 |
a39f65816efae8a45bed74058d73ec4052009e05aa5e3a5d6d53a871278b6f99
|
File details
Details for the file cuea-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cuea-0.1.1-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20d2097dc59227a2f36d5dc03ecf0f69b6b8210c882b4f8099eafe5fa2d649c4
|
|
| MD5 |
4af9282984923f82d7448119ede90a97
|
|
| BLAKE2b-256 |
844e145fa36ee8e9572eb11534c5d9026eaa25260a24df58a4dca675810c6939
|