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), with address set to the master. 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) 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.2.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.2.0
File Size Uploaded Provenance Actions
tribulnation_margin_trade-0.2.0.tar.gz 18.4 kB With provenance Details for tribulnation_margin_trade-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 39.8 kB

Release files / tribulnation_margin_trade-0.2.0.tar.gz

Download URL tribulnation_margin_trade-0.2.0.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c5224e6622133f93b1627f87936bcdbddface367b29a0177f667400324886b53
BLAKE2b-256 checksum
How to use checksums
4c2fdf246a688462efc80b4c42e0afa6a2e534e186a0a64ebbcd9d3387cd240d
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 Oct 27, 2026.

Transparency log

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

Download URL tribulnation_margin_trade-0.2.0-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57ce9d26eb0cdb4c14479f72fb06cfb93c13dd6773e9584e047b682849e451a6
BLAKE2b-256 checksum
How to use checksums
33c9f845a9f3bff4848f19a0299164525f2d59d5c5ea06f892c6cc97f996aac3
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 Oct 27, 2026.

Transparency log

Security for tribulnation-margin-trade 0.2.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.2.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 Oct 27, 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