Zerodha
by @jatinbansal1998
Route natural-language trading/account queries to the correct `zerodha` CLI command with exact flags, validation constraints, and synonym mapping. Use when a...
clawhub install zerodha-kiteπ About This Skill
name: zerodha-kite-cli-router description: Route natural-language trading/account queries to the correct
zerodha CLI command with exact flags, validation constraints, and synonym mapping. Use when a user asks to view prices, place/modify/cancel orders, manage auth/profile/config, work with holdings/positions/margins/GTT/MF flows, or asks "which zerodha command should I run?"
Purpose
Translate a user query in plain English into one exact zerodha CLI command.
Do not invent commands or flags. Use only commands defined here.
Bootstrap: CLI Installation
If the user asks to install/setup the CLI, or reports zerodha: command not found, route to an installer command first.
This is the only exception to "commands must start with zerodha".
Install commands:
curl): curl -fsSL https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | shwget): wget -qO- https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | shirm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iexpowershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex"Post-install verification command:
zerodha versionGlobal Rules
1. Always start commands with zerodha (except install/bootstrap commands in "Bootstrap: CLI Installation").
2. Prefer --json when the user asks for machine-readable output.
3. Respect global flags when provided:
- --profile
- --config
- --json
- --debug
4. Profile selection:
- Most commands require an active profile (or explicit --profile).
- If no profile is selected, use:
zerodha config profile use
5. Auth/session:
- API data/order commands require an access token.
- If missing, run zerodha auth login ....
- CLI auto-refreshes access token when refresh token exists.
6. Never guess missing required fields for write actions; ask for the missing values.
7. If OS is required for installation routing and missing, ask for only the OS (linux, macos, or windows).
Login Flow (Multi-Message)
Use this flow when the user wants to authenticate and provides api_key, api_secret, and token across one or more messages.
Collected auth fields (can arrive in any order):
profile_name (default to default if user does not specify)api_keyapi_secretrequest_token_or_redirect_url, or
- callback (optional callback_port)Rules:
1. Persist auth fields provided in earlier user messages during the same login task.
2. Ask only for missing required auth inputs for the next step.
3. Do not emit zerodha auth login ... until profile credentials are configured.
4. If api_key + api_secret are available and profile setup is needed, emit:
zerodha config profile add
5. If user explicitly wants to update only one credential on an existing profile, emit:
- zerodha config profile set-api-key
- zerodha config profile set-api-secret
6. For token mode, emit:
zerodha auth login --request-token
7. For callback mode, emit:
zerodha auth login --callback [--callback-port <1-65535>]
8. If multiple commands are needed, output only the next runnable command.
Command Catalog
Root utilities
zerodha versionzerodha help [command]zerodha completion Config profile
zerodha config profile add --api-key --api-secret [--set-active] required; --api-key and --api-secret required.
zerodha config profile set-api-key --api-key , --api-key required.
zerodha config profile set-api-secret --api-secret , --api-secret required.
zerodha config profile listzerodha config profile use must exist.
zerodha config profile remove must exist.Auth
zerodha auth login --request-token zerodha auth login --callback [--callback-port <1-65535>]--request-token OR --callback.
- --request-token cannot be combined with --callback.
- --callback-port allowed only with --callback.
- --callback-port range: 1..65535.
zerodha auth renewzerodha auth logoutzerodha auth revoke-refresh [--refresh-token ] Profile
zerodha profile showzerodha profile fullQuotes
zerodha quote get [EXCHANGE:SYMBOL...] zerodha quote ltp [EXCHANGE:SYMBOL...] zerodha quote ohlc [EXCHANGE:SYMBOL...] zerodha quote historical --instrument-token --interval --from --instrument-token > 0
- --interval required
- --from and --to required
- time format: YYYY-MM-DD or YYYY-MM-DD HH:MM:SS or RFC3339
- --from <= --toInstruments
zerodha instruments list [--exchange | --all] --exchange and --all are mutually exclusive.
zerodha instruments mfOrders (single order operations)
zerodha order place --exchange --symbol --txn --type --product --qty [--price ] [--trigger-price
] [--validity ] [--validity-ttl ] [--variety ] [--tag ]
--exchange --symbol --txn --type --product --qty
- --qty > 0
- LIMIT requires --price > 0
- SL requires both --price > 0 and --trigger-price > 0
- SL-M requires --trigger-price > 0
- TTL validity requires --validity-ttl > 0
zerodha order modify --order-id [fields...] --order-id required
- At least one modifiable field required.
- If provided, --txn must be BUY/SELL; --type must be MARKET/LIMIT/SL/SL-M; --validity must be DAY/IOC/TTL.
zerodha order cancel --order-id [--variety ] [--parent-order-id ] --order-id required.
zerodha order exit --order-id [--variety ] [--parent-order-id ] --order-id required.Orders (orderbook/trades)
zerodha orders listzerodha orders show --order-id --order-id required.
zerodha orders trades [--order-id ] Positions
zerodha positionszerodha positions convert --exchange --symbol --old-product --new-product --position-type --txn --qty --qty > 0Holdings
zerodha holdingszerodha holdings auctionszerodha holdings auth-initiate [--type ] [--transfer-type ] [--exec-date YYYY-MM-DD] [--isin ...] [--qty ...]
--type set, must be equity|mf
- if --transfer-type set, must be pre|post|off|gift
- if --exec-date set, format must be YYYY-MM-DD
- --isin and --qty must have matching counts
- each --qty must be > 0Margins
zerodha margins [--segment ] zerodha margins order --exchange --symbol --txn --type --product --qty [--price ] [--trigger-price
] [--variety ] [--compact]
zerodha margins basket --exchange --symbol --txn --type --product --qty [--price ] [--trigger-price
] [--variety ] [--compact] [--consider-positions]
zerodha margins charges --exchange --symbol --txn --type --product --qty --avg-price [--price
] [--trigger-price
] [--variety ] [--order-id ]
--exchange --symbol --txn --type --product --qty
- --qty > 0
- LIMIT requires --price > 0
- SL requires both --price > 0 and --trigger-price > 0
- SL-M requires --trigger-price > 0
- Additional charges constraint:
- --avg-price > 0GTT
zerodha gtt place [gtt flags]zerodha gtt modify --trigger-id [gtt flags] zerodha gtt listzerodha gtt show --trigger-id zerodha gtt delete --trigger-id GTT common flags:
--exchange --symbol --last-price --txn [--product ] [--type ]
single type:--trigger --limit-price
--qty
two-leg type:--lower-trigger --lower-limit-price
--lower-qty
- --upper-trigger --upper-limit-price
--upper-qty
GTT constraints:
--exchange --symbol --txn required--last-price > 0--txn in BUY|SELL--product in CNC|MIS|NRML|MTF--trigger-id > 0 for show/modify/deleteMutual Funds
MF Orders
zerodha mf orders place --symbol --txn [--qty ] [--amount ] [--tag ]
--symbol and --txn required
- at least one of --qty or --amount must be > 0
- --qty and --amount cannot be negative
zerodha mf orders list [--from YYYY-MM-DD --to YYYY-MM-DD]--from and --to must be provided together
- date format: YYYY-MM-DD
zerodha mf orders show --order-id --order-id required
zerodha mf orders cancel --order-id --order-id requiredMF SIPs
zerodha mf sips place --symbol --amount --instalments --frequency [--instalment-day <1..31>] [--initial-amount ] [--trigger-price ] [--step-up ] [--sip-type ] [--tag ]
--symbol --amount --instalments --frequency
- --amount > 0, --instalments > 0
- --instalment-day if provided must be in 1..31 (0 means not set)
- --initial-amount and --trigger-price cannot be negative
zerodha mf sips modify --sip-id [--amount ] [--frequency ] [--instalment-day <1..31>] [--instalments ] [--step-up ] [--status ] --sip-id required
- at least one modifiable field required
- numeric fields cannot be negative
zerodha mf sips cancel --sip-id --sip-id required
zerodha mf sips listzerodha mf sips show --sip-id --sip-id requiredMF Holdings
zerodha mf holdingszerodha mf holdings show --isin --isin required
zerodha mf holdings isinsSynonym Map
Use these mappings during intent parsing.
Market data
quote synonyms: price, live price, current price, quote, snapshotltp synonyms: ltp, last traded price, last price, tickohlc synonyms: open high low close, ohlc, candle snapshothistorical synonyms: history, candles, chart data, time seriesAccount and auth
profile synonyms: account details, user profile, my accountlogin synonyms: authenticate, sign in, connect kiterenew synonyms: refresh access token, renew tokenlogout synonyms: sign out, clear sessionBootstrap
install cli synonyms: install zerodha cli, setup zerodha cli, command not found, zerodha not installedOrders and tradebook
order place synonyms: buy, sell, place order, new order, execute tradeorder modify synonyms: edit order, change order, update orderorder cancel synonyms: cancel order, delete orderorder exit synonyms: square off order, exit orderorders list synonyms: orderbook, all ordersorders trades synonyms: tradebook, fills, executed tradesPortfolio
positions synonyms: open positions, net positionspositions convert synonyms: convert position, change product typeholdings synonyms: portfolio holdings, stocks held, demat holdingsholdings auctions synonyms: auction holdings, auction eligibleRisk/margins
margins synonyms: available margin, used margin, fundsmargins order synonyms: margin required, order margin estimatemargins basket synonyms: basket margin, combined marginmargins charges synonyms: brokerage estimate, charges, feesGTT
gtt synonyms: good till trigger, trigger order, price alert ordergtt two-leg synonyms: oco, one cancels other, bracket triggerMutual funds
mf orders synonyms: mutual fund order, fund buy/sellmf sips synonyms: sip, systematic investment planmf holdings synonyms: mutual fund portfolio, fund holdingsRouting Procedure
1. Detect whether this is an install/bootstrap request, login/auth bootstrap request, or a normal zerodha command request.
2. For install/bootstrap: pick the OS-specific installer command.
3. For login/auth bootstrap: follow "Login Flow (Multi-Message)" and emit only the next runnable command.
4. Otherwise detect intent domain using synonyms.
5. Pick the narrowest command path.
6. Extract required entities/flags.
7. Validate against constraints above.
8. If fields are missing, ask for only missing required inputs.
9. Output one runnable command string.
Intent to Command Defaults
curl -fsSL https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | sh
- Windows: irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex
api_key and api_secret first (profile defaults to default unless specified)
api_key + api_secret but no token/mode:--request-token or --callback)
zerodha profile show.zerodha orders list.zerodha orders trades.zerodha positions.zerodha holdings.zerodha margins --segment all.zerodha instruments list.Output Contract For Downstream Agents
When responding with a routed command, return:
1. command: exact runnable command (installer command for bootstrap, otherwise zerodha ...)
2. why: one-line reason
3. missing: required fields still missing (empty if none)