from breeze_connect import BreezeConnect
from datetime import datetime,date,time,timedelta
import pandas as pd
import numpy as np
from credentials001 import *
import requests
from nsepython import *
requests.packages.urllib3.util.connection.HAS_IPV6 = False
currentExpiry = nse_expirydetails(nse_optionchain_scrapper('BANKNIFTY'), 0)[0]

pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)

# login
breeze = BreezeConnect(api_key=api_key)
breeze.generate_session(api_secret=api_secret, session_token=session_token)

bn = breeze.get_quotes(stock_code="CNXBAN",
                       exchange_code="NSE",
                       expiry_date="",
                       product_type="cash",
                       right="others",
                       strike_price="0")
df = pd.DataFrame(bn['Success'])
# print(df)
actual_ltp = df[df['exchange_code'] == 'NSE']['ltp']
# print(actual_ltp)
rounded_ltp = round(actual_ltp, -2).to_string(index=False)
rounded_ltp = pd.to_numeric(rounded_ltp).astype(int)
print("NIFTY BANK LTP:",rounded_ltp)


# Call - Premium of 100 - Strikeprice
dfce=[]
for i in range(rounded_ltp, rounded_ltp + 1000, 100):
    bnc = breeze.get_quotes(stock_code="CNXBAN",
                            exchange_code="NFO",
                            expiry_date=currentExpiry.strftime('%Y-%m-%dT06:00:00.000Z'),
                            product_type="options",
                            right="call",
                            strike_price=i)

    df = pd.DataFrame(bnc['Success'])
    # print(df)
    dfce.append(df)
dfce = pd.concat(dfce)
# print(dfce['ltp'])
dfce['sq.ltp'] = (dfce['ltp'] - 100) * (dfce['ltp'] - 100)
# print(df1)
dfce['sq.ltp.min']=dfce['sq.ltp'].min()
strikepriceCE100 = dfce.loc[dfce['sq.ltp'] == dfce['sq.ltp.min'], 'strike_price'].to_string(index=False)
print("CE Price of LTP 100:",strikepriceCE100)

# Put - Premium of 100 - Strikeprice
dfpe=[]
for j in range(rounded_ltp-1000, rounded_ltp, 100):
    bnp = breeze.get_quotes(stock_code="CNXBAN",
                            exchange_code="NFO",
                            expiry_date=currentExpiry.strftime('%Y-%m-%dT06:00:00.000Z'),
                            product_type="options",
                            right="put",
                            strike_price=j)

    df = pd.DataFrame(bnp['Success'])
    # print(df)
    dfpe.append(df)
dfpe = pd.concat(dfpe)
# print(dfpe['ltp'])
dfpe['sq.ltp'] = (dfpe['ltp'] - 100) * (dfpe['ltp'] - 100)
# print(df1)
dfpe['sq.ltp.min']=dfpe['sq.ltp'].min()
strikepricePE100 = dfpe.loc[dfpe['sq.ltp'] == dfpe['sq.ltp.min'], 'strike_price'].to_string(index=False)
print("PE Price of LTP 100:",strikepricePE100)

 

By AskMahe.com

Hi, AskMahe.com is the Brainchild of Mahendran Paramasivan who is interested in bringing the latest technology to the common people and corporates. We are a team and we are providing supports on Technology and innovation as per industrial standard. We are supporting with the help of analysis we made on Technology and innovation to help corporate companies and individuals. We bring the latest updates of technology and innovation in front of the eyes of our readers, clients, and people. We have resources in Cloud computing, IoT, Edge Computing, Dew Computing, 5G, SAP, Web Designing, UI/ UX Design. Regards AskMahe Team askmahe.com