@ethosagent/tools-india-broker-zerodha 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/LICENSE +21 -0
- package/README.md +135 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +735 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +850 -0
- package/dist/index.js.map +1 -0
- package/dist/panel.d.ts +24 -0
- package/dist/panel.js +394 -0
- package/dist/panel.js.map +1 -0
- package/package.json +116 -0
- package/skills/portfolio_review.md +30 -0
- package/skills/position_sizing.md +4 -0
- package/skills/trade_confirmation.md +36 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mitesh Sharma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# @ethosagent/tools-india-broker-zerodha
|
|
2
|
+
|
|
3
|
+
Zerodha Kite Connect broker tools for Ethos AI agents. Read equity holdings, positions, orders, margins, and place orders with human confirmation via the Kite Connect REST API.
|
|
4
|
+
|
|
5
|
+
> **Part of the [Ethos](https://github.com/ethosagent/ethos) AI agent ecosystem.**
|
|
6
|
+
> These tools are designed to be registered with an Ethos agent via `createZerodhaTools()`. They can also be used standalone via the CLI.
|
|
7
|
+
|
|
8
|
+
## Prerequisites
|
|
9
|
+
|
|
10
|
+
- **Zerodha trading account** (free) at [zerodha.com](https://zerodha.com)
|
|
11
|
+
- **Kite Connect API subscription** — INR 2,000/month from [kite.trade](https://kite.trade)
|
|
12
|
+
- `api_key` and `api_secret` from the Kite Connect developer console
|
|
13
|
+
|
|
14
|
+
## Auth Flow
|
|
15
|
+
|
|
16
|
+
Zerodha uses session-based OAuth. The access token must be renewed daily — there is no automatic refresh.
|
|
17
|
+
|
|
18
|
+
### Setup: Register redirect URLs in Zerodha developer portal
|
|
19
|
+
|
|
20
|
+
Log in to [kite.trade/apps](https://kite.trade/apps) and add both redirect URLs to your app:
|
|
21
|
+
|
|
22
|
+
| Surface | Redirect URL |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Ethos Desktop | `ethos://auth/zerodha` |
|
|
25
|
+
| Ethos Web | `https://your-domain.com/auth/zerodha/callback` |
|
|
26
|
+
|
|
27
|
+
You only need to register the surface(s) you use.
|
|
28
|
+
|
|
29
|
+
### Desktop (Ethos app)
|
|
30
|
+
|
|
31
|
+
The desktop app shows a **Connect Zerodha** button when the token is expired. Clicking it:
|
|
32
|
+
1. Opens `https://kite.trade/connect/login?v=3&api_key=XXX` in your system browser
|
|
33
|
+
2. After you log in, Zerodha redirects to `ethos://auth/zerodha?request_token=YYY`
|
|
34
|
+
3. The app catches the redirect, exchanges the token, and stores it automatically
|
|
35
|
+
|
|
36
|
+
### Web
|
|
37
|
+
|
|
38
|
+
Configure `https://your-domain.com/auth/zerodha/callback` as the redirect URL.
|
|
39
|
+
The web app handles the callback at that route, exchanges the token, and stores it.
|
|
40
|
+
|
|
41
|
+
### CLI / Agent
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
zerodha-broker auth # print login URL
|
|
45
|
+
zerodha-broker auth --request-token TOKEN # complete token exchange
|
|
46
|
+
zerodha-broker auth status # check token validity
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or ask the agent — it can call `zerodha_auth_status` to check validity and `zerodha_auth_complete` with the `request_token` to exchange the token.
|
|
50
|
+
|
|
51
|
+
### Daily token renewal
|
|
52
|
+
|
|
53
|
+
All tokens expire at midnight IST. The `zerodha_auth_status` tool returns whether the current token is still valid.
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install @ethosagent/tools-india-broker-zerodha
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## CLI Usage
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Auth setup (one-time)
|
|
65
|
+
mkdir -p ~/.ethos/secrets/brokers/zerodha
|
|
66
|
+
echo "YOUR_API_KEY" > ~/.ethos/secrets/brokers/zerodha/apiKey
|
|
67
|
+
echo "YOUR_API_SECRET" > ~/.ethos/secrets/brokers/zerodha/apiSecret
|
|
68
|
+
chmod 600 ~/.ethos/secrets/brokers/zerodha/*
|
|
69
|
+
|
|
70
|
+
# Daily auth
|
|
71
|
+
zerodha-broker auth # print login URL
|
|
72
|
+
zerodha-broker auth --request-token TOKEN # complete token exchange
|
|
73
|
+
zerodha-broker auth status # check token validity
|
|
74
|
+
|
|
75
|
+
# Portfolio
|
|
76
|
+
zerodha-broker holdings # equity holdings with P&L
|
|
77
|
+
zerodha-broker positions # open positions
|
|
78
|
+
zerodha-broker orders # today's order book
|
|
79
|
+
zerodha-broker margins # available funds
|
|
80
|
+
|
|
81
|
+
# Orders
|
|
82
|
+
zerodha-broker order --symbol RELIANCE --qty 10 --side BUY --type LIMIT --price 2980
|
|
83
|
+
zerodha-broker order --symbol RELIANCE --qty 10 --side BUY --type LIMIT --price 2980 --confirm
|
|
84
|
+
zerodha-broker cancel --order-id ORD123
|
|
85
|
+
|
|
86
|
+
# Audit
|
|
87
|
+
zerodha-broker log # agent order log
|
|
88
|
+
zerodha-broker clean # wipe local cache
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Library / Ethos Integration
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { createZerodhaTools } from '@ethosagent/tools-india-broker-zerodha';
|
|
95
|
+
|
|
96
|
+
// Register all 6 tools with Ethos
|
|
97
|
+
for (const tool of createZerodhaTools()) {
|
|
98
|
+
toolRegistry.register(tool);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Available Tools
|
|
103
|
+
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `zerodha_auth_status` | Check if access token is valid |
|
|
107
|
+
| `zerodha_account` | Account summary — funds and margins |
|
|
108
|
+
| `zerodha_holdings` | Equity holdings with P&L (cached) |
|
|
109
|
+
| `zerodha_positions` | Open intraday and overnight positions |
|
|
110
|
+
| `zerodha_orders` | Today's order book |
|
|
111
|
+
| `zerodha_place_order` | Propose or place an equity order (dry-run default) |
|
|
112
|
+
|
|
113
|
+
## SEBI Compliance Notice
|
|
114
|
+
|
|
115
|
+
This tool is designed for **human-supervised, delivery-based (CNC) equity trading only**:
|
|
116
|
+
|
|
117
|
+
- Order placement defaults to dry-run mode (`dry_run: true`)
|
|
118
|
+
- Real orders require explicit human confirmation
|
|
119
|
+
- No algorithmic or high-frequency trading (requires SEBI/exchange approval)
|
|
120
|
+
- No intraday margin (MIS) or F&O orders in v1
|
|
121
|
+
- Full audit trail of all proposed and placed orders
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm install # install dependencies
|
|
127
|
+
npm run check # typecheck + lint + test
|
|
128
|
+
npm run build # tsup -> dist/
|
|
129
|
+
npm run dev # tsup --watch
|
|
130
|
+
make help # list all targets
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|