Zerodha

TotalClaw 作者 jatinbansal1998 vv1.0.1

将自然语言交易/帐户查询路由到正确的“zerodha” CLI 命令,并具有精确的标志、验证约束和同义词映射。当用户要求查看价格、下/修改/取消订单、管理身份验证/配置文件/配置、使用持有量/头寸/保证金/GTT/MF 流或询问“我应该运行哪个 Zerodha 命令?”时使用。

源码 ↗

安装 / 下载方式

TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:jatinbansal1998~jatinbansal1998-zerodha-kite
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Ajatinbansal1998~jatinbansal1998-zerodha-kite/file -o jatinbansal1998-zerodha-kite.md
Git 仓库获取源码
git clone https://github.com/openclaw/skills/commit/2427099291f717d9acb62aa04cf6c250b7dc079c
## 概述(中文)

将自然语言交易/帐户查询路由到正确的“zerodha” CLI 命令,并具有精确的标志、验证约束和同义词映射。当用户要求查看价格、下/修改/取消订单、管理身份验证/配置文件/配置、使用持有量/头寸/保证金/GTT/MF 流或询问“我应该运行哪个 Zerodha 命令?”时使用。

## 原文

# 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:

- Linux/macOS (`curl`): `curl -fsSL https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | sh`
- Linux/macOS (`wget`): `wget -qO- https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.sh | sh`
- Windows PowerShell: `irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex`
- Windows CMD: `powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/jatinbansal1998/zerodha-kite-cli/main/scripts/install.ps1 | iex"`

Post-install verification command:

- `zerodha version`

# Global 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 <name>`
   - `--config <path>`
   - `--json`
   - `--debug`
4. Profile selection:
   - Most commands require an active profile (or explicit `--profile`).
   - If no profile is selected, use:
     `zerodha config profile use <name>`
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_key`
- `api_secret`
- one login mode:
  - `request_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 <profile_name> --api-key <key> --api-secret <secret> --set-active`
5. If user explicitly wants to update only one credential on an existing profile, emit:
   - `zerodha config profile set-api-key <profile_name> --api-key <key>`
   - `zerodha config profile set-api-secret <profile_name> --api-secret <secret>`
6. For token mode, emit:
   `zerodha auth login --request-token <token_or_redirect_url>`
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 version`
- `zerodha help [command]`
- `zerodha completion <shell>`

## Config profile

- `zerodha config profile add <name> --api-key <key> --api-secret <secret> [--set-active]`
  - Constraints: `<name>` required; `--api-key` and `--api-secret` required.
- `zerodha config profile set-api-key <name> --api-key <key>`
  - Constraints: `<name>`, `--api-key` required.
- `zerodha config profile set-api-secret <name> --api-secret <secret>`
  - Constraints: `<name>`, `--api-secret` required.
- `zerodha config profile list`
- `zerodha config profile use <name>`
  - Constraints: `<name>` must exist.
- `zerodha config profile remove <name>`
  - Constraints: `<name>` must exist.

## Auth

- `zerodha auth login --request-token <token_or_redirect_url>`
- `zerodha auth login --callback [--callback-port <1-65535>]`
  - Constraints:
    - Exactly one mode is required: `--request-token` OR `--callback`.
    - `--request-token` cannot be combined with `--callback`.
    - `--callback-port` allowed only with `--callback`.
    - `--callback-port` range: `1..65535`.
- `zerodha auth renew`
  - Constraints: refresh token must exist in profile.
- `zerodha auth logout`
- `zerodha auth revoke-refresh [--refresh-token <token>]`
  - If omitted, uses stored refresh token.

## Profile

- `zerodha profile show`
- `zerodha profile full`

## Quotes

- `zerodha quote get <EXCHANGE:SYMBOL> [EXCHANGE:SYMBOL...]`
  - Constraints: at least 1 instrument.
- `zerodha quote ltp <EXCHANGE:SYMBOL> [EXCHANGE:SYMBOL...]`
  - Constraints: at least 1 instrument.
- `zerodha quote ohlc <EXCHANGE:SYMBOL> [EXCHANGE:SYMBOL...]`
  - Constraints: at least 1 instrument.
- `zerodha quote historical --instrument-token <int> --interval <value> --from <time> --to <time> [--continuous] [--oi]`
  - Constraints:
    - `--instrument-token > 0`
    - `--interval` required
    - `--from` and `--to` required
    - time format: `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS` or RFC3339
    - `--from <= --to`

## Instruments

- `zerodha instruments list [--exchange <EXCHANGE> | --all]`
  - Default (no flags): summary by exchange/type.
  - Constraints: `--exchange` and `--all` are mutually exclusive.
- `zerodha instruments mf`

## Orders (single order operations)

- `zerodha order place --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|LIMIT|SL|SL-M> --product <CNC|MIS|NRML|MTF> --qty <n> [--price <p>] [--trigger-price <p>] [--validity <DAY|IOC|TTL>] [--validity-ttl <min>] [--variety <v>] [--tag <t>]`
  - Constraints:
    - required: `--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 <id> [fields...]`
  - Constraints:
    - `--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 <id> [--variety <v>] [--parent-order-id <id>]`
  - Constraints: `--order-id` required.
- `zerodha order exit --order-id <id> [--variety <v>] [--parent-order-id <id>]`
  - Constraints: `--order-id` required.

## Orders (orderbook/trades)

- `zerodha orders list`
- `zerodha orders show --order-id <id>`
  - Constraints: `--order-id` required.
- `zerodha orders trades [--order-id <id>]`

## Positions

- `zerodha positions`
- `zerodha positions convert --exchange <EX> --symbol <SYM> --old-product <CNC|MIS|NRML|MTF> --new-product <CNC|MIS|NRML|MTF> --position-type <day|overnight> --txn <BUY|SELL> --qty <n>`
  - Constraints:
    - all flags above required
    - `--qty > 0`

## Holdings

- `zerodha holdings`
- `zerodha holdings auctions`
- `zerodha holdings auth-initiate [--type <equity|mf>] [--transfer-type <pre|post|off|gift>] [--exec-date YYYY-MM-DD] [--isin <isin> ...] [--qty <float> ...]`
  - Constraints:
    - if `--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 `> 0`

## Margins

- `zerodha margins [--segment <all|equity|commodity>]`
- `zerodha margins order --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|LIMIT|SL|SL-M> --product <CNC|MIS|NRML|MTF> --qty <n> [--price <p>] [--trigger-price <p>] [--variety <v>] [--compact]`
- `zerodha margins basket --exchange <EX> --symbol <SYM> --txn <BUY|SELL> --type <MARKET|