Package: nifpy
nifpynifpy is an easy to use python package that can be used to fetchlive price,closing price,stock summary,index listand fundamentals such asincome statement,cash flow statementandbalance sheetof stocks that trade on the National Stock Exchange(NSE).Getting StartedInstallationYou can install the package from Pypipip3installnifpyDependenciesYou can install the dependencies by executing the following code in your terminalpip3install-rrequirements.txtHow to get the scrip nameYou can get the scrip/symbol/ticker of the stock you want by opening the yahoo finance website and searching for the company as shown below.Methodsget_live_priceget_summaryget_dataget_closing_priceget_crypto_dataget_balance_sheetget_cash_flowget_income_statementChart Centermoving_avgbollinger_bandsget_chartget_live_priceThis function returns the live/latest price for the symbol that has been passed as the parameterfromnifpyimport*price=get_live_price(ticker)print(price)"""Parameters-------------------------------ticker : Contains the symbol/ticker for which the live price will be returned"""#Exampleprice=get_live_price('ITC.NS')get_summaryThis function returns the summary of various attributes of the symbol/ticker that has been passed as the parameterfromnifpyimport*summary=get_summary(symbol)print(summary)"""Parameters-------------------------------tickers : Contains the symbol/ticker for which the summary of various attributes will be returnedReturns-------------------------------A pandas dataframe that contains various attributes of a ticker such as the:- Previous Close- Open- Bid- Ask- Day's Range- 52 Week Range- Volume- Average Volume- Market Cap- Beta- P/E Ratio- EPS- Earnings Date- Forward Dividend and Yield- Ex-Dividend Date- 1 Year Target Estimate"""#Examplesummary=get_summary('MARUTI.NS')get_dataThis function returns the various attributes of a ticker such as the High, Low, Open, Close, Volume
and Adjusted Closefromnifpyimport*data=get_data(ticker,start=TODAY-PREV,end=TODAY)print(data)# TODAY = datetime.date.today()# PREV = datetime.timedelta(90)"""Parameters-------------------------------tickers : Contains the symbol/ticker for which various attributes mentioned above will be returnedstart :   Contains the starting dateFormat: 'dd/mm/yyyy' as in '27/01/2020'Default: Three months from today's dateend :     Contains the end dateFormat: 'dd/mm/yyyy' as in '27/04/2021'Default: Today's dateReturns-------------------------------A pandas dataframe that contains various attributes of a ticker such as the High, Low, Open, Close, Volumeand Adjusted Close"""#Exampledata=get_data('WIPRO.NS','27/01/2020','27/04/2021')get_closing_priceThis function returns the Closing price of a list of tickers mentioned in the parameter.fromnifpyimport*closing=get_closing_price(tickers,start=TODAY-PREV,end=TODAY)print(closing)# TODAY = datetime.date.today()# PREV = datetime.timedelta(90)"""Parameters-------------------------------tickers : Contains a list of symbols for which the closing price will be returnedstart : Contains the starting date from which closing price is requiredFormat: 'dd/mm/yyyy' as in '25/02/2021'Default: Three months from today's dateend : Contains the end date till which closing price is requiredFormat: 'dd/mm/yyyy' as in '27/02/2021'Default: Today's dateOther than a custom list some other parameters that can be passed directly to the function are:- get_sensex()- get_nifty_next50()- get_nifty_bank()- get_nifty_auto()- get_nifty_financial()- get_nifty_fmcg()- get_nifty_it()- get_nifty_media()- get_nifty_metal()- get_nifty_pharma()- get_nifty_psubank()- get_nifty_privatebank()- get_nifty_realty()- get_nifty()Returns-------------------------------A pandas dataframe that contains the closing price of all symbols passed as the parameter to the function"""#Examplestonks=['TCS.NS','TITAN.NS','TATASTEEL.NS','ICICIBANK.NS']closing=get_closing_price(stonks,'27/01/2021','26/02/2021')# Or you can directly pass indexes mentioned aboveclosing=get_closing_price(get_nifty_bank(),'27/01/2021','26/02/2021')get_crypto_dataThis function returns the various attributes of a crypto ticker such as the High, Low,
Open, Close, Volume and Adjusted Close.
This is limited to the previous 100 days historical data for the coinfromnifpyimport*crypto_data=get_crypto_data(symbol)print(crypto_data)"""Parameters-------------------------------symbol : Contains the symbol/ticker for which various attributes will be returnedReturns-------------------------------A pandas dataframe that contains attributes of a crypto coin such as the High,Low, Open, Close, Volume and Adjusted Close"""#Examplecrypto_coin=get_crypto_data('DOGE-USD')get_balance_sheetUsed to obtain the balance sheet of the specified tickerfromnifpyimport*balance_sheet=get_balance_sheet(symbol)print(balance_sheet)"""Parameters-------------------------------symbol : It is used to specify the symbol/ticker for   which the balance sheet has to be fetchedReturns--------------------------------A dataframe that contains the balance sheet of the company"""#Examplebalance_sheet=get_balance_sheet('RELIANCE.NS')get_cash_flowUsed to obtain the cash flow statement of the specified tickerfromnifpyimport*cash_flow=get_cash_flow(symbol)print(cash_flow)"""Parameters-------------------------------symbol : It is used to specify the symbol/ticker for which the cash flow has to be fetchedReturns--------------------------------A dataframe that contains the cash flow statement of the company"""#Examplecash_flow=get_cash_flow('HCLTECH.NS')get_income_statementUsed to obtain the income statement of the specified tickerfromnifpyimport*inc_statement=get_income_statement(symbol)print(inc_statement)"""Parameters-------------------------------symbol : It is used to specify the symbol/ticker for which the income statement has to be fetchedReturns--------------------------------A dataframe that contains the income statement of the company"""#Exampleinc_statement=get_income_statement('TITAN.NS')Indicesget_nifty()get_sensex()get_nifty_next50()get_nifty_bank()get_nifty_auto()get_nifty_financial()get_nifty_fmcg()get_nifty_it()get_nifty_media()get_nifty_metal()get_nifty_pharma()get_nifty_psubank()get_nifty_privatebank()get_nifty_realty()fromnifpyimport*it_stonks=get_nifty_it()print(it_stonks)In a similar way stocks trading in other indices are returned as a list and can be used for further analysis.moving_avgUsed to plot the moving average of the specified tickerfromnifpyimport*moving_avg(scrip,num_days)"""Parameters-------------------------------scrip : It is used to specify the symbol/ticker for which the moving average has to be plottednum_days : Number of days for which moving average has to be plotted. Commonly used valuesare 14, 20, 50, 100, 200Returns--------------------------------Plot consisting of moving average along with the closing price"""#Example#Moving average for 20 daysmoving_avg('ITC.NS',20)#Moving average for 50 daysmoving_avg('ITC.NS',50)bollinger_bandsUsed to plot Bollinger Bands of the specified tickerfromnifpyimport*bollinger_bands(scrip)"""Parameters-------------------------------scrip : Used to specify the symbol/ticker for which Bollinger Bands has to be plottedReturns--------------------------------Plot consisting of Bollinger Bands for the past 600 days"""#Examplebollinger_bands('DIVISLAB.NS')get_chartUsed to get the historical chart of the specified tickerfromnifpyimport*get_chart(scrip,kind='line',start=TODAY-PREV,end=TODAY)# TODAY = datetime.date.today()# PREV = datetime.timedelta(600)"""Parameters-------------------------------scrip : Used to specify the symbol/ticker for which historical chart has to be plottedkind : The type of chart - 'line' or 'area'start :   Contains the starting dateFormat: 'dd/mm/yyyy' as in '25/04/2020'Default: 600 days from today's dateend :     Contains the end dateFormat: 'dd/mm/yyyy' as in '27/05/2021'Default: Today's dateReturns--------------------------------Historical chart based on time frame"""#Example#For area chart with default timeframe of 600 daysget_chart('SBIN.NS','area')#For line chart with custom timeframeget_chart('SBIN.NS','line','25/04/2020','27/05/2021')