This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kiteconnect import KiteConnect | |
from selenium import webdriver | |
api_key = <YOUR API KEY> | |
api_secret = <YOUR API SECRET> | |
chromedriver_path = <PATH TO YOUR CHROMEDRIVER> | |
kite = KiteConnect(api_key = api_key) | |
#start chrome using selenium webdriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# launch chrome and open zerodha website | |
from selenium import webdriver | |
from time import sleep | |
from pyotp import TOTP | |
kite = KiteConnect(api_key) | |
service = webdriver.chrome.service.Service('./chromedriver.exe') | |
service.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Minute(): | |
def __init__(self): | |
self.login(webdriver_path, url, user_id, pwd, totp) | |
self.inspect(x_dev_tools,y_dev_tools,x_bottom_symbol,y_bottom_symbol,x_network,y_network,x_xhr,y_xhr,x_refresh,y_refresh) | |
self.d1 = self.minute_data(x_day_chart,y_day_chart,x_min_chart,y_min_chart,x_minute_url,y_minute_url,x_response,y_response,x_data,y_data) | |
def login(self, webdriver_path, url, user_id, pwd, totp): | |
# function body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import pandas as pd | |
def final_data(self, data): | |
candleinfo = data['data']['candles'] | |
df = pd.DataFrame(candleinfo, columns = ['time','open','high','low','close','volume','openinterest']) | |
df['time'] = pd.to_datetime(df.time, format = '%Y-%m-%dT%H:%M:%S') | |
date = datetime.datetime.now() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pyperclip | |
def minute_data(self,x_day_chart,y_day_chart,x_min_chart,y_min_chart,x_minute_url,y_minute_url,x_response,y_response,x_data,y_data): | |
#convert day to minute | |
sleep(2) | |
pg.click(x_day_chart , y_day_chart, interval=1) | |
#select 1 minute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install pyautogui | |
import pyautogui as pg | |
def inspect(self, x_dev_tools,y_dev_tools,x_bottom_symbol,y_bottom_symbol,x_network,y_network,x_xhr,y_xhr,x_refresh,y_refresh): | |
""" | |
This function will open developer tools and navigate to network panel. | |
Input parameters are the coordinates of buttons on screen. | |
""" | |
#click on inspect menu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stock_1(self, driver): | |
""" | |
This function finds BankNifty future and gets its chart | |
""" | |
#marketwatch | |
sleep(1) | |
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div/div/div[1]/a[1]/span").click() | |
sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from pyotp import TOTP | |
from time import sleep | |
def login(self, webdriver_path, url, user_id, pwd, totp): | |
""" | |
This function will login to zerodha account with inspect element opened. | |
""" | |
service = webdriver.chrome.service.Service(webdriver_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
ticker_symbol = "NSE:GLENMARK" | |
trading_symbol = "GLENMARK" | |
quantity = 1 | |
#The time at which we want to place order (24 hr format) | |
entry_hour = 13 | |
entry_minute = 00 |
NewerOlder