This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.Rmd
156 lines (110 loc) · 4.38 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# nse2r
> Fetch data from the National Stock Exchange, India.
<!-- badges: start -->
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/nse2r)](https://cran.r-project.org/package=nse2r)
[![cran checks](https://cranchecks.info/badges/summary/nse2r)](https://cran.r-project.org/web/checks/check_results_nse2r.html)
[![R build status](https://github.com/rsquaredacademy/nse2r/workflows/R-CMD-check/badge.svg)](https://github.com/rsquaredacademy/nse2r/actions)
[![Coverage
Status](https://img.shields.io/codecov/c/github/rsquaredacademy/nse2r/master.svg)](https://codecov.io/github/rsquaredacademy/nse2r?branch=master) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
<!-- badges: end -->
## Overview
[NSE](https://www.nseindia.com/) (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](https://nsetools.readthedocs.io/en/latest/). 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:
- stocks
- quote for a given stock
- stock description
- validate stock symbol/ticker
- most actively traded stocks in a month
- 52 week high/low
- top gainers/losers for the last trading session
- index
- list of NSE indices
- validate index symbol/ticker
- quote for a given index
- futures & options
- top gainers/losers for the last trading session
- pre open market data
- nifty
- nifty bank
- indices advances & declines
## Installation
You can install the development version of nse2r from [GitHub](https://github.com/rsquaredacademy/nse2r/) with:
```{r cran-install, eval=FALSE}
# install.packages("devtools")
devtools::install_github("rsquaredacademy/nse2r")
```
## Usage
```{r load_nse2r, echo=FALSE, message=FALSE, warning=FALSE}
library(nse2r)
```
nse2r uses consistent prefix `nse_` for easy tab completion.
- `nse_index_` for index
- `nse_stock_` for stocks
- `nse_fo_` for futures and options
- `nse_preopen_` for preopen data
## Preprocessing
nse2r does basic data preprocessing which are listed below:
- modify column data types from `character` to `numeric` and `Date`
- modify column names
- make them more descriptive
- to `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`.
### Index
##### Fetch Indices Quote
```{r index_quote}
nse_index_quote()
# retain original column names as returned by NSE
nse_index_quote(clean_names = FALSE)
```
### Stock
##### Top gainers for the last trading session.
```{r stock_top_gainers}
nse_stock_top_gainers()
# retain original column names as returned by NSE
nse_stock_top_gainers(clean_names = FALSE)
```
##### Stocks that have touched their 52 week highs during the day
```{r stock_year_high}
nse_stock_year_high()
# retain original column names as returned by NSE
nse_stock_year_high(clean_names = FALSE)
```
##### Most actively traded stocks in a month
```{r stock_most_traded}
nse_stock_most_traded()
# retain original column names as returned by NSE
nse_stock_most_traded(clean_names = FALSE)
```
### Futures & Options
##### Top futures and options gainers for the last trading session.
```{r fo_top_gainers}
nse_fo_top_gainers()
# retain original column names as returned by NSE
nse_fo_top_gainers(clean_names = FALSE)
```
### Pre Open Market Data
##### Fetch data of pre open session of Nifty Bank.
```{r popen_nb}
nse_preopen_nifty_bank()
# retain original column names as returned by NSE
nse_preopen_nifty(clean_names = FALSE)
```
### Advances & Declines
```{r advances_declines}
nse_advances_declines()
# retain original column names as returned by NSE
nse_advances_declines(clean_names = FALSE)
```