Is 31st Jan is monthly expiry for banknifty ?

visasimbu
Instruments downloaded from broker has format of weekly expiry (BANKNIFTY2413137500CE). But today is monthly expiry right. so the format suppose to be (BANKNIFTY24JAN45200CE) Please clarify me on this.
Tagged:
  • rakeshr
    Is 31st Jan is monthly expiry for banknifty ?
    Yes. This circular explains in detail the current running contract's weekly and monthly expiry.
  • sujith
    It is a rare scenario wherein monthly contract has expired but weekly is still live.
  • MAG
    MAG edited January 31
    Today is BANKNIFTY weekly expiry for the last week of January 2024. BANKNIFTY monthly expiry was on the last Thursday of Jan 2024 i.e. 25th Jan 2024.
    The logic is simple - till date for BANKNIFTY, the weekly expiry is every Wednesday. Monthly expiry is on the last Thursday of the month. Therefore we had a unique situation this month where the Jan 2024 Monthly expiry fell on last Thursday i.e., 29th Feb 2024. But since we have week ending on 31st Jan 2024 (today) we have the last weekly Banknifty expiry for Janurary 2024 today. There is no rule or logic that monthly expiry cannot happen before the weekly expiries are done with. So this month was unique in that sense.

    Now the monthly expiry for BankNifty is set to change as per the circular.
    The circular notes that monthly expiries for BANKNIFTY will also move to last wednesday of the month (currently it is last thursday). How ever this will be effective from March 01, 2024. There is no change in monthly expiry for Jan and Feb 2024.
    So for Feb 2024 the BANKNIFTY monthly expiry will be on the last Thursday i.e., 29th Feb 2024.
    For March 2024, the BANKNIFTY monthly expiry will be on the last Wednesday i.e., 27th Mar 2024 (instead of Thu, 28th March 2024).
    And going forward from March 2024, the monthly BANKNNIFTY expiries will fall on the last Wednesday of each month.

    Hope this clears up any confusion.

  • visasimbu
    Thanks for explaining it.
  • visasimbu
    I have coded in my algo that for last day of expiry on any given month is considered as monthly expiry. If it is monthly expiry symbol formation is different. Due to which it got broke. Now i am not sure how to take it forward in future to handle this kind of scenorio.
  • MAG
    MAG edited February 1
    I have coded in my algo that for last day of expiry on any given month is considered as monthly expiry. If it is monthly expiry symbol formation is different. Due to which it got broke. Now i am not sure how to take it forward in future to handle this kind of scenorio.

    This means you are doing two things wrong.
    1. You are generating the symbols at your end in code instead of referencing them from the instrument list.
    2. You are assuming the last expiry for any month is automatically the monthly expiry instead of using the exchange defined rules to determine monthly expiry.

    First of all this particular issue for January 2024 has occured due to the recent change in Banknifty weekly expiry from Thursday to Wednesday. With the monthly expiry moving to last Wednesday this issue should not repeat.

    As I have said in other threads, you should not be creating symbolnames in code. You should be referencing them from the instrument list.
    This is what I do to get the latest expiry for Banknifty and Nifty.

    curl "https://api.kite.trade/instruments" > instrumentlist.csv
    cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | cut -d',' -f6 | sort | uniq | head -n 1
    cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | cut -d',' -f6 | sort | uniq | head -n 1

    If I run this today I get
    2024-02-07 - which is the next applicable expiry for Banknifty.
    2024-02-01 - Which is the next applicable expiry for Nifty (Today)

    Now if you want instrumentlist data for these two dates,

    cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | grep `cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | cut -d',' -f6 | sort | uniq | head -n 1`
    cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | grep `cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | cut -d',' -f6 | sort | uniq | head -n 1`


    Now if you want only the symbolnames for the instruments:

    cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | grep `cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | cut -d',' -f6 | sort | uniq | head -n 1` | cut -d',' -f3
    cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | grep `cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | cut -d',' -f6 | sort | uniq | head -n 1` |cut -d',' -f3


    If you want only the instrument tokens for the instruments:

    cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | grep `cat instrumentlist.csv | grep NFO-OPT |grep -i ",BANKNIFTY" | cut -d',' -f6 | sort | uniq | head -n 1` | cut -d',' -f1
    cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | grep `cat instrumentlist.csv | grep NFO-OPT |grep -i ",NIFTY" | cut -d',' -f6 | sort | uniq | head -n 1` |cut -d',' -f1


    It took less than a minute for me to get the data. It took longer to type and format this answer.

    This is just rudimentary cli based solutions to get the data whether symbolname or instrument tokens from the instrument list. The same thing can be done from within any programming language and you can add in checks to confirm whether the expiry is weekly expiry or monthly expiry (as per exchange defined rules).

    Why are you trying to create the symbolnames in code? Most of the symbolname issues or expiry date issues occur because folks are assuming things at their end and making their own logic instead of following exchange defined rules.
  • visasimbu
    Awesome. Thanks a ton for taking time to respond for my query. I will change my code with this logic. Earlier I was constructing symbold and then i ll try to match with downloaded instrument list csv file. Once it found i ll go ahead for trading. I understand where I have made mistake. Thanks MAG.
This discussion has been closed.