What is the tradesymbol of banknifty in FNO?

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

  • 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.