An abstract, fully-typed, async Python SDK for automated crypto trading. By Tribulnation.
Project description
Tribulnation SDK
An abstract, fully-typed, async Python SDK for automated crypto trading.
Trading Quick Start
from tribulnation.sdk import TradingSDK
sdk = TradingSDK()
mexc = await sdk.market('mexc:spot:BTCUSDT')
dydx = await sdk.market('dydx:perp:BTC-USD')
async for my_trade in mexc.trades_stream():
print(f'Hedging {my_trade}')
await dydx.place_order({
'type': 'LIMIT',
'qty': -my_trade.qty,
'price': my_trade.price,
})
Installation
pip install tribulnation-sdk[mexc, dydx, hyperliquid]
Supported Venues
mexc: MEXCdydx: dYdXhyperliquid: Hyperliquid
Enumerating Venues/Exchanges/Markets
venues = await sdk.venues()
venue = await sdk.venue(venues[0])
exchanges = await venue.exchanges()
exchange = await venue.exchange(exchanges[0])
markets = await exchange.markets()
market = await exchange.market(markets[0])
Market IDs
Market IDs have this form: <venue_id>:<exchange_id>:<market_id>.
You can also scope. These are equivalent:
- Directly on the SDK:
await sdk.book('mexc:spot:BTCUSDT')
- By venue:
venue = await sdk.venue('mexc')
await venue.book('spot:BTCUSDT')
- By exchange:
exchange = await venue.exchange('spot')
await exchange.book('BTCUSDT')
- By market:
market = await exchange.market('BTCUSDT')
await market.depth()
Market Interface
- Public data:
depth() -> Book: order bookdepth_stream() -> Stream[Book]: real-time order book updatesrules() -> Rules: market rules (tick size, fees, etc.)
- User data:
query_order(id: str) -> OrderState | Noneopen_orders() -> Sequence[OrderState]trades_history(start: datetime, end: datetime) -> AsyncIterable[Sequence[Trade]]trades_stream() -> Stream[Trade]: real-time user tradesposition() -> Position: base-asset position
- Trading:
place_order(order: Order) -> OrderResponseplace_orders(orders: Sequence[Order]) -> Sequence[OrderResponse]cancel_order(id: str) -> Anycancel_orders(ids: Sequence[str])cancel_open_orders()
- Perpetual markets:
index() -> Decimal: index pricenext_funding() -> FundingRate: next funding ratefunding_history(start: datetime, end: datetime) -> AsyncIterable[Sequence[FundingRate]]: market funding rate historyfunding_payments(start: datetime, end: datetime) -> AsyncIterable[Sequence[FundingPayment]]: your funding payments historyposition() -> PerpPosition: open base-asset position, including the entry price
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
tribulnation_sdk-1.1.11.tar.gz
(26.4 kB
view details)
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 tribulnation_sdk-1.1.11.tar.gz.
File metadata
- Download URL: tribulnation_sdk-1.1.11.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfea9d29339e15e0dcfee44614964565169f7793a3f6576a59a96b2f7657f7f2
|
|
| MD5 |
7ebd98fd923c826e6fa41550e7b4544d
|
|
| BLAKE2b-256 |
369b50711d07f66adc5b64f48315e41de0a6e1f2a6a635e3d1148b1b7f297f4a
|
File details
Details for the file tribulnation_sdk-1.1.11-py3-none-any.whl.
File metadata
- Download URL: tribulnation_sdk-1.1.11-py3-none-any.whl
- Upload date:
- Size: 39.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cf2249867f6becc03959293d6baa2b00f938506ee78863f6e92830bbdceaeba
|
|
| MD5 |
f4cd409821e9305f6ef2c9189cb7a8a2
|
|
| BLAKE2b-256 |
80b274b5cb6a5dd406f8bda2a4596db5e2a172c12b80ce4855bdba5f821c34ea
|