Metadata-Version: 2.4
Name: tribulnation-sdk
Version: 4.5.0
Summary: An abstract, fully-typed, async Python SDK for automated crypto trading. By Tribulnation.
Author-email: Marcel Claramunt <marcel@tribulnation.com>
License-Expression: MIT
Project-URL: Github, https://github.com/tribulnation/sdk.git
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: tribulnation-cli<1,>=0.1.0
Requires-Dist: lazy-loader
Requires-Dist: typing-extensions
Requires-Dist: typed-core>=0.8.1
Requires-Dist: tomli>=1.1.0; python_version < "3.11"
Provides-Extra: gateway
Requires-Dist: aiohttp<4,>=3.12; extra == "gateway"
Requires-Dist: msgspec<1,>=0.23; extra == "gateway"
Requires-Dist: python-dotenv<2,>=1; extra == "gateway"
Provides-Extra: aster
Requires-Dist: tribulnation-aster>=0.16.1; extra == "aster"
Provides-Extra: extended
Requires-Dist: tribulnation-extended>=0.5.2; extra == "extended"
Provides-Extra: lighter
Requires-Dist: tribulnation-lighter>=0.15.1; extra == "lighter"
Provides-Extra: margin-trade
Requires-Dist: tribulnation-margin-trade>=0.4.1; extra == "margin-trade"
Provides-Extra: grvt
Requires-Dist: tribulnation-grvt>=0.5.1; extra == "grvt"
Provides-Extra: nado
Requires-Dist: tribulnation-nado>=0.2.1; extra == "nado"
Provides-Extra: risex
Requires-Dist: tribulnation-risex>=0.2.1; extra == "risex"
Provides-Extra: evedex
Requires-Dist: tribulnation-evedex>=0.1.0; extra == "evedex"
Provides-Extra: mexc
Requires-Dist: tribulnation-mexc>=3.0.2; extra == "mexc"
Provides-Extra: dydx
Requires-Dist: tribulnation-dydx>=0.22.1; extra == "dydx"
Provides-Extra: hyperliquid
Requires-Dist: tribulnation-hyperliquid>=0.22.2; extra == "hyperliquid"
Provides-Extra: binance
Requires-Dist: tribulnation-binance>=0.9.1; extra == "binance"
Provides-Extra: bitget
Requires-Dist: tribulnation-bitget>=0.15.0; extra == "bitget"
Provides-Extra: bit2me
Requires-Dist: tribulnation-bit2me>=0.10.2; extra == "bit2me"
Provides-Extra: ethereum
Requires-Dist: tribulnation-ethereum>=0.6.2; extra == "ethereum"
Provides-Extra: bybit
Requires-Dist: tribulnation-bybit>=0.10.3; extra == "bybit"
Provides-Extra: coinbase
Requires-Dist: tribulnation-coinbase>=0.6.2; extra == "coinbase"
Provides-Extra: kraken
Requires-Dist: tribulnation-kraken>=0.9.2; extra == "kraken"
Provides-Extra: kucoin
Requires-Dist: tribulnation-kucoin>=0.10.0; extra == "kucoin"
Provides-Extra: deribit
Requires-Dist: tribulnation-deribit>=0.7.1; extra == "deribit"
Dynamic: license-file

# Tribulnation SDK

[![PyPI](https://img.shields.io/pypi/v/tribulnation-sdk.svg)](https://pypi.org/project/tribulnation-sdk/)
[![Python versions](https://img.shields.io/pypi/pyversions/tribulnation-sdk.svg)](https://pypi.org/project/tribulnation-sdk/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/tribulnation/sdk/blob/main/LICENSE)
[![Check](https://github.com/tribulnation/sdk/actions/workflows/check.yml/badge.svg)](https://github.com/tribulnation/sdk/actions/workflows/check.yml)

One async, typed Python interface for trading and market data across crypto exchanges and chains.

## Why use it

- **🎯 One interface for 20 venues.** Code written against `Market`, `Earn`, `Wallet` and `Report` runs on any venue that implements them. To switch venues, or run several accounts on one venue, you change the ID string.
- **🛡️ Validated responses.** Each venue adapter is built on a [Typed](https://tribulnation.com/typed) client, so venue responses are checked before they reach your code.
- **🔢 `Decimal` and `datetime`.** Prices, sizes and fees are `Decimal`, and timestamps are timezone-aware `datetime`. No floats, no epoch integers.
- **📈 Spot, margin and perpetual markets.** The types tell them apart: perpetuals add funding and index price, margin markets add borrow interest.
- **📊 Reports from exchanges and chains.** `Report` reads balance and position history, `Earn` lists yield products, and `Wallet` covers deposits and withdrawals.

## Install

```bash
pip install 'tribulnation-sdk[hyperliquid]'
```

Each extra installs one venue adapter, for example `[hyperliquid,mexc,binance]`. The [support matrix](https://tribulnation.com/sdk/docs/support) shows what each venue implements.

## Quickstart

Read Hyperliquid's BTC order book and next funding rate. Public data needs no API keys:

```python
import asyncio
from tribulnation.sdk import MarketSDK, accounts

sdk = MarketSDK({'hl': accounts.Hyperliquid(public=True)})

async def main():
  book = await sdk.depth('hl::BTC')
  print('best bid:', book.best_bid)
  print('best ask:', book.best_ask)
  print(await sdk.next_funding('hl::BTC'))

asyncio.run(main())
```

```
best bid: [59976.0] 3.75746 ($225357.420960)
best ask: [59977.0] 2.10861 ($126468.101970)
NextFunding(rate=Decimal('0.0000059229'), time=datetime.datetime(2026, 11, 27, 17, 0, tzinfo=datetime.timezone(datetime.timedelta(0), 'UTC')), premium=None, interval=datetime.timedelta(seconds=3600))
```

`'hl'` is the account ID you chose, and `'hl::BTC'` is a market ID of the form `<account>:<exchange>:<market>`. An empty exchange part means Hyperliquid's default perpetuals exchange. See [Market IDs](https://tribulnation.com/sdk/docs/market/identifiers) for the format on each venue.

## Your own accounts

For trading and account data, list your accounts in a TOML file. `$VAR` values are read from the environment:

```toml
# sdk.toml
[accounts.hl]
venue = "hyperliquid"
public = true

[accounts.mexc_account1]
venue = "mexc"
api_key = "$MEXC_API_KEY"
api_secret = "$MEXC_API_SECRET"
```

```python
from tribulnation.sdk import MarketSDK

sdk = MarketSDK.load('sdk.toml')
```

A missing variable fails when the file loads (`ValueError: Environment variable MEXC_API_KEY is not set`), before any request goes out. The MEXC account needs the `mexc` extra. From here, [Your First Order](https://tribulnation.com/sdk/docs/market/first-order) walks through reading rules, sizing, placing and cancelling an order.

## Documentation

- [Market](https://tribulnation.com/sdk/docs/market): order books, rules, orders, positions, funding
- [Earn](https://tribulnation.com/sdk/docs/earn): yield products across venues
- [Wallet](https://tribulnation.com/sdk/docs/wallet): deposit and withdrawal methods
- [Report](https://tribulnation.com/sdk/docs/report): balance and position history
- [Reference](https://tribulnation.com/sdk/docs/reference): async usage, errors, logging and retries
- [Support matrix](https://tribulnation.com/sdk/docs/support): what each venue implements

## Status

Beta. The core package (`tribulnation-sdk`) and each venue adapter (`tribulnation-<venue>`) have their own version numbers and are released separately. Release notes are on the [GitHub releases page](https://github.com/tribulnation/sdk/releases). Questions and bug reports go to [GitHub issues](https://github.com/tribulnation/sdk/issues).

## Contributing

See [CONTRIBUTING.md](https://github.com/tribulnation/sdk/blob/main/CONTRIBUTING.md) for the repository layout, commands and release flow. Maintainer guides and architecture decisions are in the [developer documentation](https://github.com/tribulnation/sdk/blob/main/dev-docs/README.md).

## License

[MIT](https://github.com/tribulnation/sdk/blob/main/LICENSE)
