Skip to main content

MarginPad SDK

Free crypto-futures paper trading for bots and free market data. One key, no KYC, no deposit. Test a strategy or an AI agent against live prices with real fee schedules, funding, liquidations, limit and stop orders, trailing stops, webhooks and a WebSocket stream, then take the same code to a real exchange.

Install

pip install marginpad            # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
npm install marginpad            # Node 18+, zero dependencies

Python

from marginpad import MarginPad

mp = MarginPad("mpb_...")                                   # key from https://marginpad.io/trading-api/
print(mp.price("BTC"))                                      # keyless market data
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
              client_order_id="sig-2026-09-12-1403")        # idempotent: a retry returns the same position
mp.sltp(pos["id"], trail_pct=1.5)                           # trailing stop, ratcheted server-side
print(mp.account())

JavaScript

const { MarginPad } = require('marginpad');
const mp = new MarginPad('mpb_...');
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
mp.stream(ev => console.log(ev.type, ev.data));             // positions pushed on change, prices each tick

The simulation is yours to set

Eighteen fields and eight presets, so the paper venue can be the one you will actually trade. The defaults are deliberately frictionless, and nothing you have already built moves until you change them.

mp.sim()                                   # your profile, every field with its range, the presets
mp.sim(preset="realistic")                 # the honest middle, in one call
mp.sim(preset="bybit")                     # Bybit's published taker fee and maintenance margin
mp.sim(preset="brutal")                    # refusals, partial fills, a second of latency
mp.sim(start_balance_usd=2500, margin_enforced=True, slippage_bps=8, latency_ms=250)
mp.sim(reset=True)                         # back to the defaults
await mp.sim({ preset: 'realistic' });
await mp.sim({ start_balance_usd: 2500, margin_enforced: true, reject_rate_pct: 2 });

The book (start_balance_usd, margin_enforced, leverage_max, max_notional_usd), the fill (slippage, slippage_bps, impact_bps_per_100k, exit_slippage, latency_ms, partial_fills, min_fill_pct, reject_rate_pct), the cost (taker_bps, funding, funding_mult) and the liquidation (margin_venue, margin_tiers, mmr_pct).

Out-of-range values are refused, never clamped, and a position keeps the simulation it was filled under for life. margin_enforced turns the balance into a real budget: size past it and the open comes back 402, which is the failure a live bot has to handle and a frictionless simulator never shows you. reject_rate_pct is the one a retry loop is worth writing for.

Every field with its range: https://marginpad.io/trading-api/#sim

Examples

  • examples/agent_loop.py: a signal loop that opens, manages and closes positions once a minute without polling storms.
  • examples/webhook_server.js: receive position.closed / order.filled events with signature verification.
  • examples/mcp.md: let Claude Desktop or Cursor trade on your paper account through the MCP server.

Limits

Plan Requests/min Keys Open positions Books Webhooks
Free $0 120 3 50 1 -
Pro $27 600 10 200 5 3
Max $69 2000 30 500 20 15
Business $139 5000 100 1000 50 50

An API plan is its own product: a MarginPad Premium subscription buys nothing here, and an API plan buys nothing on the site. Every market-data endpoint is free and keyless, with no account and no trial. The paper-trading engine, the simulation, books, replay and the WebSocket stream are free for 7 days from the day the first key is minted (since 2026-10-13); after that they need a paid plan, and only webhooks and the AI read are gated by tier within it. Trade history is 30 days on the trial and 90 on a paid plan.

Measured in production: the busiest bot peaks at 66 requests a minute against the Free ceiling of 120, and no key has ever been rate-limited on any plan. Choose on keys and history, not on throughput.

Every response carries X-RateLimit-Limit / Remaining / Reset; on 429 both clients wait Retry-After and retry once. Out-of-range input is refused with a named error (leverage_max carries the market's cap), never silently clamped.

Honesty note

This is a simulator. Fees, funding and liquidation maths mirror real exchanges and every fill condition above is yours to set - but there is no order book behind impact_bps_per_100k, so market impact is modelled rather than measured on depth, and a stop, target or liquidation fills at its own level without paying the crossing cost. A bot that passes here still needs a small live test. Educational use, not financial advice.

MIT licensed.

Metadata

Release files for marginpad 3.0.1

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

Source distribution (sdist)

Source distribution for marginpad 3.0.1
File Size Uploaded Provenance
marginpad-3.0.1.tar.gz 9.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for marginpad 3.0.1
File Interpreter ABI Platform
marginpad-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / marginpad-3.0.1.tar.gz

Download URL marginpad-3.0.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c1e285708cff233d3fc4c5de519c8b7bc829e02b7048b9414d899ddb0ce5f7ef
BLAKE2b-256 checksum
How to use checksums
8162f8ff9fee095ace4e1974a37dd7c81bd614b3df39e9647ff6f16d6e7fc210
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 25, 2026.

Transparency log

Release files / marginpad-3.0.1-py3-none-any.whl

Download URL marginpad-3.0.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c027c97da8dd44646f9dfee7a954fba5f1eb8953d129faeb807ed8cacf866ffd
BLAKE2b-256 checksum
How to use checksums
c976781acbdd193fe60117611191b0e03dc384cd14e972dea95c56c85f4caebf
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 25, 2026.

Transparency log

Security for marginpad 3.0.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for marginpad-3.0.1.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 25, 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