Skip to main content

Connect V3 to V4 Migration Of Python Code

API Parameters
V3 V4

logout


from thefirstock import thefirstock
logout = thefirstock.firstock_logout()
from thefirstock import thefirstock
logout = thefirstock.firstock_logout(userId="{{userId}}")

User details


from thefirstock import thefirstock
userDetails = thefirstock.firstock_userDetails()
from thefirstock import thefirstock
userDetails = thefirstock.firstock_userDetails(userId="{{userId}}")

placeorder


from thefirstock import thefirstock
placeOrder = thefirstock.firstock_placeOrder(
exchange="NSE",
tradingSymbol="ITC-EQ",
quantity="1",
price="300",
product="I",
transactionType="B",
priceType="LMT",
retention="DAY",
triggerPrice="0",
remarks="Python Package Order"
)
from thefirstock import thefirstock
placeOrder = thefirstock.firstock_placeOrder(
userId="{{userId}}",
exchange="NSE",
tradingSymbol="ITC-EQ",
quantity="1",
price="300",
product="I",
transactionType="B",
priceType="LMT",
retention="DAY",
triggerPrice="0",
remarks="Python Package Order"
)

Order margin


from thefirstock import thefirstock
orderMargin = thefirstock.firstock_orderMargin(
exchange="NSE",
tradingSymbol="ITC-EQ",
quantity="1",
priceType="LMT",
product="C",
price="350",
transactionType="B"
)
from thefirstock import thefirstock
orderMargin = thefirstock.firstock_orderMargin(
userId="{{userId}}",
exchange="NSE",
tradingSymbol="ITC-EQ",
quantity="1",
priceType="LMT",
product="C",
price="350",
transactionType="B"
)

Order book


from thefirstock import thefirstock
orderBook = thefirstock.firstock_orderBook()
from thefirstock import thefirstock
orderBook = thefirstock.firstock_orderBook(userId="{{userId}}")

Cancel order


from thefirstock import thefirstock
cancelOrder = thefirstock.firstock_cancelOrder(
orderNumber="11030800009600" )
from thefirstock import thefirstock
cancelOrder = thefirstock.firstock_cancelOrder(
userId="{{userId}}",
orderNumber="23111100000112" )

Modify order


from thefirstock import thefirstock
modifyOrder = thefirstock.firstock_ModifyOrder(
orderNumber="11030800009600",
quantity="1",
price="301",
triggerPrice="301",
exchange="NSE",
tradingSymbol="ITC-EQ",
priceType="LMT"
)
from thefirstock import thefirstock
modifyOrder = thefirstock.firstock_ModifyOrder(
userId="{{userId}}",
orderNumber="23111100000112",
quantity="1",
price="301",
triggerPrice="301",
exchange="NSE",
tradingSymbol="ITC-EQ",
priceType="LMT"
)

Single order history


from thefirstock import thefirstock
singleOrderHistory = thefirstock.firstock_SingleOrderHistory(
orderNumber="11030800009600" )
from thefirstock import thefirstock
singleOrderHistory = thefirstock.firstock_SingleOrderHistory(
userId="{{userId}}",
orderNumber="23111100000112" )

Trade book


from thefirstock import thefirstock
tradeBook = thefirstock.firstock_TradeBook()
from thefirstock import thefirstock
tradeBook = thefirstock.firstock_TradeBook(
userId="{{userId}}" )

Position book


from thefirstock import thefirstock
PB= thefirstock.firstock_PositionBook()
from thefirstock import thefirstock
positionBook = thefirstock.firstock_PositionBook(userId="{{userId}}")

Product conversion


from thefirstock import thefirstock
convertProduct = thefirstock.firstock_ConvertProduct(
transactionType="B",
tradingSymbol="ITC-EQ",
quantity="1",
product="C",
previousProduct="I",
positionType="DAY",
exchange="NSE"
)
from thefirstock import thefirstock
convertProduct = thefirstock.firstock_ConvertProduct(
userId="{{userId}}",
transactionType="B",
tradingSymbol="ITC-EQ",
quantity="1",
product="C",
previousProduct="I",
positionType="DAY",
exchange="NSE"
)

holdings


from thefirstock import thefirstock
holdings = thefirstock.firstock_Holding()
from thefirstock import thefirstock
holdings = thefirstock.firstock_Holding(userId="{{userId}}")

limits


from thefirstock import thefirstock
limits = thefirstock.firstock_Limits()
from thefirstock import thefirstock
limits = thefirstock.firstock_Limits(userId="PV0013")

Basket margin


from thefirstock import thefirstock
basketMargin = thefirstock.firstock_BasketMargin(
basket=[
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23P17000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23C19000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY23FEB23C19000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
}
]
)
from thefirstock import thefirstock
basketMargin = thefirstock.firstock_BasketMargin(
userId="{{userId}}",
basket=[
{
"exchange": "NFO",
"tradingSymbol": "NIFTY16NOV23P19600",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY16NOV23P19400",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
},
{
"exchange": "NFO",
"tradingSymbol": "NIFTY16NOV23P20000",
"quantity": "50",
"transactionType": "S",
"price": "0",
"product": "M",
"priceType": "LMT"
}
]
)

Get Quotes


from thefirstock import thefirstock
getQuotes = thefirstock.firstock_getQuote(
exchange="NSE",
token="26000"
)
from thefirstock import thefirstock
gQ = thefirstock.firstock_getQuote(
userId="{{userId}}",
exchange="BFO",
tradingSymbol="ZEEL24JAN285PE"
)

Get Quotes LTP


from thefirstock import thefirstock
getQuoteLTP = thefirstock.firstock_getQuoteLTP(
exchange="NSE",
token="26000"
)
from thefirstock import thefirstock
gQ = thefirstock.firstock_getQuoteLTP(
userId="{{userId}}",
exchange="BFO",
tradingSymbol="ZEEL24JAN285PE"
)

Get Multi Quotes


from thefirstock import thefirstock
getMultiQuotes = thefirstock.firstock_getMultiQuote(
dataToken=[
{
"exchange": "NSE",
"token": "26000"
},
{
"exchange": "NFO",
"token": "55101"
}
]
)
from thefirstock import thefirstock
mQ = thefirstock.firstock_getMultiQuote(
userId="{{userId"}},
dataToken=[
{
"exchange": "NSE",
"tradingSymbol": "Nifty 50"
},
{
"exchange": "NSE",
"tradingSymbol": "Nifty Bank"
}
]
)

Get Multi Quotes LTP


from thefirstock import thefirstock
getMultiQuotesLTP = thefirstock.firstock_getMultiQuoteLTP(
dataToken=[
{
"exchange": "NSE",
"token": "26000"
},
{
"exchange": "NFO",
"token": "55101"
}
]
)
from thefirstock import thefirstock
mQ = thefirstock.firstock_getMultiQuoteLTP(
userId="{{userId"}},
dataToken=[
{
"exchange": "NSE",
"tradingSymbol": "Nifty 50"
},
{
"exchange": "NSE",
"tradingSymbol": "Nifty Bank"
}
]
)

Search scrips


from thefirstock import thefirstock
searchScrips = thefirstock.firstock_SearchScrips(
stext="ITC"
)
from thefirstock import thefirstock
searchScrips = thefirstock.firstock_SearchScrips(
userId="{{userId}}",
stext="ITC"
)

Get security info


from thefirstock import thefirstock
getSecurityInfo = thefirstock.firstock_getSecurityInfo(
exchange="NSE",
token="22"
)
from thefirstock import thefirstock
getSecurityInfo = thefirstock.firstock_getSecurityInfo(
exchange="NSE",
tradingSymbol="ACC-EQ",
userId="{{userId}}"
)

Get index list


from thefirstock import thefirstock
getIndexList = thefirstock.firstock_getIndexList(
exchange="NSE"
)
from thefirstock import thefirstock
getIndexList = thefirstock.firstock_getIndexList(
userId="{{userId}}",
exchange="NSE"
)

Get option chain


from thefirstock import thefirstock
optionChain = thefirstock.firstock_OptionChain(
exchange="NFO",
tradingSymbol="NIFTY23FEB23C18000",
strikePrice="18000",
count="5"
)
from thefirstock import thefirstock
optionChain = thefirstock.firstock_OptionChain(
exchange="NFO",
tradingSymbol="NIFTY21DEC23P21000",
strikePrice="21000",
count="5",
userId="{{userId}}"
)

Span calculator


from thefirstock import thefirstock
spanCalculator = thefirstock.firstock_SpanCalculator(
dataList=[
{
"exchange": "NFO",
"instrumentName": "",
"symbolName": "NIFTY",
"expireDate": "23-FEB-2023",
"optionType": "CE",
"strikePrice": "17000",
"netQuantity": "50"
},
{
"exchange": "NFO",
"instrumentName": "",
"symbolName": "BANKNIFTY",
"expireDate": "23-FEB-2023",
"optionType": "PE",
"strikePrice": "40000",
"netQuantity": "-25"
}
]
)
from thefirstock import thefirstock
spanCalculator = thefirstock.firstock_SpanCalculator(
dataList=[
{
"exchange": "NFO",
"symbolName": "NIFTY",
"expireDate": "21-DEC-2023",
"instrumentName": "OPTIDX",
"optionType": "CE",
"strikePrice": "21500",
"netQuantity": "50"
}
],
userId="{{userId}}"
)

Time Price Series Regular interval


from thefirstock import thefirstock
timePriceSeries = thefirstock.firstock_TimePriceSeries(
exchange="NSE",
token="22",
startTime="16/08/2022 09:45:32",
endTime="15/02/2023 13:45:32",
interval="5"
)
from thefirstock import thefirstock timePriceSeries = thefirstock.firstock_TimePriceSeries(
userId="{{userId}}",
exchange="NSE",
tradingSymbol="Nifty 50",
startTime="13/02/2023 09:45:45",
endTime="13/12/2023 13:56:34",
interval="30"
)

Time Price Series Day interval


from thefirstock import thefirstock
timePriceSeries = thefirstock.firstock_TimePriceSeries(
exchange="NSE",
token="RELIANCE-EQ",
startTime="16/08/2022 09:45:32",
endTime="15/02/2023 13:45:32",
interval="DAY"
)
from thefirstock import thefirstock
timePriceSeries = thefirstock.firstock_TimePriceSeries(
userId="{{userId}}",
exchange="NSE",
tradingSymbol="Nifty 50",
startTime="13/02/2023 09:45:45",
endTime="13/12/2023 13:56:34",
interval="DAY"
)

Bear put spread


from thefirstock import thefirstock
BPS = thefirstock.firstock_BearPutSpread(
symbol="NIFTY",
putBuyStrikePrice="18000",
putSellStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello"
)
from thefirstock import thefirstock
BPS = thefirstock.firstock_BearPutSpread(
symbol="NIFTY",
putBuyStrikePrice="18000",
putSellStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
userId="{{userId}}"
)

Bull call spread


from thefirstock import thefirstock
BCS = thefirstock.firstock_BullCallSpread(
symbol="NIFTY",
callBuyStrikePrice="18000",
callSellStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="15",
remarks="Hello"
)
from thefirstock import thefirstock
BCS = thefirstock.firstock_BullCallSpread(
symbol="NIFTY",
callBuyStrikePrice="18000",
callSellStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="15",
remarks="Hello",
userId="PV0013"
)

Long strangle


from thefirstock import thefirstock
LS = thefirstock.firstock_LongStrangle(
symbol="NIFTY",
callStrikePrice="18000",
putStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello"
)
from thefirstock import thefirstock
LS = thefirstock.firstock_LongStrangle(
symbol="NIFTY",
callStrikePrice="18000",
putStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
userId="{{userId}}"
)

Long straddle


from thefirstock import thefirstock
LS = thefirstock.firstock_LongStraddle(
symbol="NIFTY",
strikePrice="18000",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello"
)
from thefirstock import thefirstock
LS = thefirstock.firstock_LongStraddle(
symbol="NIFTY",
strikePrice="18000",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
userId="{{userId}}"
)

Short straddle


from thefirstock import thefirstock
SS = thefirstock.firstock_ShortStraddle(
symbol="NIFTY",
strikePrice="18000",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
hedgeValue="300",
hedge="False"
)
from thefirstock import thefirstock
SS = thefirstock.firstock_ShortStraddle(
symbol="NIFTY",
strikePrice="18000",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
hedgeValue=300,
hedge=False,
userId="{{userId}}"
)

Short strangle


from thefirstock import thefirstock
SS = thefirstock.firstock_ShortStrangle(
symbol="NIFTY",
callStrikePrice="18000",
putStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
hedgeValue="300",
hedge="True"
)
from thefirstock import thefirstock
SS = thefirstock.firstock_ShortStrangle(
symbol="NIFTY",
callStrikePrice="18000",
putStrikePrice="17800",
expiry="23FEB23",
product="C",
quantity="10",
remarks="Hello",
hedgeValue=300,
hedge=True,
userId="{{userId}}"
)

Multiplace order


from thefirstock import thefirstock
MPL = thefirstock.firstock_MultiPlaceOrder(
dataList=[
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test1"
},
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test2"
},
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test3"
},
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test1"
}
]
)
from thefirstock import thefirstock
multiPlaceOrder = thefirstock.firstock_MultiPlaceOrder(
userId="{{userId}}",
dataList=[
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test1"
},
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test2"
},
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test3"
},
{
"exchange": "NSE",
"tradingSymbol": "ITC-EQ",
"quantity": "1",
"price": "0",
"product": "I",
"transactionType": "S",
"priceType": "MKT",
"retention": "DAY",
"triggerPrice": "800",
"remarks": "Test1"
}
]
)