Skip to main content

margin.trade SDK

Spot and USDC-margined perpetual Market support, and Report snapshots and history, for margin.trade, built on typed-margin-trade. Install with pip install tribulnation-margin-trade.

from tribulnation.margin_trade import MarginTradeMarket

async with MarginTradeMarket.new() as venue:
  market = await venue.perp.market('BTC')
  book = await market.depth(levels=5)

Accounts are Solana Ed25519 keys; the account is the master key's base58 address. Trading needs the master's key or an approved agent's (API wallet). Entering a signed venue asks the venue for the key's master account: address, when set, must be it (else AuthError), and when omitted the master is used. Account reads are by address and need no key:

venue = MarginTradeMarket.new(address='6dm8…', private_key='<agent key>', mainnet=False)
reads = MarginTradeMarket.new(address='6dm8…')
  1. Exchanges are perp (coin names such as BTC, XAU, NVDA) and spot (pair names such as PEARL/USDC). Asset ids are token symbols (USDC, PEARL); perpetual fees are charged in USD.
  2. Public data: discovery, tickers (24h volumes, plus last and best bid/ask where the venue's CoinGecko feed lists the market), rules with each market's own fee rates, REST depth and shared l2Book depth streams, candles in the six SDK intervals, perpetual index (oracle price), next funding (hourly) and perp_stats. No funding-rate history: the venue serves placeholder data.
  3. Account and trading: order queries, open orders, trade history (per market or exchange-wide) and per-coin fill streams, positions, cross collateral, leverage, available notional, perpetual funding payments, and MARKET (an Ioc limit), LIMIT (Gtc, or settings={'margin-trade': {'limit_tif': 'Ioc'}}) and POST_ONLY (Alo) orders with every cancellation method. Order placement is verified on testnet only. fees is unsupported: the venue's account rate is not what fills are charged.
  4. Report: a perp subaccount (USDC without unrealized PnL, positions) and a spot subaccount (token totals); history of fills, funding and transfers (on-chain deposits and withdrawals on solana or pearl, perp/spot transfers).
  5. Streams need typed-margin-trade 0.1.1 or later, which pings every 10 s: the venue drops a connection about 30 s after the client's last ping.

Metadata

Release files for tribulnation-margin-trade 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tribulnation-margin-trade 0.4.0
File Size Uploaded Provenance Actions
tribulnation_margin_trade-0.4.0.tar.gz 21.0 kB With provenance Details for tribulnation_margin_trade-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tribulnation-margin-trade 0.4.0
File Interpreter ABI Platform Actions
tribulnation_margin_trade-0.4.0-py3-none-any.whl Python 3 none any Details for tribulnation_margin_trade-0.4.0-py3-none-any.whl

Total release size: 44.9 kB

Release files / tribulnation_margin_trade-0.4.0.tar.gz

Download URL tribulnation_margin_trade-0.4.0.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
47cad68120011cb9de5bdf03963920dc4ecba657ac6154ba6c6a1504a731eb00
BLAKE2b-256 checksum
How to use checksums
9a7ccee2bd072cbcdea18182e5500b3926674e57abcdbbbb5728c5135255413f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / tribulnation_margin_trade-0.4.0-py3-none-any.whl

Download URL tribulnation_margin_trade-0.4.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ec61962086d7b31c8b88cf659d80705aa377a642f4664aa4d5a8c7729db59ab
BLAKE2b-256 checksum
How to use checksums
a687061cb2c541790791fa96d3bce3e5b4898962d74174c36718abcd28b2a2b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for tribulnation-margin-trade 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tribulnation_margin_trade-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page