Package: thematicnifty
Package niftythematicDate: 10-Apr-2022InstallationUse the following for importing:from thematicnifty import tnPrerequisitesThepandaspackage will be imported aspd.FeaturesThis 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 thebmitheme, you can get the stocks of the usual groups such asNIFTY_50,NIFTY_100,NIFTY_200, etc. These are the sub-themes of the mainbmitheme. A complete list of themes underbmigroup is provided at the end of this document.Fromsecti, you can get the stocks belonging to different sectors such asNIFTY_AUTO,NIFTY_IT,NIFTY_PHARMA,NIFTY_FMCG, etc. These are the sub-themes of the mainsectitheme. A complete list of themes undersectigroup is provided at the end of this document.Fromstrati, you can you can extract stocks belonging to the groups such asNIFTY50_EQUAL_WEIGHT,NIFTY50_VALUE_20,NIFTY_ALPHA_50, etc. These are the sub-themes of the mainstratitheme. A complete list of themes understratigroup is provided at the end of this document.Finally, fromthemei, you can fetch stocks belonging to groups such asNIFTY100_LIQUID_15,NIFTY_CPSE,NIFTY_MIDCAP_LIQUID_15,NIFTY_MNC, etc. These are the sub-themes of the mainthemeitheme. A complete list of themes underthemeigroup is provided at the end of this document.Method DesignThis is designed to be simple, and there is a single method with three parameters.getThematicNiftyStocks(main_item, sub_item, return_output)Description of the MethodThegetThematicNiftyStocks()method takes just 3 string inputs:group_namegroup_itemreturn_typeDescription of each of the above is given hereunder.group_nameThe main item can be one of the following four -bmi_group(default),secti_group,strati_grouporthemei_group. As already indicated,bmistands forBroad Market Indices,sectistands forSectorial Indices,stratistands forStrategic Indices, andthemeistands forThematic Indices.group_itemThe sub_items are different for different main_item. Forbmi, the sub_item can be one of the following 16. The default value is 'NIFTY_50'.NIFTY_MIDSMALLCAP_400NIFTY_200NIFTY_LARGEMIDCAP_250NIFTY_TOTAL_MARKETNIFTY_50(default)NIFTY_SMALLCAP_50NIFTY_SMALLCAP_250NIFTY_SMALLCAP_100NIFTY_100NIFTY_MIDCAP_150NIFTY_MIDCAP_SELECTNIFTY_NEXT_50NIFTY500_MULTICAP_50_25_25NIFTY_MICROCAP_250NIFTY_MIDCAP_50NIFTY_MIDCAP_100'Forsecti, the sub_item can be one of the following 16: The default value is 'NIFTY_BANK'.NIFTY_PHARMANIFTY_BANK(default)NIFTY_PSU_BANKNIFTY_FMCGNIFTY_CONSUMER_DURABLESNIFTY_PRIVATE_BANKNIFTY_AUTONIFTY_HEALTHCARE_INDEXNIFTY_ENERGYNIFTY_METALNIFTY_OIL_and_GASNIFTY_REALTYNIFTY_FINANCIAL_SERVICES_25_50NIFTY_FINANCIAL_SERVICESNIFTY_MEDIANIFTY_ITForstrati, the sub_item can be one of the following 10: The default is 'NIFTY_ALPHA_50'.NIFTY100_LOW_VOLATILITY_30NIFTY100_QUALITY_30NIFTY50_VALUE_20NIFTY_MIDCAP150_QUALITY_50NIFTY_ALPHA_50(default)NIFTY200_QUALITY_30NIFTY100_EQUAL_WEIGHTNIFTY_ALPHA_LOW_VOLATILITY_30NIFTY200_MOMENTUM_30NIFTY_DIVIDEND_OPPORTUNITIES_50Finally, forthemei, the sub_item can be one of the following 10: The default value is 'NIFTY100_LIQUID_15'.NIFTY100_ESGNIFTY_INDIA_CONSUMPTIONNIFTY_SERVICES_SECTORNIFTY_INFRASTRUCTURENIFTY_INDIA_DIGITALNIFTY_PSENIFTY100_LIQUID_15(default)NIFTY_INDIA_MANUFACTURINGNIFTY_CPSENIFTY_MIDCAP_LIQUID_15NIFTY_GROWTH_SECTORS_15NIFTY_COMMODITIESNIFTY_MNC'return_typeAs 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 parametersThe method has been designed with the following default parameters:group_name ='bmi_group'group_item ='NIFTY_50'return_type ='as_text_with_NS'Method UsageExample forbmi_groupRun 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.NSExample forsecti_groupstocks = getThematicNiftyStocks(group_name='secti_group', group_item='NIFTY_IT', return_type='as_text')Output:WIPRO TCS LTTS HCLTECH INFY LTI MINDTREE TECHM MPHASIS COFORGEExample forstrati_groupstocks = 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 forthemei_groupstocks = 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 capturestocksvia the invocation ofgetThematicNiftyStocks()method.