marginpad 2.9.1__tar.gz → 3.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- marginpad-3.0.1/PKG-INFO +111 -0
- marginpad-3.0.1/README.md +91 -0
- {marginpad-2.9.1 → marginpad-3.0.1}/marginpad/__init__.py +37 -1
- marginpad-3.0.1/marginpad.egg-info/PKG-INFO +111 -0
- {marginpad-2.9.1 → marginpad-3.0.1}/pyproject.toml +2 -2
- {marginpad-2.9.1 → marginpad-3.0.1}/setup.cfg +4 -4
- marginpad-2.9.1/PKG-INFO +0 -76
- marginpad-2.9.1/README.md +0 -56
- marginpad-2.9.1/marginpad.egg-info/PKG-INFO +0 -76
- {marginpad-2.9.1 → marginpad-3.0.1}/marginpad.egg-info/SOURCES.txt +0 -0
- {marginpad-2.9.1 → marginpad-3.0.1}/marginpad.egg-info/dependency_links.txt +0 -0
- {marginpad-2.9.1 → marginpad-3.0.1}/marginpad.egg-info/requires.txt +0 -0
- {marginpad-2.9.1 → marginpad-3.0.1}/marginpad.egg-info/top_level.txt +0 -0
marginpad-3.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: marginpad
|
|
3
|
+
Version: 3.0.1
|
|
4
|
+
Summary: MarginPad Bot API client: free crypto-futures paper trading for bots (REST + WebSocket + webhooks) and free market data. No dependencies.
|
|
5
|
+
Author-email: MarginPad <support@marginpad.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://marginpad.io/trading-api/
|
|
8
|
+
Project-URL: Documentation, https://marginpad.io/api-docs/
|
|
9
|
+
Project-URL: Repository, https://github.com/Marginpad/sdk
|
|
10
|
+
Project-URL: Changelog, https://marginpad.io/api/changelog.xml
|
|
11
|
+
Keywords: crypto,futures,paper-trading,trading-bot,backtest,liquidations,api,mcp,ai-agent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Provides-Extra: stream
|
|
19
|
+
Requires-Dist: websockets>=11; extra == "stream"
|
|
20
|
+
|
|
21
|
+
# MarginPad SDK
|
|
22
|
+
|
|
23
|
+
Free crypto-futures **paper trading for bots** and free market data. One key, no KYC, no deposit.
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
- Guide: https://marginpad.io/trading-api/
|
|
27
|
+
- Reference (OpenAPI, try it live): https://marginpad.io/api-docs/
|
|
28
|
+
- Status: https://marginpad.io/status/ - Changelog: https://marginpad.io/api/changelog.xml
|
|
29
|
+
- MCP server for Claude, ChatGPT and Cursor: https://marginpad.io/trading-api/#mcp
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install marginpad # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
|
|
35
|
+
npm install marginpad # Node 18+, zero dependencies
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Python
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from marginpad import MarginPad
|
|
42
|
+
|
|
43
|
+
mp = MarginPad("mpb_...") # key from https://marginpad.io/trading-api/
|
|
44
|
+
print(mp.price("BTC")) # keyless market data
|
|
45
|
+
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
|
|
46
|
+
client_order_id="sig-2026-09-12-1403") # idempotent: a retry returns the same position
|
|
47
|
+
mp.sltp(pos["id"], trail_pct=1.5) # trailing stop, ratcheted server-side
|
|
48
|
+
print(mp.account())
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## JavaScript
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const { MarginPad } = require('marginpad');
|
|
55
|
+
const mp = new MarginPad('mpb_...');
|
|
56
|
+
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
|
|
57
|
+
mp.stream(ev => console.log(ev.type, ev.data)); // positions pushed on change, prices each tick
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## The simulation is yours to set
|
|
61
|
+
<!-- sdk-sim: generated, do not hand-edit -->
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
mp.sim() # your profile, every field with its range, the presets
|
|
67
|
+
mp.sim(preset="realistic") # the honest middle, in one call
|
|
68
|
+
mp.sim(preset="bybit") # Bybit's published taker fee and maintenance margin
|
|
69
|
+
mp.sim(preset="brutal") # refusals, partial fills, a second of latency
|
|
70
|
+
mp.sim(start_balance_usd=2500, margin_enforced=True, slippage_bps=8, latency_ms=250)
|
|
71
|
+
mp.sim(reset=True) # back to the defaults
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
await mp.sim({ preset: 'realistic' });
|
|
76
|
+
await mp.sim({ start_balance_usd: 2500, margin_enforced: true, reject_rate_pct: 2 });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
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`).
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
Every field with its range: https://marginpad.io/trading-api/#sim
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
- `examples/agent_loop.py`: a signal loop that opens, manages and closes positions once a minute without polling storms.
|
|
88
|
+
- `examples/webhook_server.js`: receive `position.closed` / `order.filled` events with signature verification.
|
|
89
|
+
- `examples/mcp.md`: let Claude Desktop or Cursor trade on your paper account through the MCP server.
|
|
90
|
+
|
|
91
|
+
## Limits
|
|
92
|
+
<!-- sdk-limits: generated from API_PLANS, do not hand-edit -->
|
|
93
|
+
|
|
94
|
+
| Plan | Requests/min | Keys | Open positions | Books | Webhooks |
|
|
95
|
+
|---|---|---|---|---|---|
|
|
96
|
+
| Free $0 | 120 | 3 | 50 | 1 | - |
|
|
97
|
+
| Pro $27 | 600 | 10 | 200 | 5 | 3 |
|
|
98
|
+
| Max $69 | 2000 | 30 | 500 | 20 | 15 |
|
|
99
|
+
| Business $139 | 5000 | 100 | 1000 | 50 | 50 |
|
|
100
|
+
|
|
101
|
+
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.
|
|
102
|
+
|
|
103
|
+
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.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
## Honesty note
|
|
108
|
+
|
|
109
|
+
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.
|
|
110
|
+
|
|
111
|
+
MIT licensed.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# MarginPad SDK
|
|
2
|
+
|
|
3
|
+
Free crypto-futures **paper trading for bots** and free market data. One key, no KYC, no deposit.
|
|
4
|
+
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.
|
|
5
|
+
|
|
6
|
+
- Guide: https://marginpad.io/trading-api/
|
|
7
|
+
- Reference (OpenAPI, try it live): https://marginpad.io/api-docs/
|
|
8
|
+
- Status: https://marginpad.io/status/ - Changelog: https://marginpad.io/api/changelog.xml
|
|
9
|
+
- MCP server for Claude, ChatGPT and Cursor: https://marginpad.io/trading-api/#mcp
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install marginpad # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
|
|
15
|
+
npm install marginpad # Node 18+, zero dependencies
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Python
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from marginpad import MarginPad
|
|
22
|
+
|
|
23
|
+
mp = MarginPad("mpb_...") # key from https://marginpad.io/trading-api/
|
|
24
|
+
print(mp.price("BTC")) # keyless market data
|
|
25
|
+
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
|
|
26
|
+
client_order_id="sig-2026-09-12-1403") # idempotent: a retry returns the same position
|
|
27
|
+
mp.sltp(pos["id"], trail_pct=1.5) # trailing stop, ratcheted server-side
|
|
28
|
+
print(mp.account())
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## JavaScript
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const { MarginPad } = require('marginpad');
|
|
35
|
+
const mp = new MarginPad('mpb_...');
|
|
36
|
+
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
|
|
37
|
+
mp.stream(ev => console.log(ev.type, ev.data)); // positions pushed on change, prices each tick
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## The simulation is yours to set
|
|
41
|
+
<!-- sdk-sim: generated, do not hand-edit -->
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
mp.sim() # your profile, every field with its range, the presets
|
|
47
|
+
mp.sim(preset="realistic") # the honest middle, in one call
|
|
48
|
+
mp.sim(preset="bybit") # Bybit's published taker fee and maintenance margin
|
|
49
|
+
mp.sim(preset="brutal") # refusals, partial fills, a second of latency
|
|
50
|
+
mp.sim(start_balance_usd=2500, margin_enforced=True, slippage_bps=8, latency_ms=250)
|
|
51
|
+
mp.sim(reset=True) # back to the defaults
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
await mp.sim({ preset: 'realistic' });
|
|
56
|
+
await mp.sim({ start_balance_usd: 2500, margin_enforced: true, reject_rate_pct: 2 });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
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`).
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
Every field with its range: https://marginpad.io/trading-api/#sim
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
- `examples/agent_loop.py`: a signal loop that opens, manages and closes positions once a minute without polling storms.
|
|
68
|
+
- `examples/webhook_server.js`: receive `position.closed` / `order.filled` events with signature verification.
|
|
69
|
+
- `examples/mcp.md`: let Claude Desktop or Cursor trade on your paper account through the MCP server.
|
|
70
|
+
|
|
71
|
+
## Limits
|
|
72
|
+
<!-- sdk-limits: generated from API_PLANS, do not hand-edit -->
|
|
73
|
+
|
|
74
|
+
| Plan | Requests/min | Keys | Open positions | Books | Webhooks |
|
|
75
|
+
|---|---|---|---|---|---|
|
|
76
|
+
| Free $0 | 120 | 3 | 50 | 1 | - |
|
|
77
|
+
| Pro $27 | 600 | 10 | 200 | 5 | 3 |
|
|
78
|
+
| Max $69 | 2000 | 30 | 500 | 20 | 15 |
|
|
79
|
+
| Business $139 | 5000 | 100 | 1000 | 50 | 50 |
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
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.
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
|
|
87
|
+
## Honesty note
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
MIT licensed.
|
|
@@ -21,7 +21,7 @@ import urllib.error
|
|
|
21
21
|
import urllib.parse
|
|
22
22
|
import urllib.request
|
|
23
23
|
|
|
24
|
-
__version__ = "
|
|
24
|
+
__version__ = "3.0.1"
|
|
25
25
|
__all__ = ["MarginPad", "MarginPadError", "verify_webhook"]
|
|
26
26
|
|
|
27
27
|
|
|
@@ -265,6 +265,42 @@ class MarginPad(object):
|
|
|
265
265
|
body["margin_venue"] = margin_venue
|
|
266
266
|
return self._post("/api/bot/v2/realism", **body)
|
|
267
267
|
|
|
268
|
+
# -- the whole simulation (3.0) ---------------------------------------------------------------------
|
|
269
|
+
SIM_PRESETS = ("frictionless", "realistic", "binance", "bybit", "okx", "hyperliquid",
|
|
270
|
+
"thin_book", "brutal")
|
|
271
|
+
|
|
272
|
+
def sim(self, **fields):
|
|
273
|
+
"""Read or set the WHOLE paper-trading simulation. realism() above is three switches of this one.
|
|
274
|
+
|
|
275
|
+
The defaults are deliberately easy - a market order fills whole at the live price, maintenance
|
|
276
|
+
margin is a flat 0.5%, the balance never refuses an open, and there is no latency, no size impact
|
|
277
|
+
and no partial fill. That is right for getting a bot RUNNING and optimistic for judging its edge.
|
|
278
|
+
|
|
279
|
+
c.sim() # your profile, every field with its range, the presets
|
|
280
|
+
c.sim(preset="realistic") # the honest middle, in one call
|
|
281
|
+
c.sim(preset="bybit") # Bybit's published fee and maintenance margin
|
|
282
|
+
c.sim(preset="brutal") # worse than anything real; surviving it means something
|
|
283
|
+
c.sim(start_balance_usd=2500, margin_enforced=True, slippage_bps=8, latency_ms=250)
|
|
284
|
+
c.sim(reset=True) # back to the defaults
|
|
285
|
+
|
|
286
|
+
The eighteen fields, in four groups:
|
|
287
|
+
the book start_balance_usd, margin_enforced, leverage_max, max_notional_usd
|
|
288
|
+
the fill slippage, slippage_bps, impact_bps_per_100k, exit_slippage, latency_ms,
|
|
289
|
+
partial_fills, min_fill_pct, reject_rate_pct
|
|
290
|
+
the cost taker_bps, funding, funding_mult
|
|
291
|
+
liquidation margin_venue, margin_tiers, mmr_pct
|
|
292
|
+
|
|
293
|
+
Out-of-range values are REFUSED, never clamped, so a strategy is never measured under a setting
|
|
294
|
+
you did not choose. A position keeps the simulation it was filled under, for life.
|
|
295
|
+
|
|
296
|
+
To CLEAR one of the three nullable fields (slippage_bps, taker_bps, mmr_pct) back to "use the
|
|
297
|
+
table / the venue", pass an empty string - this client drops None from a body, so None would
|
|
298
|
+
simply leave the field alone: c.sim(slippage_bps="")
|
|
299
|
+
"""
|
|
300
|
+
if not fields:
|
|
301
|
+
return self._get("/api/bot/v2/sim")
|
|
302
|
+
return self._post("/api/bot/v2/sim", **fields)
|
|
303
|
+
|
|
268
304
|
def webhooks(self):
|
|
269
305
|
return self._get("/api/bot/v2/webhooks")
|
|
270
306
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: marginpad
|
|
3
|
+
Version: 3.0.1
|
|
4
|
+
Summary: MarginPad Bot API client: free crypto-futures paper trading for bots (REST + WebSocket + webhooks) and free market data. No dependencies.
|
|
5
|
+
Author-email: MarginPad <support@marginpad.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://marginpad.io/trading-api/
|
|
8
|
+
Project-URL: Documentation, https://marginpad.io/api-docs/
|
|
9
|
+
Project-URL: Repository, https://github.com/Marginpad/sdk
|
|
10
|
+
Project-URL: Changelog, https://marginpad.io/api/changelog.xml
|
|
11
|
+
Keywords: crypto,futures,paper-trading,trading-bot,backtest,liquidations,api,mcp,ai-agent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Provides-Extra: stream
|
|
19
|
+
Requires-Dist: websockets>=11; extra == "stream"
|
|
20
|
+
|
|
21
|
+
# MarginPad SDK
|
|
22
|
+
|
|
23
|
+
Free crypto-futures **paper trading for bots** and free market data. One key, no KYC, no deposit.
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
- Guide: https://marginpad.io/trading-api/
|
|
27
|
+
- Reference (OpenAPI, try it live): https://marginpad.io/api-docs/
|
|
28
|
+
- Status: https://marginpad.io/status/ - Changelog: https://marginpad.io/api/changelog.xml
|
|
29
|
+
- MCP server for Claude, ChatGPT and Cursor: https://marginpad.io/trading-api/#mcp
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install marginpad # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
|
|
35
|
+
npm install marginpad # Node 18+, zero dependencies
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Python
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from marginpad import MarginPad
|
|
42
|
+
|
|
43
|
+
mp = MarginPad("mpb_...") # key from https://marginpad.io/trading-api/
|
|
44
|
+
print(mp.price("BTC")) # keyless market data
|
|
45
|
+
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
|
|
46
|
+
client_order_id="sig-2026-09-12-1403") # idempotent: a retry returns the same position
|
|
47
|
+
mp.sltp(pos["id"], trail_pct=1.5) # trailing stop, ratcheted server-side
|
|
48
|
+
print(mp.account())
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## JavaScript
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const { MarginPad } = require('marginpad');
|
|
55
|
+
const mp = new MarginPad('mpb_...');
|
|
56
|
+
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
|
|
57
|
+
mp.stream(ev => console.log(ev.type, ev.data)); // positions pushed on change, prices each tick
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## The simulation is yours to set
|
|
61
|
+
<!-- sdk-sim: generated, do not hand-edit -->
|
|
62
|
+
|
|
63
|
+
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.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
mp.sim() # your profile, every field with its range, the presets
|
|
67
|
+
mp.sim(preset="realistic") # the honest middle, in one call
|
|
68
|
+
mp.sim(preset="bybit") # Bybit's published taker fee and maintenance margin
|
|
69
|
+
mp.sim(preset="brutal") # refusals, partial fills, a second of latency
|
|
70
|
+
mp.sim(start_balance_usd=2500, margin_enforced=True, slippage_bps=8, latency_ms=250)
|
|
71
|
+
mp.sim(reset=True) # back to the defaults
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
await mp.sim({ preset: 'realistic' });
|
|
76
|
+
await mp.sim({ start_balance_usd: 2500, margin_enforced: true, reject_rate_pct: 2 });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
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`).
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
Every field with its range: https://marginpad.io/trading-api/#sim
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
- `examples/agent_loop.py`: a signal loop that opens, manages and closes positions once a minute without polling storms.
|
|
88
|
+
- `examples/webhook_server.js`: receive `position.closed` / `order.filled` events with signature verification.
|
|
89
|
+
- `examples/mcp.md`: let Claude Desktop or Cursor trade on your paper account through the MCP server.
|
|
90
|
+
|
|
91
|
+
## Limits
|
|
92
|
+
<!-- sdk-limits: generated from API_PLANS, do not hand-edit -->
|
|
93
|
+
|
|
94
|
+
| Plan | Requests/min | Keys | Open positions | Books | Webhooks |
|
|
95
|
+
|---|---|---|---|---|---|
|
|
96
|
+
| Free $0 | 120 | 3 | 50 | 1 | - |
|
|
97
|
+
| Pro $27 | 600 | 10 | 200 | 5 | 3 |
|
|
98
|
+
| Max $69 | 2000 | 30 | 500 | 20 | 15 |
|
|
99
|
+
| Business $139 | 5000 | 100 | 1000 | 50 | 50 |
|
|
100
|
+
|
|
101
|
+
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.
|
|
102
|
+
|
|
103
|
+
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.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
|
|
107
|
+
## Honesty note
|
|
108
|
+
|
|
109
|
+
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.
|
|
110
|
+
|
|
111
|
+
MIT licensed.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "marginpad"
|
|
7
|
-
version = "
|
|
7
|
+
version = "3.0.1"
|
|
8
8
|
description = "MarginPad Bot API client: free crypto-futures paper trading for bots (REST + WebSocket + webhooks) and free market data. No dependencies."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -19,7 +19,7 @@ stream = ["websockets>=11"]
|
|
|
19
19
|
[project.urls]
|
|
20
20
|
Homepage = "https://marginpad.io/trading-api/"
|
|
21
21
|
Documentation = "https://marginpad.io/api-docs/"
|
|
22
|
-
Repository = "https://github.com/
|
|
22
|
+
Repository = "https://github.com/Marginpad/sdk"
|
|
23
23
|
Changelog = "https://marginpad.io/api/changelog.xml"
|
|
24
24
|
|
|
25
25
|
[tool.setuptools.packages.find]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
marginpad-2.9.1/PKG-INFO
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: marginpad
|
|
3
|
-
Version: 2.9.1
|
|
4
|
-
Summary: MarginPad Bot API client: free crypto-futures paper trading for bots (REST + WebSocket + webhooks) and free market data. No dependencies.
|
|
5
|
-
Author-email: MarginPad <support@marginpad.io>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://marginpad.io/trading-api/
|
|
8
|
-
Project-URL: Documentation, https://marginpad.io/api-docs/
|
|
9
|
-
Project-URL: Repository, https://github.com/marginpad/sdk
|
|
10
|
-
Project-URL: Changelog, https://marginpad.io/api/changelog.xml
|
|
11
|
-
Keywords: crypto,futures,paper-trading,trading-bot,backtest,liquidations,api,mcp,ai-agent
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
15
|
-
Classifier: Intended Audience :: Developers
|
|
16
|
-
Requires-Python: >=3.8
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
Provides-Extra: stream
|
|
19
|
-
Requires-Dist: websockets>=11; extra == "stream"
|
|
20
|
-
|
|
21
|
-
# MarginPad SDK
|
|
22
|
-
|
|
23
|
-
Free crypto-futures **paper trading for bots** and free market data. One key, no KYC, no deposit.
|
|
24
|
-
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.
|
|
25
|
-
|
|
26
|
-
- Guide: https://marginpad.io/trading-api/
|
|
27
|
-
- Reference (OpenAPI, try it live): https://marginpad.io/api-docs/
|
|
28
|
-
- Status: https://marginpad.io/status/ - Changelog: https://marginpad.io/api/changelog.xml
|
|
29
|
-
- MCP server for Claude, ChatGPT and Cursor: https://marginpad.io/trading-api/#mcp
|
|
30
|
-
|
|
31
|
-
## Install
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
pip install marginpad # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
|
|
35
|
-
npm install marginpad # Node 18+, zero dependencies
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Python
|
|
39
|
-
|
|
40
|
-
```python
|
|
41
|
-
from marginpad import MarginPad
|
|
42
|
-
|
|
43
|
-
mp = MarginPad("mpb_...") # key from https://marginpad.io/trading-api/
|
|
44
|
-
print(mp.price("BTC")) # keyless market data
|
|
45
|
-
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
|
|
46
|
-
client_order_id="sig-2026-09-12-1403") # idempotent: a retry returns the same position
|
|
47
|
-
mp.sltp(pos["id"], trail_pct=1.5) # trailing stop, ratcheted server-side
|
|
48
|
-
print(mp.account())
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## JavaScript
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
const { MarginPad } = require('marginpad');
|
|
55
|
-
const mp = new MarginPad('mpb_...');
|
|
56
|
-
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
|
|
57
|
-
mp.stream(ev => console.log(ev.type, ev.data)); // positions pushed on change, prices each tick
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Examples
|
|
61
|
-
|
|
62
|
-
- `examples/agent_loop.py`: a signal loop that opens, manages and closes positions once a minute without polling storms.
|
|
63
|
-
- `examples/webhook_server.js`: receive `position.closed` / `order.filled` events with signature verification.
|
|
64
|
-
- `examples/mcp.md`: let Claude Desktop or Cursor trade on your paper account through the MCP server.
|
|
65
|
-
|
|
66
|
-
## Limits
|
|
67
|
-
|
|
68
|
-
Free: 120 requests/minute per key, 3 keys, 50 open positions. Premium: 600/minute, 10 keys, 200 open positions.
|
|
69
|
-
Every response carries `X-RateLimit-Limit / Remaining / Reset`; on 429 both clients wait `Retry-After` and retry once.
|
|
70
|
-
Out-of-range input is refused with a named error (`leverage_max` carries the market's cap), never silently clamped.
|
|
71
|
-
|
|
72
|
-
## Honesty note
|
|
73
|
-
|
|
74
|
-
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.
|
|
75
|
-
|
|
76
|
-
MIT licensed.
|
marginpad-2.9.1/README.md
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# MarginPad SDK
|
|
2
|
-
|
|
3
|
-
Free crypto-futures **paper trading for bots** and free market data. One key, no KYC, no deposit.
|
|
4
|
-
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.
|
|
5
|
-
|
|
6
|
-
- Guide: https://marginpad.io/trading-api/
|
|
7
|
-
- Reference (OpenAPI, try it live): https://marginpad.io/api-docs/
|
|
8
|
-
- Status: https://marginpad.io/status/ - Changelog: https://marginpad.io/api/changelog.xml
|
|
9
|
-
- MCP server for Claude, ChatGPT and Cursor: https://marginpad.io/trading-api/#mcp
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
pip install marginpad # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
|
|
15
|
-
npm install marginpad # Node 18+, zero dependencies
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Python
|
|
19
|
-
|
|
20
|
-
```python
|
|
21
|
-
from marginpad import MarginPad
|
|
22
|
-
|
|
23
|
-
mp = MarginPad("mpb_...") # key from https://marginpad.io/trading-api/
|
|
24
|
-
print(mp.price("BTC")) # keyless market data
|
|
25
|
-
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
|
|
26
|
-
client_order_id="sig-2026-09-12-1403") # idempotent: a retry returns the same position
|
|
27
|
-
mp.sltp(pos["id"], trail_pct=1.5) # trailing stop, ratcheted server-side
|
|
28
|
-
print(mp.account())
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## JavaScript
|
|
32
|
-
|
|
33
|
-
```js
|
|
34
|
-
const { MarginPad } = require('marginpad');
|
|
35
|
-
const mp = new MarginPad('mpb_...');
|
|
36
|
-
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
|
|
37
|
-
mp.stream(ev => console.log(ev.type, ev.data)); // positions pushed on change, prices each tick
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Examples
|
|
41
|
-
|
|
42
|
-
- `examples/agent_loop.py`: a signal loop that opens, manages and closes positions once a minute without polling storms.
|
|
43
|
-
- `examples/webhook_server.js`: receive `position.closed` / `order.filled` events with signature verification.
|
|
44
|
-
- `examples/mcp.md`: let Claude Desktop or Cursor trade on your paper account through the MCP server.
|
|
45
|
-
|
|
46
|
-
## Limits
|
|
47
|
-
|
|
48
|
-
Free: 120 requests/minute per key, 3 keys, 50 open positions. Premium: 600/minute, 10 keys, 200 open positions.
|
|
49
|
-
Every response carries `X-RateLimit-Limit / Remaining / Reset`; on 429 both clients wait `Retry-After` and retry once.
|
|
50
|
-
Out-of-range input is refused with a named error (`leverage_max` carries the market's cap), never silently clamped.
|
|
51
|
-
|
|
52
|
-
## Honesty note
|
|
53
|
-
|
|
54
|
-
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.
|
|
55
|
-
|
|
56
|
-
MIT licensed.
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: marginpad
|
|
3
|
-
Version: 2.9.1
|
|
4
|
-
Summary: MarginPad Bot API client: free crypto-futures paper trading for bots (REST + WebSocket + webhooks) and free market data. No dependencies.
|
|
5
|
-
Author-email: MarginPad <support@marginpad.io>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://marginpad.io/trading-api/
|
|
8
|
-
Project-URL: Documentation, https://marginpad.io/api-docs/
|
|
9
|
-
Project-URL: Repository, https://github.com/marginpad/sdk
|
|
10
|
-
Project-URL: Changelog, https://marginpad.io/api/changelog.xml
|
|
11
|
-
Keywords: crypto,futures,paper-trading,trading-bot,backtest,liquidations,api,mcp,ai-agent
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
15
|
-
Classifier: Intended Audience :: Developers
|
|
16
|
-
Requires-Python: >=3.8
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
Provides-Extra: stream
|
|
19
|
-
Requires-Dist: websockets>=11; extra == "stream"
|
|
20
|
-
|
|
21
|
-
# MarginPad SDK
|
|
22
|
-
|
|
23
|
-
Free crypto-futures **paper trading for bots** and free market data. One key, no KYC, no deposit.
|
|
24
|
-
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.
|
|
25
|
-
|
|
26
|
-
- Guide: https://marginpad.io/trading-api/
|
|
27
|
-
- Reference (OpenAPI, try it live): https://marginpad.io/api-docs/
|
|
28
|
-
- Status: https://marginpad.io/status/ - Changelog: https://marginpad.io/api/changelog.xml
|
|
29
|
-
- MCP server for Claude, ChatGPT and Cursor: https://marginpad.io/trading-api/#mcp
|
|
30
|
-
|
|
31
|
-
## Install
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
pip install marginpad # Python 3.8+, no dependencies (pip install "marginpad[stream]" for the WebSocket)
|
|
35
|
-
npm install marginpad # Node 18+, zero dependencies
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Python
|
|
39
|
-
|
|
40
|
-
```python
|
|
41
|
-
from marginpad import MarginPad
|
|
42
|
-
|
|
43
|
-
mp = MarginPad("mpb_...") # key from https://marginpad.io/trading-api/
|
|
44
|
-
print(mp.price("BTC")) # keyless market data
|
|
45
|
-
pos = mp.open("BTC", "long", margin_usd=100, leverage=10, sl=58000, tp=66000,
|
|
46
|
-
client_order_id="sig-2026-09-12-1403") # idempotent: a retry returns the same position
|
|
47
|
-
mp.sltp(pos["id"], trail_pct=1.5) # trailing stop, ratcheted server-side
|
|
48
|
-
print(mp.account())
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## JavaScript
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
const { MarginPad } = require('marginpad');
|
|
55
|
-
const mp = new MarginPad('mpb_...');
|
|
56
|
-
const { position } = await mp.open({ symbol: 'BTC', side: 'long', margin_usd: 100, leverage: 10, client_order_id: 'sig-1' });
|
|
57
|
-
mp.stream(ev => console.log(ev.type, ev.data)); // positions pushed on change, prices each tick
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Examples
|
|
61
|
-
|
|
62
|
-
- `examples/agent_loop.py`: a signal loop that opens, manages and closes positions once a minute without polling storms.
|
|
63
|
-
- `examples/webhook_server.js`: receive `position.closed` / `order.filled` events with signature verification.
|
|
64
|
-
- `examples/mcp.md`: let Claude Desktop or Cursor trade on your paper account through the MCP server.
|
|
65
|
-
|
|
66
|
-
## Limits
|
|
67
|
-
|
|
68
|
-
Free: 120 requests/minute per key, 3 keys, 50 open positions. Premium: 600/minute, 10 keys, 200 open positions.
|
|
69
|
-
Every response carries `X-RateLimit-Limit / Remaining / Reset`; on 429 both clients wait `Retry-After` and retry once.
|
|
70
|
-
Out-of-range input is refused with a named error (`leverage_max` carries the market's cap), never silently clamped.
|
|
71
|
-
|
|
72
|
-
## Honesty note
|
|
73
|
-
|
|
74
|
-
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.
|
|
75
|
-
|
|
76
|
-
MIT licensed.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|