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

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

Free: 120 requests/minute per key, 3 keys, 50 open positions. Premium: 600/minute, 10 keys, 200 open positions. 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 math mirror real exchanges; there is no order book, so slippage is modelled, not measured on depth. A bot that passes here still needs a small live test. Educational use, not financial advice.

MIT licensed.

Release files for marginpad 2.9.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 2.9.1
File Size Uploaded
marginpad-2.9.1.tar.gz 7.3 kB Details

Built distribution (wheel)

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

Total release size: 14.7 kB

Release files / marginpad-2.9.1.tar.gz

Download URL marginpad-2.9.1.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
00a6da35c8f2caa556616f7470115cc0199873fbbd573f4ac17b32a586133fcb
BLAKE2b-256 checksum
How to use checksums
1061b79db9e5afb480e35fa90c42e5b44615a0ca5ff073169059eb9027b792b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

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

Download URL marginpad-2.9.1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d340720fedbb1ad99e1e037edb94701ebe0bd0d0d93ff593d19d7fec86b96f62
BLAKE2b-256 checksum
How to use checksums
18755001b251ec97d529bead2674141061abbf86ce31ec1d470738276d7668ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

2.9.1 This release

2 release files

2.9.0

2 release files

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