A small package that helps you in fetching list of stocks from National Stock Exchange (NSE) based on main_item, sub_item values and returnOutput.
Project description
Package niftythematic
Date: 10-Apr-2022
Installation
Use the following for importing: from thematicnifty import tn
Prerequisites
The pandas
package will be imported as pd
.
Features
This is a comprehensive app that will allow you to get the list of stocks in National Stock Exchange (NSE) India that is belonging to different groups of main themes such as Broad Market Indices (bmi
), or Sectorial Indices (secti
), Strategy Indices (strati
) or Thematic Indices (themei
). From each of the group theme, you can pull different list of stocks from different groups.
For example, from the bmi
theme, you can get the stocks of the usual groups such as NIFTY_50, NIFTY_100, NIFTY_200, etc. These are the sub-themes of the main bmi
theme. A complete list of themes under bmi
group is provided at the end of this document.
From secti
, you can get the stocks belonging to different sectors such as NIFTY_AUTO, NIFTY_IT, NIFTY_PHARMA, NIFTY_FMCG, etc. These are the sub-themes of the main secti
theme. A complete list of themes under secti
group is provided at the end of this document.
From strati
, you can you can extract stocks belonging to the groups such as NIFTY50_EQUAL_WEIGHT, NIFTY50_VALUE_20, NIFTY_ALPHA_50, etc. These are the sub-themes of the main strati
theme. A complete list of themes under strati
group is provided at the end of this document.
Finally, from themei
, you can fetch stocks belonging to groups such as NIFTY100_LIQUID_15, NIFTY_CPSE, NIFTY_MIDCAP_LIQUID_15, NIFTY_MNC, etc. These are the sub-themes of the main themei
theme. A complete list of themes under themei
group is provided at the end of this document.
Method Design
This is designed to be simple, and there is a single method with three parameters.
getThematicNiftyStocks(main_item, sub_item, return_output)
Description of the Method
The getThematicNiftyStocks()
method takes just 3 string inputs:
- group_name
- group_item
- return_type
Description of each of the above is given hereunder.
group_name
The main item can be one of the following four - bmi_group
(default), secti_group
, strati_group
or themei_group
. As already indicated, bmi
stands for Broad Market Indices, secti
stands for Sectorial Indices, strati
stands for Strategic Indices, and themei
stands for Thematic Indices.
group_item
The sub_items are different for different main_item. For bmi
, the sub_item can be one of the following 16. The default value is 'NIFTY_50'.
- NIFTY_MIDSMALLCAP_400
- NIFTY_200
- NIFTY_LARGEMIDCAP_250
- NIFTY_TOTAL_MARKET
- NIFTY_50 (default)
- NIFTY_SMALLCAP_50
- NIFTY_SMALLCAP_250
- NIFTY_SMALLCAP_100
- NIFTY_100
- NIFTY_MIDCAP_150
- NIFTY_MIDCAP_SELECT
- NIFTY_NEXT_50
- NIFTY500_MULTICAP_50_25_25
- NIFTY_MICROCAP_250
- NIFTY_MIDCAP_50
- NIFTY_MIDCAP_100'
For secti
, the sub_item can be one of the following 16: The default value is 'NIFTY_BANK'.
- NIFTY_PHARMA
- NIFTY_BANK (default)
- NIFTY_PSU_BANK
- NIFTY_FMCG
- NIFTY_CONSUMER_DURABLES
- NIFTY_PRIVATE_BANK
- NIFTY_AUTO
- NIFTY_HEALTHCARE_INDEX
- NIFTY_ENERGY
- NIFTY_METAL
- NIFTY_OIL_and_GAS
- NIFTY_REALTY
- NIFTY_FINANCIAL_SERVICES_25_50
- NIFTY_FINANCIAL_SERVICES
- NIFTY_MEDIA
- NIFTY_IT
For strati
, the sub_item can be one of the following 10: The default is 'NIFTY_ALPHA_50'.
- NIFTY100_LOW_VOLATILITY_30
- NIFTY100_QUALITY_30
- NIFTY50_VALUE_20
- NIFTY_MIDCAP150_QUALITY_50
- NIFTY_ALPHA_50 (default)
- NIFTY200_QUALITY_30
- NIFTY100_EQUAL_WEIGHT
- NIFTY_ALPHA_LOW_VOLATILITY_30
- NIFTY200_MOMENTUM_30
- NIFTY_DIVIDEND_OPPORTUNITIES_50
Finally, for themei
, the sub_item can be one of the following 10: The default value is 'NIFTY100_LIQUID_15'.
- NIFTY100_ESG
- NIFTY_INDIA_CONSUMPTION
- NIFTY_SERVICES_SECTOR
- NIFTY_INFRASTRUCTURE
- NIFTY_INDIA_DIGITAL
- NIFTY_PSE
- NIFTY100_LIQUID_15 (default)
- NIFTY_INDIA_MANUFACTURING
- NIFTY_CPSE
- NIFTY_MIDCAP_LIQUID_15
- NIFTY_GROWTH_SECTORS_15
- NIFTY_COMMODITIES
- NIFTY_MNC'
return_type
As indicated earlier, return_type can take one of the following options:
'as_list'
'as_list_with_NS'
'as_text'
'as_text_with_NS'
(default)
Default values for the method parameters
The method has been designed with the following default parameters:
- group_name =
'bmi_group'
- group_item =
'NIFTY_50'
- return_type =
'as_text_with_NS'
Method Usage
Example for bmi_group
Run the getThematicNiftyStocks() method to capture the list of stocks (as a text, as a list, as a text witn .NS and as a text with .NS extension) as follows:
stocks = getThematicNiftyStocks(group_name='secti_group', group_item='NIFTY_IT', return_type='as_text')
The variable stocks will be either a list or a text based on what you want the list of stocks to be presented with. For example, if you run the following method,
stocks = getThematicNiftyStocks('bmi_group', 'NIFTY_50', 'as_text_with_ns')
the output will be the following:
Output: NTPC.NS INDUSINDBK.NS BPCL.NS SBIN.NS POWERGRID.NS HDFCBANK.NS HDFCLIFE.NS ADANIPORTS.NS BAJAJ-AUTO.NS COALINDIA.NS SHREECEM.NS M&M.NS BAJFINANCE.NS HDFC.NS KOTAKBANK.NS ONGC.NS TATACONSUM.NS TATAMOTORS.NS MARUTI.NS LT.NS UPL.NS HINDUNILVR.NS WIPRO.NS BAJAJFINSV.NS ICICIBANK.NS AXISBANK.NS DRREDDY.NS ASIANPAINT.NS EICHERMOT.NS TATASTEEL.NS BRITANNIA.NS ULTRACEMCO.NS NESTLEIND.NS JSWSTEEL.NS TCS.NS RELIANCE.NS HCLTECH.NS GRASIM.NS ITC.NS BHARTIARTL.NS SUNPHARMA.NS INFY.NS HINDALCO.NS TITAN.NS CIPLA.NS APOLLOHOSP.NS DIVISLAB.NS TECHM.NS SBILIFE.NS HEROMOTOCO.NS
Example for secti_group
stocks = getThematicNiftyStocks(group_name='secti_group', group_item='NIFTY_IT', return_type='as_text')
Output: WIPRO TCS LTTS HCLTECH INFY LTI MINDTREE TECHM MPHASIS COFORGE
Example for strati_group
stocks = getThematicNiftyStocks(group_name='strati_group', group_item='NIFTY50_VALUE_20', return_type='as_list_with_NS')
Output: ['NTPC.NS', 'BPCL.NS', 'POWERGRID.NS', 'COALINDIA.NS', 'BAJAJ-AUTO.NS', 'ONGC.NS', 'HINDUNILVR.NS', 'WIPRO.NS', 'LT.NS', 'UPL.NS', 'BRITANNIA.NS', 'GRASIM.NS', 'TCS.NS', 'HCLTECH.NS', 'JSWSTEEL.NS', 'ITC.NS', 'INFY.NS', 'HINDALCO.NS', 'TECHM.NS', 'HEROMOTOCO.NS']
Example for themei_group
stocks = getThematicNiftyStocks(group_name='themei_group', group_item='NIFTY_MIDCAP_LIQUID_15', return_type='as_list')
Output: ['FEDERALBNK', 'RECLTD', 'BEL', 'IRCTC', 'AUBANK', 'ZEEL', 'SRTRANSFIN', 'TATAPOWER', 'AUROPHARMA', 'ASHOKLEY', 'TVSMOTOR', 'GODREJPROP', 'BHARATFORG', 'MPHASIS', 'BALKRISIND']
This package is designed in such a way that, even if you provide some wrong inputs, the package will provide 'default' for each of the theme, which is mentioned above. It is essential that you capture the return as a 'text' or 'list' (with or without '.NS' extension). So, please note the debug comments while you capture stocks
via the invocation of getThematicNiftyStocks()
method.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file thematicnifty-0.1.4.tar.gz
.
File metadata
- Download URL: thematicnifty-0.1.4.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cc9181972bca4a348aafecba003353df646c215516e0b4f1f389de56776cd6b |
|
MD5 | 739114cb859508f0b2f6e052536435dd |
|
BLAKE2b-256 | 6ab7065726494c7d81b26e56991f808977eb4b26780cfd5185b8bf49e1262e3c |
File details
Details for the file thematicnifty-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: thematicnifty-0.1.4-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 501fd18fedf7f4d845de7331843c5c997a3edd15abf2ec3b12d0baad0ced4eb3 |
|
MD5 | 18f068b722d8c162d4576dbfd7dfc37f |
|
BLAKE2b-256 | 51058f00d3273dc3b8576207e5c5f70b8d107f5d7bcf149412e6c8e41de513f7 |