rajan_nse package

Submodules

rajan_nse.CandleStickPatterns module

class rajan_nse.CandleStickPatterns.CandleStickPatterns

Bases: object

bullishEngullfingPattern(symbol, live=True, delta=200)

This function is used to identify bullish engullfing pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

dojiPattern(symbol, live=True, delta=200)

This function is used to identify doji pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

fallingWedgePattern(symbol, live=False, period=200)

This function is used to identify falling wedge pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

hammerPattern(symbol, live=True, delta=200)

This function is used to identify hammer pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

risingWedgePattern(symbol, live=False, period=200)

This function is used to identify rising wedge pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

wedgePattern(symbol, live=False, period=200)

This function is used to identify wedge pattern in the given stock symbol and returns a string indicating the type.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

rajan_nse.NseData module

class rajan_nse.NseData.NseData

Bases: object

fiftyTwoWeekHighLow(symbol, live=True)

Get 52 Weeks High and Low values for given symbol

Keyword arguments: symbol – symbol of the stock live – boolean value to get data from live or historical data

Return structure: {

‘high’: 100, ‘low’: 15,

‘price’: 55

}

getCurrentData(symbol)

Get current market data for the symbol and return the json response

Keyword arguments: symbol – the symbol of the stock

Request url: https://www.nseindia.com/api/quote-equity?symbol=X Response structure: {

“info”: {

“symbol”: “X”, “companyName”: “X Limited”, “industry”: “COMPUTERS - SOFTWARE”, “activeSeries”: [ “EQ” ], “debtSeries”: [], “isFNOSec”: true, “isCASec”: false, “isSLBSec”: true, “isDebtSec”: false, “isSuspended”: false, “tempSuspendedSeries”: [], “isETFSec”: false, “isDelisted”: false, “isin”: “INE075A01022”, “isMunicipalBond”: false, “isTop10”: false, “identifier”: “XEQN”

}, “metadata”: {

“series”: “EQ”, “symbol”: “X”, “isin”: “INE075A01022”, “status”: “Listed”, “listingDate”: “08-Nov-1995”, “industry”: “Computers - Software & Consulting”, “lastUpdateTime”: “02-Jul-2024 15:24:00”, “pdSectorPe”: 24.77, “pdSymbolPe”: 24.77, “pdSectorInd”: “NIFTY IT “

}, “securityInfo”: {

“boardStatus”: “Main”, “tradingStatus”: “Active”, “tradingSegment”: “Normal Market”, “sessionNo”: “-“, “slb”: “Yes”, “classOfShare”: “Equity”, “derivatives”: “Yes”, “surveillance”: { “surv”: null, “desc”: null }, “faceValue”: 2, “issuedSize”: 5230164205

}, “sddDetails”: {

“SDDAuditor”: “-“, “SDDStatus”: “-”

}, “priceInfo”: {

“lastPrice”: 537.55, “change”: 10.199999999999932, “pChange”: 1.9341992983786729, “previousClose”: 527.35, “open”: 529.3, “close”: 0, “vwap”: 538.33, “lowerCP”: “474.65”, “upperCP”: “580.05”, “pPriceBand”: “No Band”, “basePrice”: 527.35, “intraDayHighLow”: { “min”: 528.3, “max”: 545, “value”: 537.55 }, “weekHighLow”: { “min”: 375.05, “minDate”: “26-Oct-2023”, “max”: 545.9, “maxDate”: “19-Feb-2024”, “value”: 537.55 }, “iNavValue”: null, “checkINAV”: false

}, “industryInfo”: {

“macro”: “Information Technology”, “sector”: “Information Technology”, “industry”: “IT - Software”, “basicIndustry”: “Computers - Software & Consulting”

}, “preOpenMarket”: {

“preopen”: [ {

“price”: 474.65, “buyQty”: 0, “sellQty”: 604

}, {

“price”: 480, “buyQty”: 0, “sellQty”: 500

}, {

“price”: 501, “buyQty”: 0, “sellQty”: 7161

}, {

“price”: 503.6, “buyQty”: 0, “sellQty”: 10

}, {

“price”: 529.3, “buyQty”: 0, “sellQty”: 0, “iep”: true

}, {

“price”: 551.05, “buyQty”: 306, “sellQty”: 0

}, {

“price”: 551.1, “buyQty”: 8, “sellQty”: 0

}, {

“price”: 580, “buyQty”: 20, “sellQty”: 0

}, {

“price”: 580.05, “buyQty”: 205, “sellQty”: 0

} ], “ato”: { “buy”: 24235, “sell”: 2858 }, “IEP”: 529.3, “totalTradedVolume”: 98656, “finalPrice”: 529.3, “finalQuantity”: 98656, “lastUpdateTime”: “02-Jul-2024 09:08:03”, “totalBuyQuantity”: 79562, “totalSellQuantity”: 304045, “atoBuyQty”: 24235, “atoSellQty”: 2858, “Change”: 1.9499999999999318, “perChange”: 0.3697733952782652, “prevClose”: 527.35

}

}

getHistoricalData(symbol, delta=200, to_date=datetime.date(2026, 5, 6), depth=3)

Get historical data for a given symbol.

Keyword arguments: symbol – the symbol of the stock delta – the number of days to get data for (default 200) to_date – the date to get data up to (default today) depth – the number of loop count to get data for (default 3, i.e 3*200 count)

Request url: https://www.nseindia.com/api/historical/cm/equity?symbol=SYMBOL&series=[“EQ”]&from=FROM&to=TO

getInsiderTradingDataWithSymbol(symbol, delta=90)

Get insider trainind data for a given symbol.

Keywork arguments: symbol – The symbol of the stock. delta – The number of days to fetch data for. Default is 90 days.

Response structure: [

{

“symbol”: “COMPANY”, “company”: “COMPANY”, “anex”: “7(2)”, “acqName”: “SHOBHA AGARWAL”, “date”: “14-Dec-2023 18:02”, “pid”: “1157172”, “tkdAcqm”: null, “buyValue”: “0”, “sellValue”: “0”, “buyQuantity”: “0”, “sellquantity”: “0”, “secType”: “Equity Shares”, “secAcq”: “150000”, “did”: “489950”, “tdpTransactionType”: “Sell”, “tdpDerivativeContractType”: “-“, “xbrl”: “https://nsearchives.nseindia.com/corporate/xbrl/IT_1157172_997084_14122023060254_WEB.xml”, “personCategory”: “Immediate relative”, “befAcqSharesNo”: “731905”, “befAcqSharesPer”: “0.01”, “secVal”: “0”, “securitiesTypePost”: “Equity Shares”, “afterAcqSharesNo”: “581905”, “afterAcqSharesPer”: “0.01”, “acqfromDt”: “11-Dec-2023”, “acqtoDt”: “11-Dec-2023”, “intimDt”: “12-Dec-2023”, “acqMode”: “Gift”, “derivativeType”: “-“, “exchange”: “NA”, “remarks”: “-”

}, { … }

]

getOISpurtsData()

Get OI spurts data

getTopGainersLosers()

Get indexDataInfo data with following structure response structure: {

‘advance’: {}, ‘topGainers’: {}, ‘topLosers’: {}, ‘topVolume’: {}, ‘topValue’: {}

}

rajan_nse.Session module

class rajan_nse.Session.Session(base_url)

Bases: object

cookies = {}
createNewSession()

Launch a headless browser to fetch fresh NSE session cookies, then prime the requests session with them.

headers = {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'DNT': '1', 'Host': 'www.nseindia.com', 'Pragma': 'no-cache', 'Priority': 'u=4', 'Referer': 'https://www.nseindia.com/', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Sec-GPC': '1', 'TE': 'trailers', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:150.0) Gecko/20100101 Firefox/150.0'}
makeRequest(url, params=None, responseType='json')

This method is used to make a request to the url and set response cookies

Keywork arguments: url – The url to make the request to. params – The parameters to be passed in the url. responseType – json|text

rajan_nse.Strategies module

class rajan_nse.Strategies.Strategies

Bases: object

oiSpurtsFilteredGainerStocks()

This method get all the stocks based on the below filter

Stocks that appear in daily top gainers or losers that has OI change > 4% by 9:20AM

oiSpurtsFilteredLoserStocks()

This method get all the stocks based on the below filter

Stocks that appear in daily top gainers or losers that has OI change > 4% by 9:20AM

promoterBuyBackStocks(delta=90, to_date=datetime.date(2026, 5, 6), save_to_file=False)

This function will return the list of stocks which are filtered by promoter buy back strategy with following seven steps. 1. Get the list of stocks which are intraday traded in last 90 days (3months) 2. Filter out the stocks in which traded value is less than 1cr 3. Filter out the stocks in which promoter holding is less than 50% 4. Filter out the stocks based on sast data 5/6/7. Individual stock analysis for promoter details

rajan_nse.TechnicalIndicators module

class rajan_nse.TechnicalIndicators.TechnicalIndicators

Bases: object

cmf(symbol, period=21)

Chaikin Money Flow (CMF) developed by Marc Chaikin is a volume-weighted average of accumulation and distribution over a specified period. The standard CMF period is 21 days. The principle behind the Chaikin Money Flow is the nearer the closing price is to the high, the more accumulation has taken place. Conversely, the nearer the closing price is to the low, the more distribution has taken place. If the price action consistently closes above the bar’s midpoint on increasing volume, the Chaikin Money Flow will be positive. Conversely, if the price action consistently closes below the bar’s midpoint on increasing volume, the Chaikin Money Flow will be a negative value. Calculations: CMF = n-day Sum of [(((C - L) - (H - C)) / (H - L)) x Vol] / n-day Sum of Vol Where: n = number of periods, typically 21 H = high L = low C = close Vol = volume

Keyword Arguments: symbol – Stock symbol listed on NSE period – The period for which SMA should be calculated (default = 21)

near52WeekHigh(symbol, live=False, delta=5)

This method is used to return a boolean if the stock is near 52 Week high value for a NSE stock.

Keyword arguments: symbol – Stock symbol listed on NSE website live – Boolean to get current running price value or previous day value delta – The delta as percentage to check if stock is in +- that range of high(default = 5 percentage)

near52WeekLow(symbol, live=False, delta=5)

This method is used to return a boolean if the stock is near 52 Week low value for a NSE stock.

Keyword arguments: symbol – Stock symbol listed on NSE website live – Boolean to get current running price value or previous day value delta – The delta as percentage to check if stock is in +- that range of low(default = 5 percentage)

rsi(symbol, period=14)

This method is used to calculate relative strength index (rsi) of stocks based on daily timeframe.

Keyword arguments: symbol – Stock symbol listed on NSE period – The period for which SMA should be calculated (default = 14)

Returns: integer value of calculated RSI

sma(symbol=None, period=200, data=None)

This method is used to calculate simple moving average of stocks based on daily timeframe.

Keyword arguments: symbol – Stock symbol listed on NSE period – The period for which SMA should be calculated (default = 200) data – Historical data of a stock (default = None i.e. historical value will be fetched)

Returns: integer value of calculated SMA -1 if there is an error in calculation

trendLine(symbol, delta=200, lower_percentile=40, upper_percentile=98, to_date=datetime.date(2026, 5, 6))

This method returns the series of price values that creates a trend line both upper and lower.

Keyword arguments: symbol – Stock symbol listed on NSE website delta – Check trend for these number of historical days low_percentile – Percentile value above which the traded qty. (volume) should be (default value = 40) upper_percentile – Percentile value below which the traded qty. (volume) should be (default value = 98) to_date – date till which the trend line should be

Returns: returns a dataframe for lower trendline and upper trendline values list

rajan_nse.Visualization module

class rajan_nse.Visualization.Visualization

Bases: object

plotDistribution(data, save=False, filePath='distribution_plot.png')

rajan_nse.helpers module

rajan_nse.helpers.filterBasedOnPromoterBuyBackStrategy(session: Session, to_date_formated, from_date_formated, allowed_diff=0.05)
rajan_nse.helpers.filterStocksBasedOnPromoterAndSast(session: Session, to_date_formated, from_date_formated)
rajan_nse.helpers.filterStocksBasedOnValueThreshold(session: Session, to_date_formated, from_date_formated, threshold=10000000)
rajan_nse.helpers.findAvgPrice(session: Session, to_date_formated, from_date_formated, symbol)
rajan_nse.helpers.getInsiderTradingData(session: Session, to_date_formated, from_date_formated)
rajan_nse.helpers.isPromoterFilterPassed(session: Session, symbol)
rajan_nse.helpers.isSastRegulationFilterPassed(session: Session, symbol)
rajan_nse.helpers.lastPrice(session: Session, symbol)

Module contents

rajan_nse package

The rajan_nse package is a comprehensive toolkit designed for analyzing and visualizing stock market data from the National Stock Exchange (NSE) of India. This package provides various modules to facilitate technical analysis, identify candlestick patterns, create visual representations, and develop trading strategies.

class rajan_nse.CandleStickPatterns

Bases: object

bullishEngullfingPattern(symbol, live=True, delta=200)

This function is used to identify bullish engullfing pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

dojiPattern(symbol, live=True, delta=200)

This function is used to identify doji pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

fallingWedgePattern(symbol, live=False, period=200)

This function is used to identify falling wedge pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

hammerPattern(symbol, live=True, delta=200)

This function is used to identify hammer pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

risingWedgePattern(symbol, live=False, period=200)

This function is used to identify rising wedge pattern in the given stock symbol and returns a boolean.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

wedgePattern(symbol, live=False, period=200)

This function is used to identify wedge pattern in the given stock symbol and returns a string indicating the type.

Keywork arguments: symbol – The stock symbol for which the doji pattern is to be identified. live – A boolean value indicating whether the data is to be fetched from live market or historical data. delta – The time delta in days for which the data is to be fetched.

class rajan_nse.NseData

Bases: object

fiftyTwoWeekHighLow(symbol, live=True)

Get 52 Weeks High and Low values for given symbol

Keyword arguments: symbol – symbol of the stock live – boolean value to get data from live or historical data

Return structure: {

‘high’: 100, ‘low’: 15,

‘price’: 55

}

getCurrentData(symbol)

Get current market data for the symbol and return the json response

Keyword arguments: symbol – the symbol of the stock

Request url: https://www.nseindia.com/api/quote-equity?symbol=X Response structure: {

“info”: {

“symbol”: “X”, “companyName”: “X Limited”, “industry”: “COMPUTERS - SOFTWARE”, “activeSeries”: [ “EQ” ], “debtSeries”: [], “isFNOSec”: true, “isCASec”: false, “isSLBSec”: true, “isDebtSec”: false, “isSuspended”: false, “tempSuspendedSeries”: [], “isETFSec”: false, “isDelisted”: false, “isin”: “INE075A01022”, “isMunicipalBond”: false, “isTop10”: false, “identifier”: “XEQN”

}, “metadata”: {

“series”: “EQ”, “symbol”: “X”, “isin”: “INE075A01022”, “status”: “Listed”, “listingDate”: “08-Nov-1995”, “industry”: “Computers - Software & Consulting”, “lastUpdateTime”: “02-Jul-2024 15:24:00”, “pdSectorPe”: 24.77, “pdSymbolPe”: 24.77, “pdSectorInd”: “NIFTY IT “

}, “securityInfo”: {

“boardStatus”: “Main”, “tradingStatus”: “Active”, “tradingSegment”: “Normal Market”, “sessionNo”: “-“, “slb”: “Yes”, “classOfShare”: “Equity”, “derivatives”: “Yes”, “surveillance”: { “surv”: null, “desc”: null }, “faceValue”: 2, “issuedSize”: 5230164205

}, “sddDetails”: {

“SDDAuditor”: “-“, “SDDStatus”: “-”

}, “priceInfo”: {

“lastPrice”: 537.55, “change”: 10.199999999999932, “pChange”: 1.9341992983786729, “previousClose”: 527.35, “open”: 529.3, “close”: 0, “vwap”: 538.33, “lowerCP”: “474.65”, “upperCP”: “580.05”, “pPriceBand”: “No Band”, “basePrice”: 527.35, “intraDayHighLow”: { “min”: 528.3, “max”: 545, “value”: 537.55 }, “weekHighLow”: { “min”: 375.05, “minDate”: “26-Oct-2023”, “max”: 545.9, “maxDate”: “19-Feb-2024”, “value”: 537.55 }, “iNavValue”: null, “checkINAV”: false

}, “industryInfo”: {

“macro”: “Information Technology”, “sector”: “Information Technology”, “industry”: “IT - Software”, “basicIndustry”: “Computers - Software & Consulting”

}, “preOpenMarket”: {

“preopen”: [ {

“price”: 474.65, “buyQty”: 0, “sellQty”: 604

}, {

“price”: 480, “buyQty”: 0, “sellQty”: 500

}, {

“price”: 501, “buyQty”: 0, “sellQty”: 7161

}, {

“price”: 503.6, “buyQty”: 0, “sellQty”: 10

}, {

“price”: 529.3, “buyQty”: 0, “sellQty”: 0, “iep”: true

}, {

“price”: 551.05, “buyQty”: 306, “sellQty”: 0

}, {

“price”: 551.1, “buyQty”: 8, “sellQty”: 0

}, {

“price”: 580, “buyQty”: 20, “sellQty”: 0

}, {

“price”: 580.05, “buyQty”: 205, “sellQty”: 0

} ], “ato”: { “buy”: 24235, “sell”: 2858 }, “IEP”: 529.3, “totalTradedVolume”: 98656, “finalPrice”: 529.3, “finalQuantity”: 98656, “lastUpdateTime”: “02-Jul-2024 09:08:03”, “totalBuyQuantity”: 79562, “totalSellQuantity”: 304045, “atoBuyQty”: 24235, “atoSellQty”: 2858, “Change”: 1.9499999999999318, “perChange”: 0.3697733952782652, “prevClose”: 527.35

}

}

getHistoricalData(symbol, delta=200, to_date=datetime.date(2026, 5, 6), depth=3)

Get historical data for a given symbol.

Keyword arguments: symbol – the symbol of the stock delta – the number of days to get data for (default 200) to_date – the date to get data up to (default today) depth – the number of loop count to get data for (default 3, i.e 3*200 count)

Request url: https://www.nseindia.com/api/historical/cm/equity?symbol=SYMBOL&series=[“EQ”]&from=FROM&to=TO

getInsiderTradingDataWithSymbol(symbol, delta=90)

Get insider trainind data for a given symbol.

Keywork arguments: symbol – The symbol of the stock. delta – The number of days to fetch data for. Default is 90 days.

Response structure: [

{

“symbol”: “COMPANY”, “company”: “COMPANY”, “anex”: “7(2)”, “acqName”: “SHOBHA AGARWAL”, “date”: “14-Dec-2023 18:02”, “pid”: “1157172”, “tkdAcqm”: null, “buyValue”: “0”, “sellValue”: “0”, “buyQuantity”: “0”, “sellquantity”: “0”, “secType”: “Equity Shares”, “secAcq”: “150000”, “did”: “489950”, “tdpTransactionType”: “Sell”, “tdpDerivativeContractType”: “-“, “xbrl”: “https://nsearchives.nseindia.com/corporate/xbrl/IT_1157172_997084_14122023060254_WEB.xml”, “personCategory”: “Immediate relative”, “befAcqSharesNo”: “731905”, “befAcqSharesPer”: “0.01”, “secVal”: “0”, “securitiesTypePost”: “Equity Shares”, “afterAcqSharesNo”: “581905”, “afterAcqSharesPer”: “0.01”, “acqfromDt”: “11-Dec-2023”, “acqtoDt”: “11-Dec-2023”, “intimDt”: “12-Dec-2023”, “acqMode”: “Gift”, “derivativeType”: “-“, “exchange”: “NA”, “remarks”: “-”

}, { … }

]

getOISpurtsData()

Get OI spurts data

getTopGainersLosers()

Get indexDataInfo data with following structure response structure: {

‘advance’: {}, ‘topGainers’: {}, ‘topLosers’: {}, ‘topVolume’: {}, ‘topValue’: {}

}

class rajan_nse.Session(base_url)

Bases: object

cookies = {}
createNewSession()

Launch a headless browser to fetch fresh NSE session cookies, then prime the requests session with them.

headers = {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'DNT': '1', 'Host': 'www.nseindia.com', 'Pragma': 'no-cache', 'Priority': 'u=4', 'Referer': 'https://www.nseindia.com/', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Sec-GPC': '1', 'TE': 'trailers', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:150.0) Gecko/20100101 Firefox/150.0'}
makeRequest(url, params=None, responseType='json')

This method is used to make a request to the url and set response cookies

Keywork arguments: url – The url to make the request to. params – The parameters to be passed in the url. responseType – json|text

class rajan_nse.Strategies

Bases: object

oiSpurtsFilteredGainerStocks()

This method get all the stocks based on the below filter

Stocks that appear in daily top gainers or losers that has OI change > 4% by 9:20AM

oiSpurtsFilteredLoserStocks()

This method get all the stocks based on the below filter

Stocks that appear in daily top gainers or losers that has OI change > 4% by 9:20AM

promoterBuyBackStocks(delta=90, to_date=datetime.date(2026, 5, 6), save_to_file=False)

This function will return the list of stocks which are filtered by promoter buy back strategy with following seven steps. 1. Get the list of stocks which are intraday traded in last 90 days (3months) 2. Filter out the stocks in which traded value is less than 1cr 3. Filter out the stocks in which promoter holding is less than 50% 4. Filter out the stocks based on sast data 5/6/7. Individual stock analysis for promoter details

class rajan_nse.TechnicalIndicators

Bases: object

cmf(symbol, period=21)

Chaikin Money Flow (CMF) developed by Marc Chaikin is a volume-weighted average of accumulation and distribution over a specified period. The standard CMF period is 21 days. The principle behind the Chaikin Money Flow is the nearer the closing price is to the high, the more accumulation has taken place. Conversely, the nearer the closing price is to the low, the more distribution has taken place. If the price action consistently closes above the bar’s midpoint on increasing volume, the Chaikin Money Flow will be positive. Conversely, if the price action consistently closes below the bar’s midpoint on increasing volume, the Chaikin Money Flow will be a negative value. Calculations: CMF = n-day Sum of [(((C - L) - (H - C)) / (H - L)) x Vol] / n-day Sum of Vol Where: n = number of periods, typically 21 H = high L = low C = close Vol = volume

Keyword Arguments: symbol – Stock symbol listed on NSE period – The period for which SMA should be calculated (default = 21)

near52WeekHigh(symbol, live=False, delta=5)

This method is used to return a boolean if the stock is near 52 Week high value for a NSE stock.

Keyword arguments: symbol – Stock symbol listed on NSE website live – Boolean to get current running price value or previous day value delta – The delta as percentage to check if stock is in +- that range of high(default = 5 percentage)

near52WeekLow(symbol, live=False, delta=5)

This method is used to return a boolean if the stock is near 52 Week low value for a NSE stock.

Keyword arguments: symbol – Stock symbol listed on NSE website live – Boolean to get current running price value or previous day value delta – The delta as percentage to check if stock is in +- that range of low(default = 5 percentage)

rsi(symbol, period=14)

This method is used to calculate relative strength index (rsi) of stocks based on daily timeframe.

Keyword arguments: symbol – Stock symbol listed on NSE period – The period for which SMA should be calculated (default = 14)

Returns: integer value of calculated RSI

sma(symbol=None, period=200, data=None)

This method is used to calculate simple moving average of stocks based on daily timeframe.

Keyword arguments: symbol – Stock symbol listed on NSE period – The period for which SMA should be calculated (default = 200) data – Historical data of a stock (default = None i.e. historical value will be fetched)

Returns: integer value of calculated SMA -1 if there is an error in calculation

trendLine(symbol, delta=200, lower_percentile=40, upper_percentile=98, to_date=datetime.date(2026, 5, 6))

This method returns the series of price values that creates a trend line both upper and lower.

Keyword arguments: symbol – Stock symbol listed on NSE website delta – Check trend for these number of historical days low_percentile – Percentile value above which the traded qty. (volume) should be (default value = 40) upper_percentile – Percentile value below which the traded qty. (volume) should be (default value = 98) to_date – date till which the trend line should be

Returns: returns a dataframe for lower trendline and upper trendline values list

class rajan_nse.Visualization

Bases: object

plotDistribution(data, save=False, filePath='distribution_plot.png')