Understanding Zerodha’s place_order() Method in Python
Zerodha’s Kite Connect API stands out as one of the most powerful tools available to Indian traders.
It allows developers to place, modify, and monitor trades programmatically using simple Python code.
At the heart of this functionality lies a crucial method — place_order().
This method acts as the execution engine that places your buy or sell orders directly on the Zerodha trading platform.
In this blog, we’ll break down the purpose, parameters, and practical examples of the place_order() function so that you can start placing trades like a pro.

Purpose of place_order()
The place_order() method is used to place a new order (either BUY or SELL) in your Zerodha account via the Kite Connect API.
In simple terms, it sends your trading request — like buying Infosys shares or selling NIFTY futures — directly to the Zerodha servers.
You can use this function to place different types of orders including:
- Market Orders
- Limit Orders
- Stop-Loss (SL / SL-M) Orders
- Bracket Orders (BO)
- Cover Orders (CO)
- After Market Orders (AMO)
Function Definition
def place_order(
self,
variety,
exchange,
tradingsymbol,
transaction_type,
quantity,
product,
order_type,
price=None,
validity=None,
disclosed_quantity=None,
trigger_price=None,
squareoff=None,
stoploss=None,
trailing_stoploss=None,
tag=None
)
Description of Above code .
1. variety
Type of order variety. It specifies the kind of order you want to place.
Examples:
• "regular" – Normal orders
• "amo" – After Market Order
• "bo" – Bracket Order
• "co" – Cover Order
2.exchange
Exchange where the order is to be placed.
✅ Examples: "NSE", "BSE", "NFO", "MCX"
3.tradingsymbol
The trading symbol of the instrument.
✅ Example: "INFY", "RELIANCE", "NIFTY24OCTFUT"
4.transaction_type
Type of transaction you want to perform.
✅ Values:
• "BUY"
• "SELL"
5.quantity
Number of shares/lots you want to buy or sell.
6.product
Product type or margin category.
✅ Examples:
• "CNC" – Cash and Carry (for delivery)
• "MIS" – Intraday
• "NRML" – Normal (for F&O)
7.order_type
Specifies how the order should be executed.
✅ Examples:
• "MARKET" – Execute at current market price
• "LIMIT" – Execute at a specific price
• "SL" – Stop Loss (limit)
• "SL-M" – Stop Loss (market)
8.price
Price at which you want to buy/sell (used only for LIMIT or SL orders).
9.validity
How long the order will remain valid.
✅ Examples:
• "DAY" – Valid for the trading day
• "IOC" – Immediate or Cancel
10.disclosed_quantity
Part of total quantity you want to show in market depth. (Useful for big orders.)
11.trigger_price :The trigger price for SL or SL-M orders.
12.squareoff : Used only for BO/CO orders — specifies target profit in absolute terms.
13. stoploss : Used for BO/CO — specifies stop loss in absolute terms.
14.trailing_stoploss : Used for Bracket Orders (BO) — sets the trailing stop loss difference.
15. tag : A custom tag to identify the order (for tracking from your app).
Example
from kiteconnect import KiteConnect
import os
import datetime as dt
import pandas as pd
import numpy as np
import time
cwd = os.chdir("D:\GenAi\python\python basic\Strategy")
#generate trading session
access_token = open("access_token.txt",'r').read()
key_secret = open("api_key.txt",'r').read().split()
kite = KiteConnect(api_key=key_secret[0])
kite.set_access_token(access_token)
#get dump of all NSE instruments
instrument_dump = kite.instruments("NSE")
instrument_df = pd.DataFrame(instrument_dump)
def fetchInstrument(instrument_df,symbol):
"""Looks up instrument token for a given script from instrument dump"""
try:
return instrument_df[instrument_df.tradingsymbol==symbol].instrument_token.values[0]
except:
return -1
def fetchOHLC(ticker,interval,duration):
"""extracts historical data and outputs in the form of dataframe"""
instrument = fetchInstrument(instrument_df,ticker)
data = pd.DataFrame(kite.historical_data(instrument,dt.date.today()-dt.timedelta(duration), dt.date.today(),interval))
data.set_index("date",inplace=True)
return data
def bollingerband(df):
df = df.iloc[:-1,:]
df = pd.DataFrame(df)
sma=20
dev=2
df.dropna(inplace=True)
df["sma"]=df["close"].rolling(sma).mean()
df["lower"]=df["sma"]-df["close"].rolling(sma).std()*dev
df["upper"]=df["sma"]+df["close"].rolling(sma).std()*dev
df["buy_signal"] = df["close"] <= df["lower"]
df["signals"] = np.where(df["close"] <= df["lower"], "BUY",
np.where(df["close"] >= df["upper"], "SELL", "HOLD"))
df.dropna(inplace=True)
return df
def rsi(df, n):
delta = df["close"].diff().dropna()
u = delta * 0
d = u.copy()
u[delta > 0] = delta[delta > 0]
d[delta < 0] = -delta[delta < 0]
u[u.index[n-1]] = np.mean( u[:n]) # first value is average of gains
u = u.drop(u.index[:(n-1)])
d[d.index[n-1]] = np.mean( d[:n]) # first value is average of losses
d = d.drop(d.index[:(n-1)])
rs = u.ewm(com=n,min_periods=n).mean()/d.ewm(com=n,min_periods=n).mean()
return 100 - 100 / (1+rs)
def run(capital):
a,b = 0,0
for ticker in tickers:
try:
df = fetchOHLC(ticker,"day",2*365)
df = df.iloc[:-1,:]
quantity = 100
df=bollingerband(df)
today_bb_row=df.iloc[-1]
isbullisbearish=today_bb_row.buy_signal
signals=today_bb_row.signals
rsival=rsi(df,14)
rsival.dropna(inplace=True)
today_rsi_row = rsival.iloc[-1]
if signals =='BUY' and today_rsi_row <=35:
print("Buy Signal for ",ticker)
kite.place_order(tradingsymbol=symbol,
exchange=kite.EXCHANGE_NSE,
transaction_type=signals,
quantity=quantity,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_MIS,
variety=kite.VARIETY_REGULAR)
elif signals =='SELL' and today_rsi_row >=70:
print("Sell Signal for ",ticker)
kite.place_order(tradingsymbol=symbol,
exchange=kite.EXCHANGE_NSE,
transaction_type=signals ,
quantity=quantity,
order_type=kite.ORDER_TYPE_MARKET,
product=kite.PRODUCT_MIS,
variety=kite.VARIETY_REGULAR)
except:
print("API error for ticker :",ticker)
tickers = ["TATAMOTORS","INFY","HINDALCO","ADANIENT","TCS","BHARTIARTL",
"INDUSINDBK","TECHM","VEDL","SHRIRAMFIN","HCLTECH","LT","MARUTI",
"WIPRO","ONGC","NTPC","ICICIBANK","BEL","HDFCBANK","BAJFINANCE","HDFCLIFE",
"ADANIPORTS","TITAN","ASIANPAINT","POWERGRID","TRENT","TATASTEEL",
"HINDUNILVR","JIOFIN","EICHERMOT","AXISBANK","HEROMOTOCO","CIPLA","ITC",
"COALINDIA","SBIN","KOTAKBANK","ULTRACEMCO","BAJAJ-AUTO","SUNPHARMA","GRASIM",
"JSWSTEEL","SBILIFE","DRREDDY","RELIANCE","M&M","TATACONSUM","NESTLEIND",
"APOLLOHOSP","BAJAJFINSV","ETERNAL"]
capital = 3000
run(capital)