Sdk

io.github.Marginpadv2.9.1更新於 Oct 8, 2026

Free crypto-futures paper trading and live market data for AI agents. 28 tools; no key for data.

已驗證Streamable HTTP可網頁執行AI & MLFinance

概覽

AI 產生的概覽

讓助理取得加密貨幣期貨即時行情,並以模擬資金進行紙上交易,包含手續費、資金費、強制平倉與停損。

功能
這是一個遠端 MCP 伺服器,用於加密貨幣期貨紙上交易與行情資料,說明中稱有 28 個工具。行情類工具不需金鑰即可使用;交易類工具可開倉與管理模擬部位,支援槓桿、限價單與停損單、移動停損,以及帳戶、權益曲線與回放檢視。它也支援同一帳戶下的多個交易帳簿,以及用歷史某日K線重跑相同呼叫的回放模式。
適用情境
適合讓助理在不冒真實資金風險的情況下,用即時價格測試交易策略或代理迴圈,也適合在對話中取得加密貨幣期貨報價與帳戶狀態。它是模擬器,結果在實際使用前仍需小額實盤驗證。
執行需求
透過 streamable HTTP 連線 marginpad.io 的遠端端點,不需在本機安裝套件。行情工具不需要憑證。交易工具需要在 X-API-Key 標頭中提供 MarginPad Bot API 金鑰。免費額度限制:每個金鑰每分鐘 120 次請求、3 個金鑰、50 個未平倉部位。
安裝前請注意
X-API-Key 標頭攜帶 MarginPad Bot API 金鑰(mpb_...),可對帳戶的模擬帳簿執行交易操作,應視為機密保管。交易工具會開倉、修改與平倉,並可重設帳簿;這些操作針對模擬資金,不涉及真實資金。此伺服器是模擬器:手續費、資金費與強制平倉為模型計算,滑價為估算而非依真實深度衡量。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Sdk,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "sdk": {
      "type": "http",
      "url": "https://marginpad.io/mcp"
    }
  }
}

README

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

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

Python

python
from marginpad import MarginPad
mp = MarginPad("mpb_...")                                   # key from https://marginpad.io/trading-api/print(mp.price("BTC"))                                      # keyless market datapos = 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 positionmp.sltp(pos["id"], trail_pct=1.5)                           # trailing stop, ratcheted server-sideprint(mp.account())

JavaScript

js
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

Books, reset, equity, replay (2.5 / 2.6)

python
mp.accounts()                                   # every book of the account with lifetime numbersmp.reset()                                      # this key's book back to $10,000 (archived, never deleted)mp.equity(days=30, step_min=60)                 # equity curve + max drawdownmp.replay_start("BTC", "2026-09-11", speed=120) # run the same code through a past day, 12 minutes per daymp.replay(interval=5, bars=120)                 # cursor, price, candles up to the cursormp.replay_stop()                                # summary: closes, win rate, P&L, return, liquidations

A key minted with book ({"act":"create","name":"rsi","book":"rsi"} on POST /api/bot/key) trades a separate journal: one strategy, one key, one clean result. During a replay every trading call of that key acts on a replay journal priced from the candle under the cursor; stops, targets and liquidations are checked on every candle between two calls.

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.

來源:README.md,提交 fcf5d5f

工具

0
工具後設資料尚未被收錄。

版本歷史

1
  1. v2.9.1最新Oct 8, 2026