kitecli 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,259 @@
1
+ Metadata-Version: 2.4
2
+ Name: kitecli
3
+ Version: 0.1.0
4
+ Summary: Kite Connect CLI — Multi-account Zerodha trading positions viewer
5
+ Author: KiteCLI Team
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: typer>=0.9.0
10
+ Requires-Dist: rich>=13.0.0
11
+ Requires-Dist: pyyaml>=6.0.0
12
+ Requires-Dist: prompt_toolkit>=3.0.36
13
+ Requires-Dist: kiteconnect>=5.0.0
14
+ Requires-Dist: pyotp>=2.9.0
15
+ Requires-Dist: requests>=2.31.0
16
+ Requires-Dist: yfinance>=0.2.0
17
+ Provides-Extra: server
18
+ Requires-Dist: fastapi>=0.110.0; extra == "server"
19
+ Requires-Dist: uvicorn[standard]>=0.27.0; extra == "server"
20
+ Requires-Dist: pydantic>=2.0.0; extra == "server"
21
+ Provides-Extra: bot
22
+ Requires-Dist: python-telegram-bot>=20.0; extra == "bot"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
25
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
26
+ Requires-Dist: httpx>=0.27.0; extra == "dev"
27
+
28
+ # Kite Connect CLI (kitecli)
29
+
30
+ A multi-account Zerodha Kite Connect trading positions viewer with a beautiful interactive terminal user interface (TUI).
31
+
32
+ ```
33
+ ╦╔═╔═╗╦ ╦
34
+ ╠╩╗║ ║ ║
35
+ ╩ ╩╚═╝╩═╝╩
36
+ Kite Connect CLI
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Key Features
42
+
43
+ - 🔒 **Local-Only Architecture**: No server layer, no database, no cloud deployment. Your Zerodha API credentials and session tokens stay strictly on your local machine.
44
+ - 👥 **Multi-Account**: View and manage open positions and order books from multiple Zerodha accounts in a single consolidated screen.
45
+ - ⚡ **Parallelized Requests**: All network calls (positions, orders, initialization) are executed concurrently in a thread pool, keeping updates extremely fast and fluid.
46
+ - 🔑 **Auto-Login**: Session tokens are cached securely in `~/.kcli/sessions.json`. Using your credentials (`user_id`, `password`, `totp_secret`), `kcli` automatically handles authentication and daily OTP generation in the background.
47
+ - 🌐 **Proxy Routing**: Map different HTTP/HTTPS proxies to each account individually to comply with Zerodha API connection requirements.
48
+ - 📊 **Interactive TUI Dashboard**: Launch the live dashboard to view:
49
+ - Consolidated active positions with soft-color styling.
50
+ - Live indices panel (**NIFTY 50**, **SENSEX**, and **INDIA VIX**).
51
+ - Info Pane to view Pending Orders, Executed Orders, or Option Chains (`F1`, `F2`, `F3`).
52
+ - Active logs with color-coded alerts and focus highlights for simple navigation.
53
+ - 📡 **Live WebSocket Streaming**: Position LTPs/P&L, the market indices panel, and the option chain all update in real time over the Kite WebSocket (`KiteTicker`) — no manual refresh needed. Order fills push an instant positions/orders re-sync.
54
+ - 🎯 **Primary Streaming Account**: Market data (indices, option chain, and position prices) is streamed through a single designated *primary* account instead of redundantly subscribing on every account. Mark one account with `primary: true` in the config, or let `kcli` auto-select the first streaming-capable account. Per-account positions, orders, and P&L remain fully independent.
55
+ - 🩺 **Streaming Diagnostics**: On startup, `kcli` probes each account's WebSocket authentication. Accounts whose `api_key` lacks an active streaming subscription (REST works but the ticker is rejected with `403`) are reported clearly and skipped, preventing reconnect-error storms.
56
+ - 🤖 **Gemini Natural Language Interface (NLI) [Very Basic]**: Prefix commands with `/` (e.g., `/exit weekly options on zk`) to translate conversational queries into explicit chained `kcli` orders. Runs 100% offline for symbol lookup using active positions, and is powered by Google's Gemini 2.5 Flash Cloud API. *(Requires setting `gemini_api_key` in config.yaml)*.
57
+ - 🧹 **Action Bar SQUAREOFF Button**: Dedicated purple action button that pre-fills the `exit near-week` command, letting you exit all near-week weekly options on selected or all accounts concurrently with double confirmation.
58
+ - 💾 **SQLite Session Recorder**: Logs positions, orders, and market indices snapshots context to a local `~/.kcli/data.db` database in the background for trading performance analytics.
59
+ - 📈 **Tuesday Strangle Advisor**: Displays capital allocations, lot sizes, and copy-paste execution stages on Tuesdays in the Info Pane (`F4`).
60
+
61
+ ---
62
+
63
+ ## Installation
64
+
65
+ Install the package via `pip`:
66
+
67
+ ```bash
68
+ pip install kitecli
69
+ ```
70
+
71
+ *(For local development or installing from source)*:
72
+ ```bash
73
+ git clone https://github.com/chandu389/kitecli.git
74
+ cd kitecli
75
+ pip install -e .
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Quick Start
81
+
82
+ ### 1. Initialize Configuration
83
+
84
+ Create a default configuration template:
85
+
86
+ ```bash
87
+ kcli config --init
88
+ ```
89
+
90
+ This generates a config file at `~/.kcli/config.yaml`.
91
+
92
+ ### 2. Configure Accounts
93
+
94
+ Open `~/.kcli/config.yaml` in your text editor and add your accounts. Include your login credentials and TOTP secrets to enable auto-login:
95
+
96
+ ```yaml
97
+ accounts:
98
+ - name: "Account 1"
99
+ api_key: "your_api_key_1"
100
+ api_secret: "your_api_secret_1"
101
+ user_id: "your_zerodha_user_id_1"
102
+ password: "your_zerodha_password_1"
103
+ totp_secret: "your_totp_secret_1"
104
+ proxy: "http://username:password@ip:port" # Optional per-account proxy
105
+ primary: true # Optional: use this account for streaming
106
+
107
+ - name: "Account 2"
108
+ api_key: "your_api_key_2"
109
+ api_secret: "your_api_secret_2"
110
+ user_id: "your_zerodha_user_id_2"
111
+ password: "your_zerodha_password_2"
112
+ totp_secret: "your_totp_secret_2"
113
+ proxy: "http://username:password@ip:port"
114
+ ```
115
+
116
+ **The `primary` flag** (optional) designates which account streams the shared
117
+ market data — the indices panel, option chain, and position prices. Because an
118
+ instrument's price is the same regardless of which account holds it, streaming
119
+ it once through a single primary account avoids redundant duplicate
120
+ subscriptions. If `primary` is omitted (or the flagged account can't stream),
121
+ `kcli` automatically falls back to the first streaming-capable account.
122
+
123
+ > **Note on streaming:** Live WebSocket streaming requires that the account's
124
+ > Kite Connect app has an active streaming subscription. An account can read
125
+ > positions over REST yet still be rejected by the WebSocket (`403`) if its app
126
+ > lacks streaming access. `kcli` detects this on startup and reports it in the
127
+ > Status Logs.
128
+
129
+ ### 3. Log In & Authenticate
130
+
131
+ Authenticate and start your sessions (auto-login will run in the background for accounts with complete credentials):
132
+
133
+ ```bash
134
+ kcli init
135
+ ```
136
+
137
+ ### 4. Run commands
138
+
139
+ - **Interactive Dashboard**:
140
+ ```bash
141
+ kcli live
142
+ ```
143
+ - **Positions Snapshot**:
144
+ ```bash
145
+ kcli positions
146
+ ```
147
+ - **Status Check**:
148
+ ```bash
149
+ kcli status
150
+ ```
151
+
152
+ ---
153
+
154
+ ## CLI Command Reference
155
+
156
+ | Command | Description |
157
+ |---|---|
158
+ | `kcli live` | Launch the interactive live TUI dashboard |
159
+ | `kcli init` | Initialize and authenticate account sessions |
160
+ | `kcli positions` | Print a quick snapshot of active positions |
161
+ | `kcli status` | Check authentication status of configured accounts |
162
+ | `kcli config --init` | Generate a default configuration file |
163
+ | `kcli config --show` | Display current configuration (secrets masked) |
164
+ | `kcli config --path` | Print the configuration file path |
165
+
166
+ ---
167
+
168
+ ## License
169
+
170
+ MIT
171
+
172
+ ---
173
+
174
+ ## Changelog
175
+
176
+ ### 0.1.0b13 — 2026-06-30
177
+
178
+ **Bug Fixes:**
179
+ - **Global IPv4 DNS Resolution Patch**: Moved and applied the IPv4 DNS resolution override globally at the package initialization level in `cli/__init__.py`. This forces all Zerodha connections (including direct, non-proxied account calls like `SS1009`) to resolve and connect strictly over IPv4, preventing IP mismatch errors ("IP not allowed") caused by transient macOS IPv6 routing.
180
+
181
+ ---
182
+
183
+ ### 0.1.0b12 — 2026-06-29
184
+
185
+ **Enhancements:**
186
+ - **Explicit Symbol Resolution on SQUAREOFF Click**: Clicking the `SQUAREOFF` action bar button now resolves near-week options using live open positions, pre-filling the exact command chain (e.g. `exit NIFTY26JUN22300PE`) directly in the input bar for full transparency before execution, rather than displaying generic `exit near-week` text.
187
+ - **Price Format Correction in NLI**: Added strict system instructions and formatting rules to ensure the LLM outputs prices as raw numeric values (e.g. `1.4`) and explicitly forbids prefixing them with `@` (e.g. `@1.4`), which was generating invalid kcli commands.
188
+ - **Large Quantity Parsing Fix**: Fixed a bug where any order quantity >= 1000 (e.g., 2665, 2405) was skipped by the CLI parser because it was assumed to be an option strike price.
189
+ - **Auto-Splitting on Position Exit**: Modified position exits/square-offs to route through `self.place_order` so that exit orders exceeding the exchange freeze limit (e.g., 1800 for Nifty) are automatically sliced into separate child orders instead of getting rejected by Zerodha.
190
+ - **Smooth TUI Scrolling & Sizing Fix**: Rebuilt the scroll bindings for the Tuesday Advisor and Option Chain panes to delegate vertical scrolling directly to prompt-toolkit's native buffer cursor movement. This unifies mouse wheel and keyboard navigation under a single native mechanism, resolving the scroll-lock and viewport snap-back issues permanently.
191
+
192
+ ---
193
+
194
+ ### 0.1.0b11 — 2026-06-28
195
+
196
+ **New Features:**
197
+ - **Action Bar SQUAREOFF Button**: Purple button pre-filling the `exit near-week` command to square off near-week weekly options on selected or all accounts concurrently.
198
+ - **Natural Language Interface (NLI) [Very Basic]**: Translates slash (`/`) command requests into kcli chained orders. Runs 100% offline for symbol lookup using active positions, and routes queries through the Gemini 2.5 Flash API.
199
+ - **SQLite Session Recorder**: Background thread records order executions, positions, and market indices snapshots metadata to `~/.kcli/data.db` for trade performance reporting.
200
+ - **Tuesday Option Strangle Advisor**: Dynamic capital allocation and lot sizing plan mapped to F4 key.
201
+
202
+ **Bug Fixes:**
203
+ - **Proxy Bypass & IPv4 DNS lookup patch**: Patched the NLI network call to force IPv4 DNS queries and bypass local terminal proxies, reducing Gemini API lookup latency from 2400ms to 2ms on macOS.
204
+ - **Spacious 3-Row Prompt Height**: Expanded the command input row statically to 3 lines with text wrapping enabled, so long chained commands and confirmations are fully readable.
205
+ - **Authentication Client Method**: Added the missing `is_authenticated` helper method to the `KCLIClient` wrapper.
206
+ - **Advisor Singleton Import path**: Resolved the `_manager` import exception in `cli/advisor.py` by directing it to the correct singleton location in `cli/api_client.py`.
207
+
208
+ ---
209
+
210
+ ### 0.1.0b10 — 2026-06-25
211
+
212
+ **Bug Fixes:**
213
+ - **WebSocket reconnect crash on startup**: `reconnect` and `reconnect_max_tries` were incorrectly passed to `ticker.connect()`, which does not accept them. These params now correctly go to the `KiteTicker()` constructor. Fixes: `KiteTicker.connect() got an unexpected keyword argument 'reconnect'`.
214
+ - **Reduced reconnect attempts to 5**: Max reconnect retries tuned down from 50 to 5 (~60s recovery window with exponential backoff) to stop faster on persistent failures.
215
+
216
+ ---
217
+
218
+ ### 0.1.0b9 — 2026-06-24
219
+
220
+ **Bug Fixes:**
221
+ - **WebSocket auto-reconnect on network drops**: The `KiteTicker` was previously started without reconnect settings, so a transient TCP drop (error 1006 — peer closed connection) would silently kill the WebSocket permanently, freezing NIFTY indices, position LTPs, and all live data. Reconnect is now enabled with up to **10 attempts** and exponential backoff.
222
+ - **Auth-failure reconnect storm prevention**: If the WebSocket fails due to a 403 / expired token, the ticker now immediately stops reconnecting and shows a clear message (`Run kcli init to re-authenticate`) instead of hammering Zerodha indefinitely.
223
+
224
+ ---
225
+
226
+ ### 0.1.0b8 — 2026-06-24
227
+
228
+ **Bug Fixes:**
229
+ - **Account-aware order routing**: Fixed a bug where clicking an account (e.g. `@SS1009`) correctly updated the TUI context, but placing an order for a symbol that also existed in another account routed the order to that other account. Symbol resolution and action bar position matching are now scoped to the selected account context.
230
+ - **Improved login/auto-login error logging**: `complete_login` and `auto_login` in `kite_manager.py` now log the full exception message and stack trace, making proxy and token failures much easier to diagnose.
231
+
232
+ **Enhancements:**
233
+ - **Filled quantity display in orders pane**: Both pending (F1) and executed (F2) orders now always show `filled/total` format (e.g. `0/910`, `130/910`, `910/910`) so you can track partial fills at a glance.
234
+ - **Live order update messages**: The WebSocket order update log in the status pane now shows `filled/total` quantity (e.g. `SELL 130/910 NIFTY25JUN25800PE -> OPEN`) in real time as fills arrive.
235
+
236
+ ---
237
+
238
+ ### 0.1.0b7 — 2026-06-19
239
+
240
+ **Bug Fixes:**
241
+ - **Position price updates via WebSocket**: Position LTPs were not updating in the TUI because `instrument_token` was missing from the dict returned by `get_positions()`. Adding the key allows the WebSocket ticker to correctly map tick data to positions.
242
+
243
+ **New Features:**
244
+ - **Pending order modification**: Select a pending order (`select order <id>` or `s o <id>`) and use `order <id> <qty> <price>` to modify it, with a double-confirmation prompt before execution.
245
+ - **Pending order cancellation**: Use `cancel [id]` (or click CANCEL after selecting an order) to cancel a pending order with confirmation.
246
+ - **REFRESH button**: A `REFRESH` button on the TUI quick action bar immediately triggers a full sync of positions, orders, margins, and indices across all accounts.
247
+ - **Context-aware MODIFY/CANCEL buttons**: The quick action bar swaps BUY/SELL for MODIFY/CANCEL buttons when a pending order is selected.
248
+ - **ORDERS.md documentation**: Added a comprehensive reference guide for all order types, syntax, lot notation (`L`), command chaining (`&&`), and keyboard shortcuts.
249
+
250
+ ---
251
+
252
+ ### 0.1.0b6 — 2026-06-15
253
+
254
+ **New Features:**
255
+ - **Command chaining (`&&`)**: Chain multiple commands in a single input, e.g. `account SS1009 && buy SBIN 10`.
256
+ - **Context-aware BUY/SELL buttons**: Action bar buttons dynamically pre-fill order syntax based on whether an account, position, or nothing is selected.
257
+ - **Lot-size notation**: Specify quantities in lots using `L` suffix (e.g. `2L` for 2 lots).
258
+ - **Position ID shortcuts**: Reference positions by their row index number instead of full symbol name.
259
+
@@ -0,0 +1,16 @@
1
+ cli/__init__.py,sha256=q56v_VXSeqnIVu6WF4eQjALmAYzXT8NZHqEwoCnmm4U,357
2
+ cli/advisor.py,sha256=jCI5rxbVPHWOsLMcTxnldC5IL1cLOqQWA1CNGGwV3sw,10349
3
+ cli/api_client.py,sha256=dRMciF520KToutREnkxiiLvlUM02KAwSz9qz_xMD8jk,15821
4
+ cli/config.py,sha256=T7_k02OsPa3XiFAfkTenwrEJH3-63D-SdJTZTAxvcVg,2330
5
+ cli/display.py,sha256=Y7xcevsM7GLPOkayu1m5b-EVb0cCn0RTt2ldQXfjblM,12395
6
+ cli/kite_manager.py,sha256=OzUNbirZWjUs2CQVOxzHjjvDpst-hk4akgB4cISBSc4,40908
7
+ cli/live_session.py,sha256=8V7vRbrJe2gm3h52rraiQf13T53ZTNEh28RK39NrYg0,177921
8
+ cli/main.py,sha256=OUgWxLIg_Kw86lVApHXIqi3CBXtpTjm0yVERsl7asWg,11918
9
+ cli/nli.py,sha256=6ssHbLb9s91ZUWeh50GZNrQ-FzroEfD8uilpiUE2vjI,6574
10
+ cli/recorder.py,sha256=10VabsHlPE7ACE7F7FzRwWpE2kcn_ho87xY76tw_G10,11883
11
+ cli/telegram_bot.py,sha256=0IXo1Xz3qpJ-SWafmr_uqZRCgEKAfehPrzG9S1XfZio,47155
12
+ kitecli-0.1.0.dist-info/METADATA,sha256=5IUemBV0ctvjTHauDfxLjIvuG45kttVFaQZ5P8OH7j4,14405
13
+ kitecli-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
14
+ kitecli-0.1.0.dist-info/entry_points.txt,sha256=kjjo2wIaq9WBefR1lgxN-agHqUvYGid5yRI8VydVXxg,38
15
+ kitecli-0.1.0.dist-info/top_level.txt,sha256=2ImG917oaVHlm0nP9oJE-Qrgs-fq_fGWgba2H1f8fpE,4
16
+ kitecli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ kcli = cli.main:app
@@ -0,0 +1 @@
1
+ cli