It looks like you're new here. If you want to get involved, click one of these buttons!
import schedule
import xlwings as xw
import kiteSettings
from kiteconnect import KiteConnect
import logging
import time
from datetime import datetime
kite = KiteConnect(kiteSettings.api_key)
kite.set_access_token(kiteSettings.access_token)
wbtest = xw.Book("xxxx.xlsm")
def order_place1(symbol, bs, qty, price1):
# Place an order
if bs == "BUY":
transaction_type1 = kite.TRANSACTION_TYPE_BUY,
elif bs == "SELL":
transaction_type1 = kite.TRANSACTION_TYPE_SELL,
try:
order_id = kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NFO,
tradingsymbol=symbol,
transaction_type=transaction_type1,
quantity=qty,
price=price1,
product=kite.PRODUCT_NRML,
order_type=kite.ORDER_TYPE_LIMIT
)
logging.info("Order placed. ID is: {}".format(order_id))
except Exception as e:
logging.info("Order placement failed: {}".format(e.message))
return order_id
def sch_chk():
try:
i = 51
while i < 72:
# wbtest.sheets("NIFTY50").range("AA"+str(i)).select()
if wbtest.sheets("BANKNIFTY").range("AA" + str(i)).value == wbtest.sheets("BANKNIFTY").range("B18").value:
BS1 = wbtest.sheets("BANKNIFTY").range("AA" + str(i)).offset(0, 1).value
sym1 = wbtest.sheets("BANKNIFTY").range("AA" + str(i)).offset(0, 11).value
prc1 = wbtest.sheets("BANKNIFTY").range("AA" + str(i)).offset(0, 4).value
qty1 = 300
a4 = order_place1(sym1, BS1, int(qty1), prc1)
wbtest.sheets("BANKNIFTY").range("AA" + str(i)).offset(0, 5).value = a4
print("Order BankNifty PE")
i = i + 1
print(datetime.now())
except:
pass
if __name__ == '__main__':
while True:
try:
sch_chk()
time.sleep(2)
except:
pass