What is the tradesymbol of banknifty in FNO?

sumegh20
I try to calculate margin for BANKNIFTY30NOV43400CE. But I get the following error
"GeneralException: error computing charges: could not get instrument details : instrument not found: NFO:BANKNIFTY30NOV43400CE"
  • sujith
    Can you enable debug logs and share the complete stacktrace?
  • sujith
    We need complete request and response to investigate. The above screenshot has partial data.
  • MAG
    MAG edited November 2023
    @sumegh20 how did you get the tradingsymbol of BANKNIFTY30NOV43400CE?

    If you look up the instruments list for banknifty NFO instruments with 2023-11-30 expiry you get instruments with the 'BANKNIFTY23NOV' prefix.

    So the symbolname for the instrument you are searching for should be BANKNIFTY23NOV43400CE and not BANKNIFTY30NOV43400CE

    Also your screenshot the last line shows "instrument not found: NFO:BANKNIFTY22NOV43500CE"
    22NOV??? That's last year.

    As I have said in other threads before, do not form the symbolnames for NFO instruments using your own logic.
    What you should do instead is use the instruments list as source of truth and do the following steps:
    1. First have a clear understanding of which underlying you want the symbolname for - in this case it is banknifty.
    2. Have the relevant expiry date - in this case it is 2023-11-30
    3. Download the latest instrument list and parse it for NFO instruments for Banknifty for 2023-11-30

    Which will give you all banknifty instruments for NFO options for that expiry. Something like
    >$ cat instrumentlist.csv | grep NFO-OPT | grep '"BANKNIFTY"' | grep 2023-11-30 | grep 43400 -A10 -B10
    14913538,58256,BANKNIFTY23NOV42900CE,"BANKNIFTY",0,2023-11-30,42900,0.05,15,CE,NFO-OPT,NFO
    14913794,58257,BANKNIFTY23NOV42900PE,"BANKNIFTY",0,2023-11-30,42900,0.05,15,PE,NFO-OPT,NFO
    14914050,58258,BANKNIFTY23NOV43000CE,"BANKNIFTY",0,2023-11-30,43000,0.05,15,CE,NFO-OPT,NFO
    14914818,58261,BANKNIFTY23NOV43000PE,"BANKNIFTY",0,2023-11-30,43000,0.05,15,PE,NFO-OPT,NFO
    14915074,58262,BANKNIFTY23NOV43100CE,"BANKNIFTY",0,2023-11-30,43100,0.05,15,CE,NFO-OPT,NFO
    14915330,58263,BANKNIFTY23NOV43100PE,"BANKNIFTY",0,2023-11-30,43100,0.05,15,PE,NFO-OPT,NFO
    14915586,58264,BANKNIFTY23NOV43200CE,"BANKNIFTY",0,2023-11-30,43200,0.05,15,CE,NFO-OPT,NFO
    14915842,58265,BANKNIFTY23NOV43200PE,"BANKNIFTY",0,2023-11-30,43200,0.05,15,PE,NFO-OPT,NFO
    14916098,58266,BANKNIFTY23NOV43300CE,"BANKNIFTY",0,2023-11-30,43300,0.05,15,CE,NFO-OPT,NFO
    14916354,58267,BANKNIFTY23NOV43300PE,"BANKNIFTY",0,2023-11-30,43300,0.05,15,PE,NFO-OPT,NFO
    14916610,58268,BANKNIFTY23NOV43400CE,"BANKNIFTY",0,2023-11-30,43400,0.05,15,CE,NFO-OPT,NFO
    14916866,58269,BANKNIFTY23NOV43400PE,"BANKNIFTY",0,2023-11-30,43400,0.05,15,PE,NFO-OPT,NFO
    14917122,58270,BANKNIFTY23NOV43500CE,"BANKNIFTY",0,2023-11-30,43500,0.05,15,CE,NFO-OPT,NFO
    14917378,58271,BANKNIFTY23NOV43500PE,"BANKNIFTY",0,2023-11-30,43500,0.05,15,PE,NFO-OPT,NFO
    14917890,58273,BANKNIFTY23NOV43600CE,"BANKNIFTY",0,2023-11-30,43600,0.05,15,CE,NFO-OPT,NFO
    14918146,58274,BANKNIFTY23NOV43600PE,"BANKNIFTY",0,2023-11-30,43600,0.05,15,PE,NFO-OPT,NFO
    14918402,58275,BANKNIFTY23NOV43700CE,"BANKNIFTY",0,2023-11-30,43700,0.05,15,CE,NFO-OPT,NFO
    14918658,58276,BANKNIFTY23NOV43700PE,"BANKNIFTY",0,2023-11-30,43700,0.05,15,PE,NFO-OPT,NFO
    14918914,58277,BANKNIFTY23NOV43800CE,"BANKNIFTY",0,2023-11-30,43800,0.05,15,CE,NFO-OPT,NFO
    14919170,58278,BANKNIFTY23NOV43800PE,"BANKNIFTY",0,2023-11-30,43800,0.05,15,PE,NFO-OPT,NFO
    14919426,58279,BANKNIFTY23NOV43900CE,"BANKNIFTY",0,2023-11-30,43900,0.05,15,CE,NFO-OPT,NFO
    14919682,58280,BANKNIFTY23NOV43900PE,"BANKNIFTY",0,2023-11-30,43900,0.05,15,PE,NFO-OPT,NFO


  • sumegh20
    How do we differentiate between monthly and weekly expiry options?
  • MAG
    This is how I do it. I base it off the expiry date.
    Monthly expiry for banknifty is the last Thursday of the month - period. Once you have this, all other expiries for the month are weekly expiries. This logic should apply to any instrument in NFO-OPT.
    For banknifty in particular, another telling sign is the day of week. Weekly expiry falls on a "wednesday". Monthly expiry falls on the "last thursday" of the month.

    So get the date first and work backwards from that. Works fine for me.
  • sumegh20
    Suppose I want to calculate the margin for a particular trade. For example:

    Underlying: BankNifty
    Expiry date: 6th DEC 2023
    Strike: 43700
    Option type: CE
    Transaction type: SELL

    What should be my trading symbol, and how should I call the basket_order_margins API?
  • MAG
    MAG edited November 2023
    @sumegh20 you need to develop your own logic for extracting that information.

    If I were to do it,
    1. One option would be to have the instrument list as a json file and do a json search for matching parameters.
    2. Another way is to read the instrument list and generate a custom lookup table using python dictionary or using redis where you give the key as <symbol>:<YYYYMMDD>:<Strikeprice> and the <symbolname> as the value.
    So when you do something like
    rediscli>get BANKNIFTY:20231206:43700
    It will return "BANKNIFTY23D0643700" and then you can append the CE or PE.

    This will help you get the correct symbolname.
    These are just two methods. Others may come up with different ideas to achieve the same objective.
    I already use the second method to create symbolname to instrumenttoken mapping and a reverse instrumenttoken to symbolname mapping for my use. I use that basically for handling ticks which contain the instrument token and I want to determine the corresponding symbolname and it works like a charm.

    No idea bout the basket_order_margins API as I have never used it.
Sign In or Register to comment.