sdk

v3.0.2
io.github.Marginpad/sdk Checked 1 day ago Published 18 days ago

Free crypto-futures paper trading and live market data for AI agents.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_price Live price

Live price and 24h change for a crypto perp, stock, index, forex pair or metal. No API key needed.

ParameterTypeDescription
symbol *stringSymbol without the USDT suffix, e.g. BTC, ETH, AAPL, EURUSD, XAU

get_klines OHLC candles

OHLC candles for a symbol. Use this to compute indicators or check a setup before trading.

ParameterTypeDescription
symbol *string
intervalstringMinutes: 1, 5, 15, 60, 240, 1440, 10080

get_markets Tradable markets

Every tradable symbol with its asset class, maximum leverage and taker fee. Call this before sizing a trade.

ParameterTypeDescription
asset_classstring

get_screener Setup screener

Scored trade setups across top USDT perps: 0-100 technical score, RSI, MACD, funding and open interest.

get_funding Funding rates

Current funding rates across exchanges - who pays whom to hold a perp position.

ParameterTypeDescription
symbolstring

get_open_interest Open interest

Open interest per symbol - how much leveraged money is committed.

ParameterTypeDescription
symbolstring

get_catalysts Catalysts (news, listings, macro, hacks)

Dated events that can move a coin, as they land: exchange listings and delistings, filings, macro prints, hacks (scored by the money lost), ETF and regulation headlines, official channels and fast news desks - one story per event with the desks that reported it, a 0-100 score, the coins named, the direction implied and how much events of that kind have measurably moved price.

ParameterTypeDescription
kindstringlisting, delisting, macro, hack, etf, regulation, politics, whale, unlock, protocol, adoption, filing, news
limitnumber
min_scorenumberMinimum score 0-100 (default 25)
symbolstringOnly items naming this coin

get_what_moved_it What moved it (30 days)

Every abnormal jump or drop of the last 30 days for any market (coin, stock, index, forex, metal) with its causes and their shares, dated by the FIRST report of a story: the story that moved it (with desks and measured realism), a liquidation cascade or forced closes, the whale tracker, the tape, Bitcoin and why Bitcoin moved, US stocks, open interest (deleveraging, short covering, new positioning), the chart structure (a broken level, a new 30-day extreme), with a sentence on every move - unknown said out loud. Pass at (ms) with pct for a live verdict on a move happening now.

ParameterTypeDescription
atnumberLive verdict: the move start in ms
daysnumber
nnumber
pctnumber
symbolstring
tfnumberCandle minutes: 5, 15 or 60

get_liquidations Liquidations (24h)

Recent real liquidation events aggregated from twelve exchanges.

ParameterTypeDescription
symbolstring

get_fear_greed Fear and Greed index

Crypto Fear and Greed index, current value and classification.

get_economic_calendar Economic calendar

Upcoming macro events that move crypto (FOMC, CPI, NFP). Always check this before answering questions about dates - never answer those from memory.

calc_liquidation Liquidation price calculator

Liquidation price for a position: entry, leverage, side.

ParameterTypeDescription
entry *number
leverage *number
side *string

calc_position_size Position size calculator

Risk-based position size from account balance, risk percent, entry and stop.

ParameterTypeDescription
balance *number
entry *number
risk_pct *number
stop *number

paper_balance Paper account balance

Your paper account: balance, equity, free margin, unrealized P&L. Requires an API key.

paper_positions Paper positions

Your paper positions with live mark price and P&L net of fees; status "open" for just the open ones. Requires an API key.

ParameterTypeDescription
statusstringOmit for both

paper_trades Closed paper trades

Closed-trade ledger with paging - the full record for measuring a strategy. Requires an API key.

ParameterTypeDescription
beforenumberEpoch ms cursor from next_before
limitnumber

paper_open Open a paper position

Open a simulated position at the live price. Simulated money only - no real funds are ever at risk. Requires an API key.

ParameterTypeDescription
leverage *number1 to the symbol cap from get_markets
margin_usd *number1 to 100000
side *string
symbol *string
client_order_idstringYour own id - retrying with the same one returns the first position instead of opening a second
dry_runbooleantrue = validate and price the trade (entry, liquidation, quantity, fees) and write NOTHING
slnumber | null
tpnumber | null
trail_pctnumber | nullTrailing stop distance in percent (0.05-50): the stop follows the best price seen, server-side, even while the bot is offline

paper_close Close a paper position

Close a simulated position, fully or partially. Requires an API key.

ParameterTypeDescription
id *string
pctnumberPercent to close, 1-100. Omit for the whole position.

paper_sltp Set stop / take-profit

Move the stop-loss, take-profit or trailing stop on an open simulated position. Requires an API key.

ParameterTypeDescription
id *string
slnumber | null
tpnumber | null
trail_pctnumber | nullTrailing stop distance in percent (0.05-50); null switches trailing off

paper_modify_order Modify a resting order

Change a resting limit or stop order in place: its price, stop-loss, take-profit, margin, leverage or trailing stop. Requires an API key.

ParameterTypeDescription
order_id *string
leveragenumber
limit_pricenumber
margin_usdnumber
slnumber | null
tpnumber | null
trail_pctnumber | null

paper_fees Fee venue

Which exchange fee schedule your paper fills are charged at: lists the venues we model (Bybit, Binance, OKX, Bitget, MEXC, Gate, KuCoin, Kraken, Hyperliquid) with their taker rate and the referral discount a MarginPad sign-up gets, and your current default. Pass set to change the default (a venue key, or "marginpad" for the default rate). Requires an API key.

ParameterTypeDescription
setstringOmit to read. A venue key from the list, or "marginpad" to reset.

paper_sim Simulation profile

The whole paper-trading simulation, configurable. By default this engine is deliberately easy: a market order fills whole at the live price, maintenance margin is a flat 0.5%, the balance is a scorecard that never refuses an open, and there is no latency, no size impact and no partial fill. That is right for learning and optimistic for proving out a bot. This sets any of it: the book size your results are measured against and whether it is a real budget (margin_enforced), what crossing the book costs on entry and exit (slippage, slippage_bps, impact_bps_per_100k), how long your order is in fli…

ParameterTypeDescription
exit_slippagebooleanPay the crossing cost on the way out too (default true). A stop, take-profit or liquidation still fills at its level.
fundingbooleanfalse = never charge funding, which is how you separate an execution edge from a carry edge.
funding_multnumber0-5. Scale the real 8-hourly funding rate.
impact_bps_per_100knumber0-500. Extra basis points per $100,000 of notional, because size walks further down the book.
latency_msnumber0-2000. Your order is in flight this long and the price is re-read afterwards.
leverage_maxnumberYour own leverage ceiling below the market cap. 0 = the market cap.
margin_enforcedbooleantrue = an open needing more than free margin is refused 402, as a venue refuses it. Free margin is balance minus committed margin; unrealized profit is not collateral, because every position is isolat…
margin_tiersbooleanRaise maintenance margin with size, as a risk-limit ladder does, so a large position liquidates sooner.
margin_venuestringbinance | bybit | okx | bitget | mexc | kucoin | gate | kraken | hyperliquid | coinbase, or "marginpad". Moves ONLY where liquidation sits.
max_notional_usdnumberYour own ceiling on one position’s notional. 0 = none.
min_fill_pctnumber10-100. The worst fill ratio with partial_fills on.
mmr_pctnumber0.05-10. Your own maintenance margin, beating margin_venue.
partial_fillsbooleanAllow a market order to fill less than it asked for.
presetstringfrictionless | realistic | binance | bybit | okx | hyperliquid | thin_book | brutal. A preset starts from the defaults, so it is a clean slate plus that configuration. Omit every field to READ.
reject_rate_pctnumber0-50. Share of opens refused 503 venue_rejected on purpose.
resetbooleantrue = back to the engine defaults.
slippagebooleanFill against yourself the way a real book does: 0.01% crypto majors, 0.05% other crypto, 0.005% forex, 0.02% stocks/metals/indices.
slippage_bpsnumber0-500. Your own crossing cost in basis points instead of that table. 10 = 0.10%.
start_balance_usdnumber100 to 10,000,000. The book return_pct, the equity curve and max drawdown are measured against.
taker_bpsnumber0-100. Your own per-side fee in basis points. 5.5 = 0.055%.

paper_realism Fill realism

How honestly your paper fills are simulated. By default a market order fills at the live price with no slippage and maintenance margin is a flat 0.5%, which is easier than a real exchange and increasingly so as a position grows. Pass slippage and/or margin_tiers to turn either on, and margin_venue to build on a named venue’s published maintenance-margin rate (Binance 0.40%, Bybit 0.50%, MEXC 0.10%, Kraken 0.60%, Hyperliquid 1.25%, Coinbase 1.33%). Reading returns your setting, every venue rate and the whole size-tier ladder, so a liquidation price never has to be reverse-engineered. Position…

ParameterTypeDescription
margin_tiersbooleanRaise maintenance margin with position size, as an exchange risk-limit table does, so a large position is liquidated sooner.
margin_venuestringbinance | bybit | okx | bitget | mexc | kucoin | gate | kraken | hyperliquid | coinbase, or "marginpad" to reset. Omit every field to read.
slippagebooleanFill against yourself the way a real order book does: 0.01% crypto majors, 0.05% other crypto, 0.005% forex, 0.02% stocks/metals/indices.

paper_report Trading report

The 30-day trading report for this account, measured from its own closed trades: totals and a skill score (free), win rate and return by coin, leverage band, side, hour and day plus written findings (API Pro and above). Requires an API key.

ParameterTypeDescription
daysnumber1-30, default 30

paper_accounts Paper books

Every book (sub-account) of this account with lifetime numbers and the keys bound to it. A book is a separate journal, balance and report; a key minted with a book name trades that book. Requires an API key.

paper_reset Reset the paper book

Restart this key’s book at $10,000: closed trades are archived (never deleted), resting orders cancelled, the report and equity curve start from now. Refused while positions are open - close them first. Requires an API key.

paper_equity Equity curve

The equity curve of this key’s book: starting balance + realized P&L per bucket from the ledger, the live unrealized point at the end, and max drawdown. Requires an API key.

ParameterTypeDescription
daysnumber1-90, default 30
step_minnumberBucket minutes, 5-1440

paper_replay Replay a past day

Backtest with the real routes: replay one past UTC day on MarginPad’s 1-minute candles. With symbol+day it STARTS a replay (speed = market seconds per real second, 1-600, default 60): from then on paper_open / paper_positions / paper_close act on a separate replay journal priced at the candle under the cursor, with stops, targets and liquidations checked on every candle. With no arguments it reads the status (cursor, price, progress, candles up to the cursor). With act "stop" it closes everything at the cursor and returns the summary. Requires an API key.

ParameterTypeDescription
actstring"stop" ends the replay and returns the summary
daystringStart: a complete past UTC day, YYYY-MM-DD
speednumberStart: 1-600, default 60
symbolstringStart: the market, e.g. BTC

paper_limit_order Place a limit or stop order

Place a resting order that fills only when the market reaches your price, and fills AT that price. type "limit" = a pullback entry (long below the market, short above); type "stop" = a breakout entry (long above the market, short below). To open right now use paper_open instead. Simulated money only. Requires an API key.

ParameterTypeDescription
leverage *number
limit_price *numberBelow the market for a long, above it for a short
margin_usd *number1 to 100000
side *string
symbol *string
client_order_idstring
slnumber | null
tpnumber | null

paper_orders Resting orders

Your resting limit orders, plus the last 20 that filled, expired or were cancelled. Requires an API key.

paper_cancel_order Cancel a resting order

Cancel a resting limit order. Requires an API key.

ParameterTypeDescription
order_id *string