Skip to content

Instantly share code, notes, and snippets.

@oldmonkABA
oldmonkABA / create-kiteconnect-candlestick-q.py
Last active August 1, 2024 05:32
Implementation of ticks to 1min and 15 mins candles in zerodha kiteconnect using python queues. This code is modified version of the code given in http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html. The difference is that in on_ticks functions the only action performed is that the ticks are place in a event queue. This …
################## Ticks to candles in kiteconnect python ####################
# Author : Arun B
# Reference : http://ezeetrading.in/Articles/Candles_formation_from_tick_data_zerodha.html
# Purpose : Convert ticks to candles by putting ticks in a queue. This redues time wasted in on_ticks function
################################################################################
from kiteconnect import KiteTicker
import datetime
from copy import copy
import queue
def instrument_token(data, symbol):
"""
This function will return the token number of the instrument from data
"""
return data[data.tradingsymbol == symbol].instrument_token.values[0]
def historical_data(symbol, from_date, to_date, interval):
"""
This function will return historical data of the instrument for specific period of days for specific interval
"""