Nse 2 R

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Package ‘nse2r’

November 1, 2022
Type Package
Title Fetch Data from 'National Stock Exchange (India)'
Version 0.1.6
Description Fetch data related to stocks, index, futures & options from the
'NSE (National Stock Exchange, India)'. This package is community maintained
and is not officially supported by 'NSE'. The accuracy of data is only as
correct as provided on <https://www.nseindia.com>.
License MIT + file LICENSE

URL https://github.com/rsquaredacademy/nse2r,
https://nse2r.rsquaredacademy.com/

BugReports https://github.com/rsquaredacademy/nse2r/issues
Depends R(>= 3.3)
Imports jsonlite, magrittr, utils, yahoofinancer
Suggests covr, DT, httptest, shiny, shinyBS, shinycssloaders,
shinythemes, testthat (>= 2.1.0)
Encoding UTF-8
RoxygenNote 7.1.1
NeedsCompilation no
Author Lokesh Kumar [aut],
Aravind Hebbali [aut, cre],
Lionel Pinto [ctb]
Maintainer Aravind Hebbali <[email protected]>
Repository CRAN
Date/Publication 2022-11-01 15:17:53 UTC

R topics documented:
nse2r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
nse_advances_declines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1
2 nse_advances_declines

nse_app . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
nse_fo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
nse_index_list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
nse_index_quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
nse_index_valid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
nse_stock_code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
nse_stock_high_low . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
nse_stock_most_traded . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
nse_stock_quote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
nse_stock_top_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
nse_stock_valid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
preopen_nifty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Index 14

nse2r nse2r package

Description
Tools for Collecting Real Time Data from National Stock Exchange (India)

nse_advances_declines Advances & Declines

Description
NSE indices advances & declines.

Usage
nse_advances_declines(clean_names = TRUE)

Arguments
clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.

Value
A tibble with the following columns:

index_name Name of the index.


advances Number of stocks increased (in green).
declines Number of stocks decreased (in red).
unchanged Number of stocks unchanged.
nse_app 3

Examples
## Not run:
nse_advances_declines()

# retain original column names as returned by NSE


nse_advances_declines(clean_names = FALSE)

## End(Not run)

nse_app Launch shiny app

Description
Launches shiny app for fetching data from NSE.

Usage
nse_app()

Examples
## Not run:
nse_app()

## End(Not run)

nse_fo Top F&O gainers and losers

Description
Top futures and options gainers and losers for the last trading session.

Usage
nse_fo_top_gainers(clean_names = TRUE)

nse_fo_top_losers(clean_names = TRUE)

Arguments
clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.
4 nse_fo

Value

A tibble with the following columns:

symbol NSE ticker.


series Equity (EQ).
last_corp_announcement_date
Last corporate announcement date.
last_corp_announcement
Last corporate announcement.
open_price Open price.
high_price High price.
low_price Low price.
last_traded_price
Last traded price.
prev_close_price
Previous close price.
percent_change Percentage change in price.
traded_quantity
Total traded quantity.
turnover Turnover in lakhs.

Examples

## Not run:
# top gainers
nse_fo_top_gainers()

# retain original column names as returned by NSE


nse_fo_top_gainers(clean_names = FALSE)

# top losers
nse_fo_top_losers()

# retain original column names as returned by NSE


nse_fo_top_losers(clean_names = FALSE)

## End(Not run)
nse_index_list 5

nse_index_list Index list

Description
List NSE indices.

Usage
nse_index_list(clean_names = TRUE)

Arguments
clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.

Value
A tibble with the following column:

index_name Name of the index.

Examples
## Not run:
nse_index_list()

# retain original column names as returned by NSE


nse_index_list(clean_names = FALSE)

## End(Not run)

nse_index_quote Index quote

Description
Fetch the quote for a given index.

Usage
nse_index_quote(clean_names = TRUE)

Arguments
clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.
6 nse_index_valid

Value
A tibble with the following columns:

index_name Name of the NSE indices.


last_traded_price
Last traded price.
change Change in price.
percent_change Percentage change in price.

Examples
## Not run:
nse_index_quote()

# retain original column names as returned by NSE


nse_index_quote(clean_names = FALSE)

## End(Not run)

nse_index_valid Validate index symbol.

Description
Check if index symbol is valid.

Usage
nse_index_valid(index_code)

Arguments
index_code Symbol of the index.

Examples
## Not run:
nse_index_valid("nifty auto")
nse_index_valid("nifty cps")

## End(Not run)
nse_stock_code 7

nse_stock_code Stock code

Description
Fetch stock symbol and name from NSE.

Usage
nse_stock_code(clean_names = TRUE)

Arguments
clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.

Value
A tibble with the following columns:

symbol NSE ticker.


company Name of the firm.

Examples
## Not run:
nse_stock_code()

# retain original column names as returned by NSE


nse_stock_code(clean_names = FALSE)

## End(Not run)

nse_stock_high_low 52 week high & low

Description
Fetch stocks that have touched their 52 week high and low.

Usage
nse_stock_year_high(clean_names = TRUE)

nse_stock_year_low(clean_names = TRUE)
8 nse_stock_high_low

Arguments

clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.

Value

A tibble with the following column names:

symbol NSE ticker.


symbol_desc Name of the firm.
date Previous high date.
new_high New 52 week high price.
new_low New 52 week low price.
year Year.
last_traded_price
Last traded price.
prev_high Previous high price.
prev_low Previous low price.
prev_close Previous close price.
change Change in price.
percent_change Percentage change in price.

Examples

## Not run:
# 52 week high
nse_stock_year_high()

# retain original column names as returned by NSE


nse_stock_year_high(clean_names = FALSE)

# 52 week low
nse_stock_year_low()

# retain original column names as returned by NSE


nse_stock_year_low(clean_names = FALSE)

## End(Not run)
nse_stock_most_traded 9

nse_stock_most_traded Most actively traded stocks

Description

Fetch most actively traded stocks in a month on NSE.

Usage

nse_stock_most_traded(clean_names = TRUE)

Arguments

clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.

Value

A tibble with the following columns:

security Name of the firm.


share_turnover Share in total turnover (percentage).
traded_quantity
Total traded quantity (in lakhs)
no_of_trades Number of trades.
avg_daily_turnover
Average daily turnover (in crores).
turnover Turnover (in crores.)

Examples

## Not run:
nse_stock_most_traded()

# retain original column names as returned by NSE


nse_stock_most_traded(clean_names = FALSE)

## End(Not run)
10 nse_stock_top_base

nse_stock_quote Stock quote

Description

Fetch the quote for a given stock code from Yahoo Finance API or Rediff Money.

Usage

nse_stock_quote(stock_code)

Arguments

stock_code Symbol of the stock.

Examples
## Not run:
nse_stock_quote("infy")

## End(Not run)

nse_stock_top_base NSE top gainers & losers

Description

Fetch top gainers and losers for the last trading session.

Usage

nse_stock_top_gainers(clean_names = TRUE)

nse_stock_top_losers(clean_names = TRUE)

Arguments

clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.
nse_stock_top_base 11

Value

A tibble with the following columns:

symbol NSE ticker.


series Equity (EQ).
last_corp_announcement_date
Last corporate announcement date.
last_corp_announcement
Last corporate announcement.
open_price Open price.
high_price High price.
low_price Low price.
last_traded_price
Last traded price.
prev_close_price
Previous close price.
percent_change Percentage change in price.
traded_quantity
Total traded quantity.
turnover Turnover in lakhs.

Examples

## Not run:
# top gainers
nse_stock_top_gainers()

# retain original column names as returned by NSE


nse_stock_top_gainers(clean_names = FALSE)

# top losers
nse_stock_top_losers()

# retain original column names as returned by NSE


nse_stock_top_losers(clean_names = FALSE)

## End(Not run)
12 preopen_nifty

nse_stock_valid Validate stock symbol

Description

Check if stock symbol/ticker is valid.

Usage

nse_stock_valid(stock_code)

Arguments

stock_code Symbol of the stock.

Examples
## Not run:
nse_stock_valid("infy")
nse_stock_valid("glo")

## End(Not run)

preopen_nifty Pre Open market data

Description

Fetch data of pre open session of Nifty & Nifty Bank.

Usage

nse_preopen_nifty(clean_names = TRUE)

nse_preopen_nifty_bank(clean_names = TRUE)

Arguments

clean_names Logical; if TRUE, makes the column names descriptive and uses snake_case.
preopen_nifty 13

Value
A tibble with the following columns:

symbol NSE ticker.


series Equity (EQ)
corp_action_date
Corporate action date.
corp_action Corporate Action
price Price
change Change in price
percent_change Percentage change in price.
prev_close Previous close.
quantity Quantity
value Value (in lakhs),
mkt_cap Free float market capitalization (in crores).
year_high Normal market 52 week high.
year_low Normal market 52 week low.

Examples
## Not run:
# nifty
nse_preopen_nifty()

# retain original column names as returned by NSE


nse_preopen_nifty(clean_names = FALSE)

# nifty bank
nse_preopen_nifty_bank()

# retain original column names as returned by NSE


nse_preopen_nifty_bank(clean_names = FALSE)

## End(Not run)
Index

nse2r, 2
nse_advances_declines, 2
nse_app, 3
nse_fo, 3
nse_fo_top_gainers (nse_fo), 3
nse_fo_top_losers (nse_fo), 3
nse_index_list, 5
nse_index_quote, 5
nse_index_valid, 6
nse_preopen_nifty (preopen_nifty), 12
nse_preopen_nifty_bank (preopen_nifty),
12
nse_stock_code, 7
nse_stock_high_low, 7
nse_stock_most_traded, 9
nse_stock_quote, 10
nse_stock_top_base, 10
nse_stock_top_gainers
(nse_stock_top_base), 10
nse_stock_top_losers
(nse_stock_top_base), 10
nse_stock_valid, 12
nse_stock_year_high
(nse_stock_high_low), 7
nse_stock_year_low
(nse_stock_high_low), 7

preopen_nifty, 12

14

You might also like