Python Sample Code with output to get PCR, MaxPain, high OI and change in OI for both Nifty and Banknifty. Nearest expiry is taken by default

Python Code import pandas as pd from NSEOption import OptionChain nifty_name =”Nifty” banknifty_name = “Banknifty” objNifty = OptionChain(nifty_name) objBanknifty = OptionChain(banknifty_name) oi_df = pd.DataFrame({‘Script’: [nifty_name, banknifty_name], ‘Max Pain’: [objNifty.max_pain, objBanknifty.max_pain], ‘PCR’: [objNifty.pcr, objBanknifty.pcr], ‘High OI PE’: [objNifty.max_high_oi_pe, objBanknifty.max_high_oi_pe], ‘High OI CE’: [objNifty.max_high_oi_ce, objBanknifty.max_high_oi_ce], ‘Chng OI PE’: [objNifty.max_change_oi_pe, objBanknifty.max_change_oi_pe], ‘Chng OI

Continue Reading

Python Code (defined as Class) to get NSE options data (PCR, MaxPain, High OI, Change in OI) for all scripts like Nifty, Banknifty and Stocks.

import pandas as pd import requests from datetime import datetime # Colunn at which strike price is listed in NSE option chain table strike_price_column_index = 11 # Encapuslate NSE option data and function class OptionChain: # static variable to hold current running expiry date expiry = ” # Common Utility

Continue Reading

Written small piece of Python Code to process trade log and paste as table in HTML. you will get expiry trade log faster and smoother hereafter

# import pandas library import pandas as pd import os import glob import ctypes # An included library with Python install. # define trade log file name tradelog_filename = “TradeLog.csv” tradehtml_filename = “TradeLog.html” # define account id to filer account_id = your_id # Remove the old file if os.path.exists(tradelog_filename): os.remove(tradelog_filename)

Continue Reading

Python code to read expiry details for Futures from NSE

# Get all get possible expiry date details for the given script def get_expiry_from_future_list (symbol): # Base url page for the symbole with default expiry date Base_url = “https://www.nseindia.com/live_market/dynaContent/live_watch/fomwatchsymbol.jsp?key=” + symbol + “&Fut_Opt=Futures” # Load the page and sent to HTML parse page = requests.get(Base_url) soup = BeautifulSoup(page.content, ‘html.parser’) table_cls_2

Continue Reading