KiteFeed API Reference¶
Retry Decorator¶
- aio_trader.AbstractFeeder.retry(max_retries=50, base_wait=2, max_wait=60)¶
Decorator that retries a function or method with exponential backoff in case of exceptions.
Retry terminates if response code is 403: Session Expired
- Parameters:
max_retries (float) – The maximum number of retry attempts. Default 50
base_wait – The initial delay in seconds before the first retry. Default 2
max_wait_time (float) – The maximum delay in seconds between retries. Default 60
Usage:
@retry(max_retries=5, base_wait=2, max_wait=60) async def your_function_or_method(*args, **kwargs): # Your function or method logic goes here pass
KiteFeed API¶
- class aio_trader.kite.KiteFeed(api_key: str = 'kitefront', user_id: str | None = None, enctoken: str | None = None, access_token: str | None = None, parse_data: bool = True, session: ClientSession | None = None, logger: Logger | None = None)¶
Websocket class for Zerodha Kite
Implements the
AbstractFeeder
base class- Parameters:
api_key (str) – KiteConnect api_key. Default is “kitefront” for Web login.
user_id (Optional[str]) – Optional user_id for Kite Web login.
enctoken (Optional[str]) – Optional enctoken for Kite Web login.
access_token (Optional[str]) – Optional KiteConnect access_token.
parse_data (bool) – If true, on_tick handler receives raw binary/text data. Default True.
session (Optional[aiohttp.ClientSession].) – Client Session for making HTTP requests.
logger (Optional[logging.Logger]) – logger instance for logging.
- Raises:
ValueError – If enctoken or access_token is not provided
ValueError – If enctoken is provided, but user_id is missing
ValueError – If access_token is provided, but api_key is the default value
- async KiteFeed.close()¶
Perform clean up operations to gracefully exit
- async KiteFeed.connect(**kwargs) None ¶
Connect and start the Websocket connection
Use the retry decorator @retry(max_retries=50, base_wait=2, max_wait=60)
- Parameters:
kwargs – Any keyword arguments to pass to aiohttp.ClientSession.ws_connect
- Type:
kwargs: Any
- async KiteFeed.subscribe_symbols(symbols: List[int] | Tuple[int], mode: str = 'quote') None ¶
Subscribe to live market feeds
- Parameters:
symbols (List[int] | Tuple[int]) – A collection of instrument tokens
mode (str) – Default quote. One of quote, ltp, full
- async KiteFeed.unsubscribe_symbols(symbols: List[int]) None ¶
Unsubscribe from live market feed
- Parameters:
symbols (List[int] | Tuple[int]) – A collection of instrument tokens