Orders not getting placed

Jay_1412
I was testing algo for zerodha api using python for first time.
The code is getting executed but order is not getting executed in zerodha.
I am trying AMO order just for trial but no order is being fetched by zerodha.
Please let me know what i am doing wrong.

Below is the code:-
For login:-
from kiteconnect import KiteConnect
from kiteconnect import KiteTicker
import pdb
import pandas as pd
import datetime
import os


api_k = "nd3n0deymftxu54f" # api_key
api_s = "5zqhd460n2895oaruvklg0z0tegzt0sf" # api_secret
filename = str(datetime.datetime.now().date()) + ' token' + '.txt'




def read_access_token_from_file():
file = open(filename, 'r+')
access_token = file.read()
file.close()
return access_token


def send_access_token_to_file(access_token):
file = open(filename, 'w')
file.write(access_token)
file.close()


def get_login(api_k, api_s):
global kws, kite
kite = KiteConnect(api_key=api_k)
print("Logging into zerodha")


if filename not in os.listdir():

print("[*] Generate Request Token : ", kite.login_url())
request_tkn = input("[*] Enter Your Request Token Here : ")
data = kite.generate_session(request_tkn, api_secret=api_s)
access_token = data["access_token"]
kite.set_access_token(access_token)
kws = KiteTicker(api_k, access_token)
send_access_token_to_file(access_token)

elif filename in os.listdir():
print("You have already loggged in for today")
access_token = read_access_token_from_file()
kite.set_access_token(access_token)
kws = KiteTicker(api_k, access_token)

return kite

kite = get_login(api_k, api_s)

FOR ORDER PLACING CODE IS AS BELOW:-
import zrd_login
import pdb
from pprint import pprint

kite = zrd_login.kite

margin = kite.margins()


wathclist = ["PFC", "TITAN", "RECLTD", "JUBLFOOD", "EXIDEIND", "BOSCHLTD", "SUNTV", "MARUTI", "HINDUNILVR", "IBULHSGFIN", "MUTHOOTFIN", "PETRONET", "SUNPHARMA", "GODREJPROP", "LUPIN", "APOLLOHOSP", "AMARAJABAT", "DRREDDY", "CADILAHC", "TORNTPOWER", "DABUR", "ASIANPAINT", "TATACHEM", "CIPLA", "SHREECEM", "COALINDIA", "IGL", "BIOCON", "MGL", "TATACONSUM", "INFY", "M&M", "PNB", "MRF", "INFRATEL", "DLF", "BALKRISIND", "ICICIPRULI", "TVSMOTOR", "RAMCOCEM", "HEROMOTOCO", "RELIANCE", "CUMMINSIND", "DIVISLAB", "ESCORTS", "BRITANNIA", "NESTLEIND", "ZEEL", "GLENMARK", "GRASIM", "GMRINFRA", "UBL", "IDEA", "M&MFIN", "SBILIFE", "BATAINDIA", "AUROPHARMA", "BERGEPAINT", "HAVELLS", "VOLTAS", "GODREJCP", "TORNTPHARM", "MANAPPURAM", "ACC", "BHARATFORG", "MARICO", "PIDILITIND", "GAIL", "ICICIGI", "UPL", "NATIONALUM", "ADANIPORTS", "NMDC", "BHEL", "HDFCBANK", "APOLLOTYRE", "HCLTECH", "BAJAJ-AUTO", "PEL", "KOTAKBANK", "JSWSTEEL", "CONCOR", "MFSL", "JINDALSTEL", "WIPRO", "COFORGE", "L&TFH", "BEL", "ADANIENT", "ITC", "VEDL", "ULTRACEMCO", "BANKBARODA", "ASHOKLEY", "POWERGRID", "TATASTEEL", "ONGC", "HINDPETRO", "SAIL", "AMBUJACEM", "HDFC", "MCDOWELL-N", "TCS", "BHARTIARTL", "TECHM", "PAGEIND", "LICHSGFIN", "NAUKRI", "BPCL", "COLPAL", "LT", "AXISBANK", "TATAMOTORS", "SBIN", "CHOLAFIN", "SRTRANSFIN", "ICICIBANK", "HDFCLIFE", "SRF", "SIEMENS", "NTPC", "FEDERALBNK", "BAJFINANCE", "IDFCFIRSTB", "TATAPOWER", "MINDTREE", "INDUSINDBK", "MOTHERSUMI", "BAJAJFINSV", "HINDALCO", "EICHERMOT", "BANDHANBNK", "INDIGO", "CANBK", "IOC", "PVR", "RBLBANK"]


pdb.set_trace()

for name in wathclist:
zname = 'NSE:' + name
ohlc = kite.ohlc([zname])

ltp = ohlc[zname]['last_price']

if 100 < ltp < 500:
kite.place_order(variety = kite.VARIETY_AMO, exchange= kite.EXCHANGE_NSE, tradingsymbol = name, transaction_type = kite.TRANSACTION_TYPE_BUY, quantity = int(ltp), product = kite.PRODUCT_MIS, order_type = kite.ORDER_TYPE_MARKET, price = None, validity = None, disclosed_quantity = None, trigger_price = None, squareoff = None, stoploss = None, trailing_stoploss = None, tag = None)
print(name, ltp)

Tagged:
  • sujith
    Can you run with debug logs enabled and paste the logs here? Make sure to remove app and client specific tokens.
Sign In or Register to comment.