niftythematic 0.1.5
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.
Requires Python: >=3.6

# Package niftythematic
Date: 10-Feb-2022

## Installation

Use the following for importing: ```from niftythematic import nt```

## Prerequisites
This package requires ```os```, ```glob``` and ```pandas```.  The ```pandas``` 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.


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.

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.

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.

When you fetch the list of any of the sub-theme from any of the main theme, you can get it as one of the following outputs:



*   List of Stock symbols (```returnOutput='list'```)
*   List of Stock symbols with .NS as the suffix (```returnOutput='list_with_ns'```)
*   String of Stock symbols (```returnOutput='text'```)
*   String of Stock symbols with .NS as the suffix (```returnOutput='text_with_ns'```)

# Method Design
This is designed to be simple, and there is a single method with three parameters.

```getThematicNiftyStocks(main_item, sub_item, returnOutput)```

## Description of the Method

The ```getThematicNiftyStocks()``` method takes just 3 string inputs:

*   main_item
*   sub_item
*   returnOutput

### main_item
The main item can be one of the following four - ```bmi``` (default), ```secti```, ```strati``` or ```themei```. As already indicated, ```bmi``` stands for *Broad Market Indices*, ```secti``` is *Sectorial Indices*, ```strati``` stands for *Strategic Indices*, and ```themei``` stands for *Thematic Indices*.

### sub_item
The sub_items are different for different main_item. For ```bmi```, the sub_item can be one of the following 12. The default value is 'NIFTY_50'.

1.  NIFTY_50 (default)
2.  NIFTY_100
3.  NIFTY_200
4.  NIFTY_LARGEMIDCAP_50:25:25
5.  NIFTY_LARGEMIDCAP_50
6.  NIFTY_LARGEMIDCAP_100
7.  NIFTY_LARGEMIDCAP_150
8.  NIFTY_MIDSMALLCAP_400
9.  NIFTY_NEXT_50
10. NIFTY_SMALLCAP_50
11. NIFTY_SMALLCAP_100
12. NIFTY_SMALLCAP_250


For ```secti```, the sub_item can be one of the following 16: The default value is 'NIFTY_AUTO'.

1.   NIFTY_AUTO (default)
2.   NIFTY_BANK
3.   NIFTY_CONSUMER_DURABLES
4.   NIFTY_ENERGY
5.   NIFTY_FINANCIAL_SERVICES
6.   NIFTY_FINANCIAL_SERVICES_25_50
7.   NIFTY_FMCG
8.   NIFTY_HEALTHCARE_INDEX
9.   NIFTY_IT
10.  NIFTY_MEDIA
11.  NIFTY_METAL
12.  NIFTY_OIL_&_GAS
13.  NIFTY_PHARMA
14.  NIFTY_PRIVATE_BANK
15.  NIFTY_PSU_BANK
16.  NIFTY_REALTY

For ```strati```, the sub_item can be one of the following 10: The default is 'NIFTY50_EQUAL_WEIGHT'.

1.   NIFTY50_EQUAL_WEIGHT (default)
2.   NIFTY50_VALUE_20
3.   NIFTY100_EQUAL_WEIGHT
4.   NIFTY100_LOW_VOLATALITY_30
5.   NIFTY100_QUALITY_30
6.   NIFTY200_MOMENTUM_30
7.   NIFTY200_QUALITY_30
8.   NIFTY_ALPHA_50
9.   NIFTY_ALPHA_LOW-VOLATALITY_30
10.  NIFTY_DIVIDEND_OPPORTUNITIES_50

Finally, for ```themei```, the sub_item can be one of the following 10: The default value is 'NIFTY100_LIQUID_15'.

1.   NIFTY100_LIQUID_15 (default)
2.   NIFTY_COMMODITIES
3.   NIFTY_CPSE
4.   NIFTY_GROWTH_SECTORS_15
5.   NIFTY_INDIA_CONSUMPTION
6.   NIFTY_INFRASTRUCTURE
7.   NIFTY_MIDCAP_LIQUID_15
8.   NIFTY_MNC
9.   NIFTY_PSE
10.  NIFTY_SERVICES_SECTOR

### returnOutput
As indicated earlier, returnOutput can take one of the following options:

1.   ```'list'```
2.   ```'list_with_ns'```
3.   ```'text'```
4.   ```'text_with_ns'``` (default)

### Default values for the method parameters
The method has been designed with the following default parameters:

1.   main_item = ```'bmi'```
2.   sub_item = ```'NIFTY_50'```
3.   returnOutput = ```'text_with_ns'```



# Method Usage
## Example for ```bmi```

If you run the following method,

```getThematicNiftyStocks('bmi', 'NIFTY_50', 'text_with_ns')```

the output will be the following:

Output: ```HCLTECH.NS ADANIPORTS.NS HDFC.NS TECHM.NS ONGC.NS DIVISLAB.NS TCS.NS RELIANCE.NS TATACONSUM.NS GRASIM.NS SUNPHARMA.NS INFY.NS HDFCBANK.NS SBIN.NS LT.NS ULTRACEMCO.NS SBILIFE.NS NESTLEIND.NS NTPC.NS SHREECEM.NS WIPRO.NS MARUTI.NS POWERGRID.NS AXISBANK.NS BAJAJFINSV.NS BAJAJ-AUTO.NS M&M.NS ICICIBANK.NS HINDUNILVR.NS TITAN.NS CIPLA.NS BHARTIARTL.NS UPL.NS KOTAKBANK.NS INDUSINDBK.NS HEROMOTOCO.NS ASIANPAINT.NS TATAMOTORS.NS ITC.NS BRITANNIA.NS DRREDDY.NS HDFCLIFE.NS IOC.NS EICHERMOT.NS BAJFINANCE.NS COALINDIA.NS HINDALCO.NS BPCL.NS TATASTEEL.NS JSWSTEEL.NS```

## Example for ```secti```

```getThematicNiftyStocks(main_item='secti', sub_item='NIFTY_IT', returnOutput='text_with_ns')```

Output: ```HCLTECH.NS COFORGE.NS TECHM.NS LTI.NS TCS.NS LTTS.NS MINDTREE.NS INFY.NS WIPRO.NS MPHASIS.NS```

## Example for ```strati```

```getThematicNiftyStocks(main_item='strati', sub_item='NIFTY50_VALUE_20', returnOutput='text_with_ns')```

Output: ```HCLTECH.NS TECHM.NS ONGC.NS TCS.NS GRASIM.NS INFY.NS LT.NS NTPC.NS WIPRO.NS POWERGRID.NS BAJAJ-AUTO.NS HINDUNILVR.NS UPL.NS HEROMOTOCO.NS ITC.NS IOC.NS COALINDIA.NS HINDALCO.NS BPCL.NS JSWSTEEL.NS```

## Example for ```themei```

```getThematicNiftyStocks(main_item='themei', sub_item='NIFTY_MIDCAP_LIQUID_15', returnOutput='text_with_ns')```

Output: ```AUBANK.NS FEDERALBNK.NS TATAPOWER.NS BALKRISIND.NS ASHOKLEY.NS BHARATFORG.NS PAGEIND.NS SRF.NS SRTRANSFIN.NS VOLTAS.NS BEL.NS TVSMOTOR.NS ZEEL.NS RECLTD.NS LICHSGFIN.NS```