Skip to main content
The Miramarket CLI lets you author, validate, and post strategies from a terminal instead of the visual builder. Strategies can trade Polymarket prediction markets, tokenized stocks on Base, and perps on Hyperliquid. It is built for scripting and for AI coding agents that can run shell commands, but works just as well for a human typing commands directly. If you want a visual canvas instead, use the strategy builder.

Install

Sign in

This prints a short code and a link:
Open the link in any browser. It does not need to be on the device running the CLI, which helps over SSH or on a server with no browser. Sign in with the usual Miramarket options (email, Google, Discord), check that the code on the page matches the one in your terminal, and choose what this login may do: The budget is one dollar amount for both live runs and single orders, $100 by default. Choose Approve, and the CLI finishes signing in on its own. The login stays active while you use it and ends after 30 days without use, so you do not need to sign in again for routine use. It appears on Connected agents (in the account menu, or at app.miramarket.org/settings/agents) as Miramarket CLI followed by your computer’s name. There you can change its budget or revoke it at any time. Check whether you are signed in, what the login may do, and how much of its budget is in use:
To change the switches, run miramarket-cli login --force and approve a new login with the switches you want. Then revoke the old one on Connected agents.
A login from a CLI older than 1.6.0 no longer works. Run npm install -g @miramarket/cli to update, then miramarket-cli login.

Update the CLI

This installs the latest release with the package manager you installed it with (npm, pnpm, Yarn, or Bun), in the same place, so you don’t need to run npm install -g again. To only check whether a newer release exists, add --check. Versions before 1.6.0 do not have update; update those once with npm install -g @miramarket/cli. If you run the CLI through npx, as a project dependency, or from source, update installs nothing and prints the command to run instead. If it has no permission to write to the install directory, run it again with those rights, for example sudo miramarket-cli update.

Finish account setup

Signing in is not enough to trade. Two more things are required: accepting the current Terms, Privacy Policy, and Risk Disclosure, and delegating your wallet. Check what is still needed:
This reports exactly what is missing and how to fix it. Two steps require you personally, and cannot be done by a script or an AI agent on your behalf:
  • Accept the current policies, from an interactive terminal:
    If you have not accepted them yet, the app also asks you to when you sign in to approve the login.
  • Delegate your wallet, by opening app.miramarket.org and signing in once in a browser. miramarket-cli account status will confirm once this is done.
Run miramarket-cli account status again afterward to confirm you are ready to trade. When the Terms, Privacy Policy, or Risk Disclosure change, account status reports them as not accepted until you run account accept-policies again.

Post your first strategy

Use the guided wizard, which walks you through choosing a starting point, validating, previewing, and posting:
Or work with a strategy file directly:
Add --demo to post to simulate a run instead of using real funds. A live run starts right away when it fits within the login’s budget, counting the live runs it already has in the market. A run beyond the budget is saved but does not start. It waits for you to choose Approve on Connected agents, and post prints the command that reports where it stands:
Once you approve it, the run starts on its own. Requests you do not answer expire after a day.

Describe a strategy instead of writing it

You do not have to write the JSON yourself. Describe what the strategy should do and the CLI builds it with the same assistant that powers the visual builder, then hands you a file to validate, preview, and post:
The command writes ./fed.json only when it reports result: strategy. If the description could mean several markets, it lists them and asks which one you meant; if it is missing something, it says what; if you asked a question, it answers. Read the result before going on, including unmatched, which lists anything you named that could not be matched and was substituted or left out. Once a file is written, continue as with any other strategy file:
It works for tokenized stocks and perps too, in dollars: "buy TSLA if it crosses $400, sell at $450" or "go 3x short on ETH, close it if it rises above $4,200". You can also describe a news situation instead of a trade, such as "build a strategy around this week's Fed meeting": the CLI researches the news and the markets it moves first, and prints a short note on why it chose them. Generated strategies use two venues by default: a trade you name on one venue gets a related position on another for 30% of the budget, which the notices name. Say “just” or “only” in the description to keep one venue (details). To change a generated file, describe the change: miramarket-cli strategies generate "also sell everything below 30 cents" --strategy ./fed.json --out ./fed.json.

Everyday commands

A command the login was not allowed, such as account withdraw with Withdraw funds off, stops with a message that names the switch. Approve a new login with that switch on to use it. Every command supports a --json flag for machine-readable output, which agents and scripts should always use. Run any command with --help to see its full set of options. See the CLI reference for every command, flag, JSON shape, and exit code.

Using it with an AI agent

The CLI is designed so an AI coding agent (such as Claude Code) can drive it directly: run miramarket-cli account status --json first to confirm the account can trade, then either miramarket-cli strategies generate "<description>" --out ./s.json --json or miramarket-cli schema plus hand-authored JSON, then validate, preview, and post. Signing in and accepting policies still require a human — an agent should stop and ask you to complete those steps rather than attempting them. An agent signs in with miramarket-cli login --events, which prints the link and code as soon as they exist, so the agent can show them to you while the CLI waits. You approve the login and choose its switches and budget yourself; the agent cannot change them. A live run beyond the budget waits for your approval, as described in Post your first strategy. If your agent supports MCP, you can connect it to the MCP server instead (agents: see the MCP reference): it gets the same strategy tools without shell access, with the same budget and approvals, but it cannot place single orders, bridge, or withdraw. For the full strategy JSON format, worked examples, and the rules that determine whether a strategy actually behaves as intended (most of which validate can’t check for you), point your agent at /agent-strategy-guide.md — a single markdown file meant to be fetched and read directly, not browsed.