Skip to main content

A Python module for placing bracket orders with Zerodha's KiteConnect API, featuring authentication, dashboard, Google Sheets integration, and customizable logging.

Project description

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

  1. Setup Credentials:

    • Create credentials/config.json with your Kite API details.
    • Create credentials/credentials.json with your Google Service Account key.
  2. Run the Script (example in order.py):

     # pip install --upgrade kite-order
    
     from kite_bracket_orders import BracketOrderPlacer, pip_install, pip_upgrade, login, KiteDashboard
    
     order_data = {
         "segment": "NSE",                  # "NSE" or "NFO"
         "product_type": "MIS",             # "MIS" or "CNC" or "NRML"
         "side": "SELL",                    # "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.60,               # Only used if LIMIT order
         "target_price": 7.80,
         "stop_loss_trigger": 7.50,
         "stop_loss_limit": 0               # only used if SL (not SL-M)
     }
    
     if __name__ == "__main__":
    
         pip_install()  # Check and install dependencies if needed
    
         enable_logging = False  # True or False (If False, logs are disabled (no log file output or redirection))
    
         print("\n📊  Select an option:")
         print("━" * 18)
         print("1. Run login")
         print("2. Show Dashboard")
         print("3. Place Order")
         print("\n4. pip upgrade")
    
         choice = input("\nSelect an option: ")
    
         if choice == "1":
             login()
         elif choice == "2":
             dash = KiteDashboard()
             dash.show_all()
         elif choice == "3":
             placer = BracketOrderPlacer(code_data=order_data, enable_logging=enable_logging) # Pass order_data for choice "1" and logging toggle
             placer.load_kite_login_name_show()
             placer.place_bracket_order() # No args needed - prompt happens inside
         elif choice == "4":
             pip_upgrade()
         else:
             print("Invalid option.")
    
  3. Run: python order.py

Configuration

  • config.json: Stores Kite API_KEY and ACCESS_TOKEN.
  • credentials.json: Google Sheets auth.
  • Logging: Set enable_logging=False to 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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kite_order-0.1.5.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kite_order-0.1.5-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file kite_order-0.1.5.tar.gz.

File metadata

  • Download URL: kite_order-0.1.5.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for kite_order-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3ee215edf5b83b97bb3d65eb411ef576eb0618dd3723bd111e1f4b5cad35d2d2
MD5 f73e5a98363f982aea3c9ee8ac8493a0
BLAKE2b-256 225b2adfebda4ccd636ad55bfd5d6ecf4b43d180d65f2fd72aeae42b8c14b846

See more details on using hashes here.

File details

Details for the file kite_order-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: kite_order-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for kite_order-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8ab9ff64dc6167712e06c46bda227e51e5d39ebafa94643d29acee3afc77ab8f
MD5 e91103336bb2deceaf56a4a4af7cd37e
BLAKE2b-256 de9a77704cc1bd299d1c834acf4beec37a7210a1bdd1af18abf000ac2d8a9817

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page