# nifpy
nifpy is an easy to use python package that can be used to fetch **live price**, **closing price**, **stock summary**, **index list** and fundamentals such as **income statement**, **cash flow statement** and **balance sheet** of stocks that trade on the National Stock Exchange(NSE).
## Getting Started
### Installation
You can install the package from Pypi
```bash
pip3 install nifpy
```
### Dependencies
You can install the dependencies by executing the following code in your terminal
```bash
pip3 install -r requirements.txt
```
### How to get the scrip name
You 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.
![](docs/scrip.gif)
## Methods
- [get_live_price](#get_live_price)
- [get_summary](#get_summary)
- [get_data](#get_data)
- [get_closing_price](#get_closing_price)
- [get_crypto_data](#get_crypto_data)
- [get_balance_sheet](#get_balance_sheet)
- [get_cash_flow](#get_cash_flow)
- [get_income_statement](#get_income_statement)
## Chart Center
- [moving_avg](#moving_avg)
- [bollinger_bands](#bollinger_bands)
- [get_chart](#get_chart)
### get_live_price
This function returns the live/latest price for the symbol that has been passed as the parameter
``` python
from nifpy import *
price = get_live_price(ticker)
print(price)
"""
Parameters
-------------------------------
ticker : Contains the symbol/ticker for which the live price will be returned
"""
#Example
price = get_live_price('ITC.NS')
```
### get_summary
This function returns the summary of various attributes of the symbol/ticker that has been passed as the parameter
``` python
from nifpy import *
summary = get_summary(symbol)
print(summary)
"""
Parameters
-------------------------------
tickers : Contains the symbol/ticker for which the summary of various attributes will be returned
Returns
-------------------------------
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
"""
#Example
summary = get_summary('MARUTI.NS')
```
### get_data
This function returns the various attributes of a ticker such as the High, Low, Open, Close, Volume
and Adjusted Close
``` python
from nifpy import *
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 returned
start : Contains the starting date
Format: 'dd/mm/yyyy' as in '27/01/2020'
Default: Three months from today's date
end : Contains the end date
Format: 'dd/mm/yyyy' as in '27/04/2021'
Default: Today's date
Returns
-------------------------------
A pandas dataframe that contains various attributes of a ticker such as the High, Low, Open, Close, Volume
and Adjusted Close
"""
#Example
data = get_data('WIPRO.NS','27/01/2020','27/04/2021')
```
### get_closing_price
This function returns the Closing price of a list of tickers mentioned in the parameter.
``` python
from nifpy import *
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 returned
start : Contains the starting date from which closing price is required
Format: 'dd/mm/yyyy' as in '25/02/2021'
Default: Three months from today's date
end : Contains the end date till which closing price is required
Format: 'dd/mm/yyyy' as in '27/02/2021'
Default: Today's date
Other 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
"""
#Example
stonks = ['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 above
closing = get_closing_price(get_nifty_bank(),'27/01/2021','26/02/2021')
```
### get_crypto_data
This 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 coin
```python
from nifpy import *
crypto_data = get_crypto_data(symbol)
print(crypto_data)
"""
Parameters
-------------------------------
symbol : Contains the symbol/ticker for which various attributes will be returned
Returns
-------------------------------
A pandas dataframe that contains attributes of a crypto coin such as the High,Low, Open, Close, Volume and Adjusted Close
"""
#Example
crypto_coin = get_crypto_data('DOGE-USD')
```
### get_balance_sheet
Used to obtain the balance sheet of the specified ticker
``` python
from nifpy import *
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 fetched
Returns
--------------------------------
A dataframe that contains the balance sheet of the company
"""
#Example
balance_sheet = get_balance_sheet('RELIANCE.NS')
```
### get_cash_flow
Used to obtain the cash flow statement of the specified ticker
``` python
from nifpy import *
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 fetched
Returns
--------------------------------
A dataframe that contains the cash flow statement of the company
"""
#Example
cash_flow = get_cash_flow('HCLTECH.NS')
```
### get_income_statement
Used to obtain the income statement of the specified ticker
``` python
from nifpy import *
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 fetched
Returns
--------------------------------
A dataframe that contains the income statement of the company
"""
#Example
inc_statement = get_income_statement('TITAN.NS')
```
### Indices
- get_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()
``` python
from nifpy import *
it_stonks = get_nifty_it()
print(it_stonks)
```
![](docs/nifpy1.png)
In a similar way stocks trading in other indices are returned as a list and can be used for further analysis.
### moving_avg
Used to plot the moving average of the specified ticker
``` python
from nifpy import *
moving_avg(scrip, num_days)
"""
Parameters
-------------------------------
scrip : It is used to specify the symbol/ticker for which the moving average has to be plotted
num_days : Number of days for which moving average has to be plotted. Commonly used values
are 14, 20, 50, 100, 200
Returns
--------------------------------
Plot consisting of moving average along with the closing price
"""
#Example
#Moving average for 20 days
moving_avg('ITC.NS', 20)
#Moving average for 50 days
moving_avg('ITC.NS', 50)
```
### bollinger_bands
Used to plot Bollinger Bands of the specified ticker
``` python
from nifpy import *
bollinger_bands(scrip)
"""
Parameters
-------------------------------
scrip : Used to specify the symbol/ticker for which Bollinger Bands has to be plotted
Returns
--------------------------------
Plot consisting of Bollinger Bands for the past 600 days
"""
#Example
bollinger_bands('DIVISLAB.NS')
```
![](docs/Bollinger_image.png)
### get_chart
Used to get the historical chart of the specified ticker
``` python
from nifpy import *
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 plotted
kind : The type of chart - 'line' or 'area'
start : Contains the starting date
Format: 'dd/mm/yyyy' as in '25/04/2020'
Default: 600 days from today's date
end : Contains the end date
Format: 'dd/mm/yyyy' as in '27/05/2021'
Default: Today's date
Returns
--------------------------------
Historical chart based on time frame
"""
#Example
#For area chart with default timeframe of 600 days
get_chart('SBIN.NS','area')
#For line chart with custom timeframe
get_chart('SBIN.NS','line','25/04/2020','27/05/2021')
```
![](docs/Line_chart.png)
Raw data
{
"_id": null,
"home_page": "https://github.com/shresth26/nifpy",
"name": "nifpy",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "stocks,nifty,financials,algo trading,nse,crypto,cryptocurrency,sensex",
"author": "Shresth Singh",
"author_email": "singhshresth26@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/4c/97/e5b9f03a4400006323e50db71c1ed307dafc709fd080455978ea0bc2b13e/nifpy-2.1.0.tar.gz",
"platform": null,
"description": "# nifpy\n\nnifpy is an easy to use python package that can be used to fetch **live price**, **closing price**, **stock summary**, **index list** and fundamentals such as **income statement**, **cash flow statement** and **balance sheet** of stocks that trade on the National Stock Exchange(NSE).\n\n## Getting Started\n\n### Installation\n\nYou can install the package from Pypi\n```bash\npip3 install nifpy\n```\n\n### Dependencies\n\nYou can install the dependencies by executing the following code in your terminal\n\n```bash\npip3 install -r requirements.txt\n```\n\n### How to get the scrip name\n\nYou 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. \n\n![](docs/scrip.gif)\n\n## Methods\n\n- [get_live_price](#get_live_price)\n- [get_summary](#get_summary)\n- [get_data](#get_data)\n- [get_closing_price](#get_closing_price)\n- [get_crypto_data](#get_crypto_data)\n- [get_balance_sheet](#get_balance_sheet)\n- [get_cash_flow](#get_cash_flow)\n- [get_income_statement](#get_income_statement)\n\n\n## Chart Center\n\n- [moving_avg](#moving_avg) \n- [bollinger_bands](#bollinger_bands) \n- [get_chart](#get_chart) \n\n### get_live_price\n\nThis function returns the live/latest price for the symbol that has been passed as the parameter\n\n``` python \nfrom nifpy import *\nprice = get_live_price(ticker)\nprint(price)\n\n\"\"\" \nParameters\n-------------------------------\nticker : Contains the symbol/ticker for which the live price will be returned\n\"\"\"\n#Example\nprice = get_live_price('ITC.NS')\n```\n\n### get_summary\n\nThis function returns the summary of various attributes of the symbol/ticker that has been passed as the parameter\n\n``` python \nfrom nifpy import *\nsummary = get_summary(symbol)\nprint(summary)\n\n\"\"\" \nParameters\n-------------------------------\ntickers : Contains the symbol/ticker for which the summary of various attributes will be returned\n\nReturns\n-------------------------------\nA pandas dataframe that contains various attributes of a ticker such as the:\n\n- Previous Close\n- Open\n- Bid\n- Ask\n- Day's Range\n- 52 Week Range\n- Volume\n- Average Volume\n- Market Cap\n- Beta\n- P/E Ratio\n- EPS\n- Earnings Date\n- Forward Dividend and Yield\n- Ex-Dividend Date\n- 1 Year Target Estimate\n\"\"\"\n#Example\nsummary = get_summary('MARUTI.NS')\n```\n\n### get_data\n\nThis function returns the various attributes of a ticker such as the High, Low, Open, Close, Volume \nand Adjusted Close\n\n``` python \nfrom nifpy import *\ndata = get_data(ticker, start=TODAY-PREV, end=TODAY)\nprint(data)\n\n# TODAY = datetime.date.today()\n# PREV = datetime.timedelta(90)\n\"\"\" \nParameters\n-------------------------------\ntickers : Contains the symbol/ticker for which various attributes mentioned above will be returned\n\nstart : Contains the starting date\n Format: 'dd/mm/yyyy' as in '27/01/2020' \n Default: Three months from today's date\n\nend : Contains the end date\n Format: 'dd/mm/yyyy' as in '27/04/2021'\n Default: Today's date\nReturns\n-------------------------------\nA pandas dataframe that contains various attributes of a ticker such as the High, Low, Open, Close, Volume\nand Adjusted Close\n\"\"\"\n#Example\ndata = get_data('WIPRO.NS','27/01/2020','27/04/2021')\n```\n\n### get_closing_price\n\n\nThis function returns the Closing price of a list of tickers mentioned in the parameter.\n\n``` python \nfrom nifpy import *\nclosing = get_closing_price(tickers, start=TODAY-PREV, end = TODAY)\nprint(closing)\n\n# TODAY = datetime.date.today()\n# PREV = datetime.timedelta(90)\n\n\"\"\" \nParameters\n-------------------------------\ntickers : Contains a list of symbols for which the closing price will be returned\n\nstart : Contains the starting date from which closing price is required\n\nFormat: 'dd/mm/yyyy' as in '25/02/2021' \nDefault: Three months from today's date\n\nend : Contains the end date till which closing price is required\n \nFormat: 'dd/mm/yyyy' as in '27/02/2021' \nDefault: Today's date\n\nOther than a custom list some other parameters that can be passed directly to the function are:\n\n- get_sensex()\n- get_nifty_next50()\n- get_nifty_bank()\n- get_nifty_auto()\n- get_nifty_financial()\n- get_nifty_fmcg()\n- get_nifty_it()\n- get_nifty_media()\n- get_nifty_metal()\n- get_nifty_pharma()\n- get_nifty_psubank()\n- get_nifty_privatebank()\n- get_nifty_realty()\n- get_nifty()\n\nReturns\n-------------------------------\nA pandas dataframe that contains the closing price of all symbols passed as the parameter to the function\n\"\"\"\n#Example\nstonks = ['TCS.NS', 'TITAN.NS', 'TATASTEEL.NS','ICICIBANK.NS']\n\nclosing = get_closing_price(stonks,'27/01/2021','26/02/2021')\n\n# Or you can directly pass indexes mentioned above\nclosing = get_closing_price(get_nifty_bank(),'27/01/2021','26/02/2021')\n\n```\n\n### get_crypto_data\n\nThis function returns the various attributes of a crypto ticker such as the High, Low, \nOpen, Close, Volume and Adjusted Close.\nThis is limited to the previous 100 days historical data for the coin\n\n```python\nfrom nifpy import *\ncrypto_data = get_crypto_data(symbol)\nprint(crypto_data)\n\n\"\"\"\nParameters\n-------------------------------\nsymbol : Contains the symbol/ticker for which various attributes will be returned\n\nReturns\n-------------------------------\nA pandas dataframe that contains attributes of a crypto coin such as the High,Low, Open, Close, Volume and Adjusted Close \n\n\"\"\"\n#Example\ncrypto_coin = get_crypto_data('DOGE-USD')\n```\n\n### get_balance_sheet\n\nUsed to obtain the balance sheet of the specified ticker\n\n``` python \nfrom nifpy import *\nbalance_sheet = get_balance_sheet(symbol)\nprint(balance_sheet)\n\n\"\"\"\nParameters\n-------------------------------\nsymbol : It is used to specify the symbol/ticker for which the balance sheet has to be fetched\n\nReturns\n--------------------------------\nA dataframe that contains the balance sheet of the company\n\"\"\"\n#Example\nbalance_sheet = get_balance_sheet('RELIANCE.NS')\n```\n\n### get_cash_flow\n\nUsed to obtain the cash flow statement of the specified ticker\n\n``` python \nfrom nifpy import *\ncash_flow = get_cash_flow(symbol)\nprint(cash_flow)\n\n\"\"\" \nParameters\n-------------------------------\nsymbol : It is used to specify the symbol/ticker for which the cash flow has to be fetched\n\nReturns\n--------------------------------\nA dataframe that contains the cash flow statement of the company\n\"\"\"\n#Example\ncash_flow = get_cash_flow('HCLTECH.NS')\n```\n\n### get_income_statement\nUsed to obtain the income statement of the specified ticker\n\n``` python \nfrom nifpy import *\ninc_statement = get_income_statement(symbol)\nprint(inc_statement)\n\n\"\"\" \nParameters\n-------------------------------\nsymbol : It is used to specify the symbol/ticker for which the income statement has to be fetched\n\nReturns\n--------------------------------\nA dataframe that contains the income statement of the company\n\"\"\"\n#Example\ninc_statement = get_income_statement('TITAN.NS')\n```\n\n### Indices\n\n- get_nifty()\n- get_sensex()\n- get_nifty_next50()\n- get_nifty_bank()\n- get_nifty_auto()\n- get_nifty_financial()\n- get_nifty_fmcg()\n- get_nifty_it()\n- get_nifty_media()\n- get_nifty_metal()\n- get_nifty_pharma()\n- get_nifty_psubank()\n- get_nifty_privatebank()\n- get_nifty_realty()\n\n``` python\nfrom nifpy import *\nit_stonks = get_nifty_it()\nprint(it_stonks)\n```\n\n![](docs/nifpy1.png)\n \nIn a similar way stocks trading in other indices are returned as a list and can be used for further analysis.\n\n\n### moving_avg\nUsed to plot the moving average of the specified ticker\n\n``` python \nfrom nifpy import *\nmoving_avg(scrip, num_days)\n\n\"\"\" \nParameters\n-------------------------------\nscrip : It is used to specify the symbol/ticker for which the moving average has to be plotted\nnum_days : Number of days for which moving average has to be plotted. Commonly used values\n are 14, 20, 50, 100, 200 \n\nReturns\n--------------------------------\nPlot consisting of moving average along with the closing price\n\"\"\"\n#Example\n\n#Moving average for 20 days\nmoving_avg('ITC.NS', 20)\n\n#Moving average for 50 days\nmoving_avg('ITC.NS', 50)\n\n```\n\n### bollinger_bands\nUsed to plot Bollinger Bands of the specified ticker\n\n``` python \nfrom nifpy import *\nbollinger_bands(scrip)\n\n\"\"\" \nParameters\n-------------------------------\nscrip : Used to specify the symbol/ticker for which Bollinger Bands has to be plotted \n\nReturns\n--------------------------------\nPlot consisting of Bollinger Bands for the past 600 days\n\"\"\"\n#Example\nbollinger_bands('DIVISLAB.NS')\n\n```\n\n![](docs/Bollinger_image.png)\n\n### get_chart\nUsed to get the historical chart of the specified ticker\n\n``` python \nfrom nifpy import *\nget_chart(scrip, kind = 'line',start = TODAY-PREV, end = TODAY)\n\n# TODAY = datetime.date.today()\n# PREV = datetime.timedelta(600)\n\n\"\"\" \nParameters\n-------------------------------\nscrip : Used to specify the symbol/ticker for which historical chart has to be plotted\n\nkind : The type of chart - 'line' or 'area'\n\nstart : Contains the starting date\n Format: 'dd/mm/yyyy' as in '25/04/2020' \n Default: 600 days from today's date\n\nend : Contains the end date\n Format: 'dd/mm/yyyy' as in '27/05/2021' \n Default: Today's date\n\nReturns\n--------------------------------\nHistorical chart based on time frame\n\"\"\"\n#Example\n\n#For area chart with default timeframe of 600 days\nget_chart('SBIN.NS','area')\n\n#For line chart with custom timeframe\nget_chart('SBIN.NS','line','25/04/2020','27/05/2021')\n\n```\n\n![](docs/Line_chart.png)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Easy to use python package that can be used to fetch live price, closing price, stock summary,",
"version": "2.1.0",
"project_urls": {
"Homepage": "https://github.com/shresth26/nifpy"
},
"split_keywords": [
"stocks",
"nifty",
"financials",
"algo trading",
"nse",
"crypto",
"cryptocurrency",
"sensex"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f44853b0243898a7ce87e110e6acf0fb7497c843eff1de7aedfa30100517c846",
"md5": "85b46f12899e4cfa0edddde83972aa17",
"sha256": "c1f1459269a0d8127b2acd7a332e5ce331d98cd0de3b7f407f8a4ad39cceb5a1"
},
"downloads": -1,
"filename": "nifpy-2.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "85b46f12899e4cfa0edddde83972aa17",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9525,
"upload_time": "2023-12-05T19:41:54",
"upload_time_iso_8601": "2023-12-05T19:41:54.099359Z",
"url": "https://files.pythonhosted.org/packages/f4/48/53b0243898a7ce87e110e6acf0fb7497c843eff1de7aedfa30100517c846/nifpy-2.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4c97e5b9f03a4400006323e50db71c1ed307dafc709fd080455978ea0bc2b13e",
"md5": "da19604d5cb38c5b1a44a02b53d6ae18",
"sha256": "037b91b536aacbda677079c33e90ba9dc31015eb75b8f9e52bbc737b2346f77c"
},
"downloads": -1,
"filename": "nifpy-2.1.0.tar.gz",
"has_sig": false,
"md5_digest": "da19604d5cb38c5b1a44a02b53d6ae18",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9510,
"upload_time": "2023-12-05T19:41:55",
"upload_time_iso_8601": "2023-12-05T19:41:55.767698Z",
"url": "https://files.pythonhosted.org/packages/4c/97/e5b9f03a4400006323e50db71c1ed307dafc709fd080455978ea0bc2b13e/nifpy-2.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-05 19:41:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "shresth26",
"github_project": "nifpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "nifpy"
}