Kite Bracket Orders
A Python module for placing bracket orders with Zerodha's KiteConnect API. It includes features like automated authentication, a dashboard for viewing margins/holdings/positions/orders, Google Sheets integration for trade plans, customizable logging, and market hour checks with AMO (After Market Order) support.
Features
- Bracket Order Placement: Place entry orders with target and stop-loss, including monitoring and modification.
- Authentication: Automatic login with dependency installation, config management, and session token handling.
- Dashboard: View account margins, holdings, positions, and recent orders in a clean terminal format.
- Google Sheets Integration: Load trade plans from a specified sheet for easy data-driven trading.
- Logging Toggle: Enable/disable logging to file with a simple flag (no impact on terminal output when disabled).
- Market Checks: Detects closed markets/weekends and prompts for AMO orders.
Dependencies
- kiteconnect
- gspread
- oauth2client
- colorama
These are automatically installed via pip.
Usage
-
Setup Credentials:
- Create
credentials/config.jsonwith your Kite API details. - Create
credentials/credentials.jsonwith your Google Service Account key.
- Create
-
Run the Script (example in order.py):
# pip install --upgrade kite-order from kite_bracket_orders import BracketOrderPlacer, KiteDashboard, KiteAlerts, safe_print, login, pip_upgrade, pip_install order_data = { "segment" : "NSE" , # "NSE" or "NFO" "product_type" : "MIS" , # "MIS" or "CNC" or "NRML" "side" : "BUY" , # "BUY" or "SELL" "entry_order_type" : "LIMIT" , # "LIMIT" or "MARKET" "sl_type" : "SL-M" , # choose: "SL" or "SL-M" "symbol" : "IDEA" , # e.g. "IDEA", "RELIANCE", or "NIFTY24JUL20000CE" "quantity" : 1 , # Must match lot size for options; 1+ for stocks "entry_price" : 7.34 , # Only used if LIMIT order "target_price" : 7.45 , "stop_loss_trigger" : 7.28 , "stop_loss_limit" : 7.27 # only used if SL (not SL-M) } if __name__ == "__main__": # pip_install() # Optional: Uncomment if you want to auto-install packages enable_logging = False # Toggle True to enable logging while True: safe_print("\n📊 Select an option:") safe_print("━" * 35) safe_print("1. 🔐 Kite Login") safe_print("2. 📈 Show Dashboard") safe_print("\n3. 📢 Manage Alerts") safe_print("\n4. 🛒 Place Order") safe_print("5. 🛍️ Track Entry Order") safe_print("6. 🎯 Track SL / Target") safe_print("\n7. 🛠️ Upgrade pip") safe_print("8. ❌ Exit") choice = input("\n👉 Select an option (1-8): ").strip() if choice == "1": login() elif choice == "2": dash = KiteDashboard() dash.show_all() elif choice == "3": # 🚀 Launch KiteAlerts sub-menu alerts = KiteAlerts() alerts.menu() # when exited, control returns here elif choice == "4": placer = BracketOrderPlacer(code_data=order_data, enable_logging=enable_logging) placer.load_kite_login_name_show() placer.place_bracket_order() elif choice == "5": placer = BracketOrderPlacer(code_data=order_data, enable_logging=enable_logging) placer.load_kite_login_name_show() safe_print("\n📋 Enter Entry Order Details:") entry_order_id = input("🔢 Entry Order ID: ").strip() target_price = float(input("🎯 Target Price: ")) stop_loss_trigger = float(input("🛑 Stop Loss Trigger Price: ")) sl_type = input("🛑 Stop Loss Type (SL or SL-M): ").strip().upper() stop_loss_limit = float(input("🛑 Stop Loss Limit (if SL, else enter 0): ")) if sl_type == "SL" else 0 placer.track_entry_order(entry_order_id, target_price, stop_loss_trigger, stop_loss_limit, sl_type) elif choice == "6": placer = BracketOrderPlacer(code_data=order_data, enable_logging=enable_logging) placer.load_kite_login_name_show() safe_print("\n📋 Enter SL/Target Order Details:") target_order_id = input("🎯 Target Order ID: ").strip() sl_order_id = input("🛑 Stop Loss Order ID: ").strip() placer.track_sl_target_orders(target_order_id, sl_order_id) elif choice == "7": pip_upgrade() elif choice == "8": safe_print("\n👋 Exiting... Have a profitable day!") break else: safe_print("❗ Invalid option. Please try again.") -
Run: python order.py
Configuration
- config.json: Stores Kite API_KEY and ACCESS_TOKEN.
- credentials.json: Google Sheets auth.
- Logging: Set
enable_logging=Falseto disable log files.
License
MIT License. See LICENSE for details.
Contributing
Fork the repo and submit a pull request. Issues and feature requests are welcome!
Metadata
Release files for kite-order 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kite_order-0.2.1.tar.gz | 17.9 kB | Without provenance | Details for kite_order-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kite_order-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for kite_order-0.2.1-py3-none-any.whl |
Total release size: 37.8 kB
Release files / kite_order-0.2.1.tar.gz
| Download URL | kite_order-0.2.1.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f047534b0f95c9151b40aded75f77019e263dd6573613d98afe77bf261aa626
|
|
BLAKE2b-256 checksum How to use checksums |
efd0c4943c49c3a6e6c5b69f0fdeab2b109ef0683cd9b19db235effaa44e89b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / kite_order-0.2.1-py3-none-any.whl
| Download URL | kite_order-0.2.1-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09f03f2235edbe154cdd51cc4fb2e610021555aca5dd8b15de0d6e7cfc42289c
|
|
BLAKE2b-256 checksum How to use checksums |
baa22754cbeaf7adeb430c3f814e172d35e938eb27a20d08ec96abdac91adfc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for kite-order 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.