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.3.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.3.0
File Size Uploaded Provenance Actions
tribulnation_margin_trade-0.3.0.tar.gz 20.5 kB With provenance Details for tribulnation_margin_trade-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 43.9 kB

Release files / tribulnation_margin_trade-0.3.0.tar.gz

Download URL tribulnation_margin_trade-0.3.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4f8b290ac26bd89e21aa9634036a3bcfbe46d9e8f813d432ac84370610594133
BLAKE2b-256 checksum
How to use checksums
b58e4dc441f9366423f7edb12c986b04fdb3dcccc783121a9b3618ff82b70bbf
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 4, 2026.

Transparency log

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

Download URL tribulnation_margin_trade-0.3.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efeefb0360fa4b06d49b1484f1eb0dd7c1e3088fc1832367448568e4c29e2aa2
BLAKE2b-256 checksum
How to use checksums
f197308757a864e16fb1b15aaf299f5cb7b7a1d1f299c79c500fb68ce2ca6ded
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 4, 2026.

Transparency log

Security for tribulnation-margin-trade 0.3.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.3.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 4, 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