perpadGitHub

How it works

One loop, five tools, one gate.

The tick

  1. The agent appends a tick entry to the journal.
  2. It sends the model the strategy, the hard limits and five tools.
  3. The model reads markets and its account, reasons in text (journaled as thought), then calls open_position, close_position or hold.
  4. Every open_position is evaluated by the risk engine against live account state and live exchange leverage caps. Allowed requests are clamped to the limits and executed. Denied requests are journaled as risk_denied and the model is told why.
  5. The tick ends on hold, after the model stops calling tools, or after maxRounds (default 8).

Tools the model sees

ToolWhat it does
get_marketsMark price, exchange max leverage, hourly funding for allowed markets.
get_accountEquity, withdrawable margin, today's realized PnL, open positions with liquidation prices.
open_positionIsolated-margin long or short. Subject to the risk gate.
close_positionReduce-only market close.
holdDo nothing. Ends the turn.

There is no tool for withdrawals, transfers, cross margin, or changing limits. The model cannot do what no tool allows.

Order execution

Orders are marketable immediate-or-cancel limits priced at mid plus or minus a slippage bound (default 1%), with prices rounded to Hyperliquid's tick rules (5 significant figures, at most 6 minus szDecimals decimals) and sizes rounded down so a position never exceeds approved margin. Leverage is set isolated before the order. An unfilled IOC opens nothing and is reported as an error.

Venues

HyperliquidVenue signs real orders with @nktkas/hyperliquid. PaperVenue reads the same live prices but fills locally with the 0.045% taker fee and models isolated liquidation. Both implement one Venue interface, so a strategy tested on paper runs unchanged live.