knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Fetch data from the National Stock Exchange, India.
NSE (National Stock Exchange) is the leading stock exchange of India, located in the city of Mumbai. While users can manually download data from NSE through a browser, importing this data into R becomes cumbersome. The nse2r R package implements the retrieval of data from NSE and aims to reduce the pre-processing steps needed in analyzing such data.
nse2r is inspired by and a port of the Python package nsetools. The authors and contributors for this R package are not affiliated with NSE and NSE does not offer support for this R package.
With nse2r, you can fetch the following data related to:
You can install the development version of nse2r from GitHub with:
# install.packages("devtools") devtools::install_github("rsquaredacademy/nse2r")
library(nse2r)
nse2r uses consistent prefix nse_
for easy tab completion.
nse_index_
for index nse_stock_
for stocksnse_fo_
for futures and optionsnse_preopen_
for preopen datanse2r does basic data preprocessing which are listed below:
character
to numeric
and Date
snake_case
from camelCase
Users can retain the names and format as returned by NSE using the clean_names
argument and setting it to FALSE
.
nse_index_quote() # retain original column names as returned by NSE nse_index_quote(clean_names = FALSE)
nse_stock_top_gainers() # retain original column names as returned by NSE nse_stock_top_gainers(clean_names = FALSE)
nse_stock_year_high() # retain original column names as returned by NSE nse_stock_year_high(clean_names = FALSE)
nse_stock_most_traded() # retain original column names as returned by NSE nse_stock_most_traded(clean_names = FALSE)
nse_fo_top_gainers() # retain original column names as returned by NSE nse_fo_top_gainers(clean_names = FALSE)
nse_preopen_nifty_bank() # retain original column names as returned by NSE nse_preopen_nifty(clean_names = FALSE)
nse_advances_declines() # retain original column names as returned by NSE nse_advances_declines(clean_names = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.