Skip to main content

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

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:

  1. Directly on the SDK:
await sdk.book('mexc:spot:BTCUSDT')
  1. By venue:
venue = await sdk.venue('mexc')
await venue.book('spot:BTCUSDT')
  1. By exchange:
exchange = await venue.exchange('spot')
await exchange.book('BTCUSDT')
  1. By market:
market = await exchange.market('BTCUSDT')
await market.depth()

Market Interface

  • Public data:
    • depth() -> Book: order book
    • depth_stream() -> Stream[Book]: real-time order book updates
    • rules() -> Rules: market rules (tick size, fees, etc.)
  • User data:
    • query_order(id: str) -> OrderState | None
    • open_orders() -> Sequence[OrderState]
    • trades_history(start: datetime, end: datetime) -> AsyncIterable[Sequence[Trade]]
    • trades_stream() -> Stream[Trade]: real-time user trades
    • position() -> Position: base-asset position
  • Trading:
    • place_order(order: Order) -> OrderResponse
    • place_orders(orders: Sequence[Order]) -> Sequence[OrderResponse]
    • cancel_order(id: str) -> Any
    • cancel_orders(ids: Sequence[str])
    • cancel_open_orders()
  • Perpetual markets:
    • index() -> Decimal: index price
    • next_funding() -> FundingRate: next funding rate
    • funding_history(start: datetime, end: datetime) -> AsyncIterable[Sequence[FundingRate]]: market funding rate history
    • funding_payments(start: datetime, end: datetime) -> AsyncIterable[Sequence[FundingPayment]]: your funding payments history
    • position() -> PerpPosition: open base-asset position, including the entry price

Project details


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.1.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tribulnation_sdk-1.1.1-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file tribulnation_sdk-1.1.1.tar.gz.

File metadata

  • Download URL: tribulnation_sdk-1.1.1.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for tribulnation_sdk-1.1.1.tar.gz
Algorithm Hash digest
SHA256 4386f99074f2e3f4f02f97a61020912943afe8bd5bdd3baf6b28dafde78bc17c
MD5 82a20dd96ea7a98d6b08fca4ef7ea408
BLAKE2b-256 73a9fa4b51ee769985f7f2fccfa694cf7f3444da2ebf9613c9ac8fb4fc85a752

See more details on using hashes here.

File details

Details for the file tribulnation_sdk-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tribulnation_sdk-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1dd0aa9896ace304e0d8b8f719e4bc40a9882eb32cd4a85d9141b6867f529c41
MD5 c93ade4f134437b60277b0174164bc9b
BLAKE2b-256 d6b9fae25b97569f9c5b1f8f6ddbc7136f5d265726b81aafbc418b79e31ea3d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page