### Installing Build Dependencies on macOS/OSx Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This command initiates the installation of the Xcode command line tools on macOS. These tools include a C compiler necessary for building dependencies with C extensions when installing the kiteconnect library. ```Shell xcode-select --install ``` -------------------------------- ### Installing pdoc for Documentation Generation Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This command installs the pdoc library using pip. pdoc is a tool used to automatically generate API documentation from Python source code, as demonstrated in the subsequent snippet. ```Shell pip install pdoc ``` -------------------------------- ### Installing Build Dependencies on Debian/Ubuntu Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This command installs required development libraries (`libffi-dev`, `python-dev`, `python3-dev`) on Debian or Ubuntu systems. These are necessary for compiling C extensions used by some dependencies of the kiteconnect library. ```Shell apt-get install libffi-dev python-dev python3-dev ``` -------------------------------- ### Updating pip and setuptools for Installation Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This command updates pip and setuptools to their latest versions. This is recommended if you encounter issues during the kiteconnect installation, particularly if dependencies use C extensions that require compilation. ```Shell pip install -U pip setuptools ``` -------------------------------- ### Installing Kite Connect Python Client via pip Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This command installs or upgrades the Kite Connect Python client library using pip, the standard Python package installer. It fetches the latest version from PyPI. Ensure pip is up-to-date for best results. ```Shell pip install --upgrade kiteconnect ``` -------------------------------- ### Installing Build Dependencies on Centos/RHEL/Fedora Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This command installs required development libraries (`libffi-devel`, `python3-devel`, `python-devel`) on Centos, RHEL, or Fedora systems. These libraries are needed for compiling C extensions used by kiteconnect dependencies. ```Shell yum install libffi-devel python3-devel python-devel ``` -------------------------------- ### Using Kite Ticker WebSocket in Python Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This Python snippet demonstrates how to use the Kite Ticker for real-time market data via WebSockets. It shows initializing the ticker with API key and access token, defining callback functions for receiving ticks, handling connection success, and handling connection closure, then connecting to start the data stream. ```Python import logging from kiteconnect import KiteTicker logging.basicConfig(level=logging.DEBUG) # Initialise kws = KiteTicker("your_api_key", "your_access_token") def on_ticks(ws, ticks): # Callback to receive ticks. logging.debug("Ticks: {}".format(ticks)) def on_connect(ws, response): # Callback on successful connect. # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). ws.subscribe([738561, 5633]) # Set RELIANCE to tick in `full` mode. ws.set_mode(ws.MODE_FULL, [738561]) def on_close(ws, code, reason): # On connection close stop the main loop # Reconnection will not happen after executing `ws.stop()` ws.stop() # Assign the callbacks. kws.on_ticks = on_ticks kws.on_connect = on_connect kws.on_close = on_close # Infinite loop on the main thread. Nothing after this will run. # You have to use the pre-defined callbacks to manage subscriptions. kws.connect() ``` -------------------------------- ### Using Kite Connect REST API in Python Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This Python snippet demonstrates core Kite Connect API interactions: initializing the client, generating a session using a request token and secret, setting the access token, placing an order, fetching all orders, getting instrument lists, placing a mutual fund order, and cancelling a mutual fund order. Requires a valid API key and access token. ```Python import logging from kiteconnect import KiteConnect logging.basicConfig(level=logging.DEBUG) kite = KiteConnect(api_key="your_api_key") # Redirect the user to the login url obtained # from kite.login_url(), and receive the request_token # from the registered redirect url after the login flow. # Once you have the request_token, obtain the access_token # as follows. data = kite.generate_session("request_token_here", api_secret="your_secret") kite.set_access_token(data["access_token"]) # Place an order try: order_id = kite.place_order(tradingsymbol="INFY", exchange=kite.EXCHANGE_NSE, transaction_type=kite.TRANSACTION_TYPE_BUY, quantity=1, variety=kite.VARIETY_AMO, order_type=kite.ORDER_TYPE_MARKET, product=kite.PRODUCT_CNC, validity=kite.VALIDITY_DAY) logging.info("Order placed. ID is: {}".format(order_id)) except Exception as e: logging.info("Order placement failed: {}".format(e.message)) # Fetch all orders kite.orders() # Get instruments kite.instruments() # Place an mutual fund order kite.place_mf_order( tradingsymbol="INF090I01239", transaction_type=kite.TRANSACTION_TYPE_BUY, amount=5000, tag="mytag" ) # Cancel a mutual fund order kite.cancel_mf_order(order_id="order_id") # Get mutual fund instruments kite.mf_instruments() ``` -------------------------------- ### Running Unit Tests with setup.py Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This shell command executes the unit tests for the pykiteconnect library using the standard Python `setup.py` script. This is a common way to run tests in Python packages. ```Shell python setup.py test ``` -------------------------------- ### Generating HTML Documentation with pdoc Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This shell command uses pdoc to generate HTML API documentation for the `kiteconnect` package. The output is saved to the `docs` directory specified by `--html-dir`. This command allows developers to create readable documentation from the code's docstrings. ```Shell pdoc --html --html-dir docs kiteconnect ``` -------------------------------- ### Running Integration Tests with pytest and Credentials Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This shell command uses pytest to run integration tests located in `tests/integration/`. It requires `--api-key` and `--access-token` arguments to authenticate with the Kite Connect API for live testing. It also generates an HTML coverage report. ```Shell pytest -s tests/integration/ --cov-report html:cov_html --cov=./ --api-key api_key --access-token access_token ``` -------------------------------- ### Running Unit Tests with pytest and Coverage Source: https://github.com/zerodha/pykiteconnect/blob/master/README.md This shell command uses pytest to run the unit tests located in the `tests/unit` directory. The flags enable verbose output (`-s`), generate an HTML coverage report (`--cov-report html:cov_html`), and specify the package to measure coverage for (`--cov=./`). ```Shell pytest -s tests/unit --cov-report html:cov_html --cov=./ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.