How it works
One loop, five tools, one gate.
The tick
- The agent appends a
tickentry to the journal. - It sends the model the strategy, the hard limits and five tools.
- The model reads markets and its account, reasons in text (journaled as
thought), then callsopen_position,close_positionorhold. - Every
open_positionis 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 asrisk_deniedand the model is told why. - The tick ends on
hold, after the model stops calling tools, or aftermaxRounds(default 8).
Tools the model sees
| Tool | What it does |
|---|---|
get_markets | Mark price, exchange max leverage, hourly funding for allowed markets. |
get_account | Equity, withdrawable margin, today's realized PnL, open positions with liquidation prices. |
open_position | Isolated-margin long or short. Subject to the risk gate. |
close_position | Reduce-only market close. |
hold | Do 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.