OpenAlgo CLI
OpenAlgo CLI - a command-line client for the OpenAlgo API, built for AI agents, scripts, and automation
OpenAlgo CLI is a single Go binary that talks to your own OpenAlgo server over its REST and WebSocket APIs. It places and manages orders, reads positions, funds and holdings, pulls quotes, depth and historical candles, works with option chains and Greeks, operates Strategy Module runs, and streams live market data, with any broker OpenAlgo supports.
The CLI never connects to a broker directly. It sends requests to your OpenAlgo server, and the server's API key resolves the broker session.
The CLI is open source under the Apache-2.0 license: github.com/marketcalls/openalgo-cli.
For a step-by-step walkthrough with screenshots, read the tutorial OpenAlgo CLI: Trade, Stream and Automate Your Broker from the Terminal.
Built for Agents
The CLI is designed for AI agents, scripts, and automation pipelines first:
Every parameter is an explicit
--flag. Flag names are the API field names in kebab-case (trigger_pricebecomes--trigger-price).Every API command returns the OpenAlgo JSON response on stdout.
Errors are JSON on stderr with meaningful exit codes.
--help-alland--schemalet an agent discover commands and response shapes at runtime without calling the API.--dry-runpreviews any state-changing request without sending it.
It is not an interactive trading terminal. There are no confirmation prompts, and every command executes immediately against whatever your OpenAlgo server is connected to. Whether an order is simulated or live depends on the server's analyzer mode (sandbox mode), not on the CLI.
Use Cases
AI agent harnesses
Give Claude Code, Codex, the Claude Agent SDK, or any tool-calling harness a shell tool and the CLI. The agent reads positions, funds and quotes, reasons about them, and places or manages orders. See AI Agents.
Human-in-the-loop execution
An agent or script proposes an order with --dry-run, a human or policy layer approves the exact request body, and the same command is sent without --dry-run.
Scheduled automation
Cron jobs, CI, or task schedulers square off positions, snapshot P&L, or alert on rejected orders with a few lines of shell.
Multiple brokers and instances
One profile per OpenAlgo instance (-p zerodha, -p dhan) lets a single script or agent report on or act across every account.
Research and data pipelines
Historical candles, the instrument master, option chains, and Greeks go straight into pandas, DuckDB, or spreadsheets with --csv.
Live monitoring
openalgo stream ltp, quote, depth, and orders emit NDJSON for alerting scripts, dashboards, or an agent watching order updates.
Strategy Module operations
Start, stop, and audit strategies (runs, orders, risk events) from scripts or chat-ops.
Ops and debugging
openalgo doctor checks connectivity, the broker session, and analyzer mode. --debug and --trace show the exact request with the API key redacted, which helps reproduce a TradingView or Amibroker integration issue.
Universal adapter
Anything that can run a process (Excel VBA, Node, Rust, n8n, Make) can drive OpenAlgo without an SDK.
When Not to Use It
Latency-sensitive, tick-by-tick strategies. Each command starts a new process and makes a fresh HTTP request. Use the Python SDK or the WebSocket API directly.
Long conversational sessions. When an assistant is exploring an account interactively over many turns, the MCP server fits better.
CLI Compared to MCP
Both let an AI agent work with a running OpenAlgo instance.
Interface
Shell commands with flags
Tool calls over the Model Context Protocol
Runs as
A single binary, one process per command
A long-running MCP server process
Works with
Any agent or script that can run a shell command, plus cron, CI, and other languages
MCP clients such as Claude Desktop, Cursor, and Windsurf
Output
JSON by default, CSV with --csv, filtered with --jq
Tool results returned to the model
Previewing writes
--dry-run prints the exact request body
Depends on the client's approval flow
Live data
stream commands emit NDJSON over WebSocket
Request and response only
Multiple instances
Profiles, selected per command with -p
One server entry per instance
Good for
Automation, scheduled jobs, pipelines, and agents with a shell tool
Conversational exploration of the account
They compose. An agent can use MCP for conversation and the CLI for scripted, repeatable, or scheduled work.
Quick Start
Install the CLI. See Installation.
Save the server address and API key in a profile. See Authentication and Profiles.
Check connectivity and the trading mode.
Read the account and market data.

Preview an order, then place it.
Safety
Destructive commands act immediately and without confirmation:
openalgo position close-allsquares off every open position in the account.--strategyis a tag, not a filter.openalgo order cancel-allcancels every open order in the account.openalgo strategy close-allexits every open leg of a strategy run.openalgo analyzer toggle --mode=falseswitches the server out of analyzer mode, so every later order goes to the broker as a live order.
Run openalgo analyzer status before placing orders when you are not sure which mode the server is in. See Responsibilities.
Pages in This Section
Install scripts, Go, source builds, verification, and updates
Profiles, environment variables, and multiple OpenAlgo instances
Every command, its API endpoint, and an example
JSON, CSV, jq, schemas, dry runs, errors, exit codes, and retries
Live LTP, quote, depth, and order updates over WebSocket
Using the CLI and its agent skill inside agent harnesses
Last updated
Was this helpful?