项目作者: nandp1

项目描述 :
R package to download bhavcopy from NSE
高级语言: HTML
项目地址: git://github.com/nandp1/nser.git
创建时间: 2021-07-07T18:06:20Z
项目社区:https://github.com/nandp1/nser

开源协议:GNU General Public License v2.0

下载


CRAN_Status_Badge
Lifecycle:
stable
Github Code Size
CRAN RStudio mirror downloads

nser: R package to download historical bhavcopy of Equities and F&O, get live market data, plot treemap of movement in securities

Latest Version 1.5.4 on Github

  • Due to change in NSE website interface the bhav and bhavtoday functions have been revised and old code is maintained in bhav1.
  • bhav downloads bhavcopy from 1 Jan 2020 onwards,
  • bhavtoday download todays bhavcopy from NSE.
  • bhav1 downloads NSE bhavcopy from from 1 Jan 2016 to 05 July 2024.
  • fobhav download derivatives (F&O) bhavcopy from 1 Jan 2020 onwards
  • fobhavtoday derivatives (F&O) todays bhavcopy from NSE.
  • fobhav1 downloads NSE bhavcopy from from 1 Jan 2016 to 05 July 2024.

New Functions

  • bhav1, optbanknifty and optnifty to get option chain of BANKNIFTY and NIFTY 50 repsectively.

NOTE

nselive, nseopen nseindex, nsetree, optbanknifty and optnifty obtain data from NSE using python scripts. Thus, you need to install Python modules pandas and requests in R,

Following steps should help you to get started,

  • Install latest version of Python, Ananconda and Miniconda. And add Python as PATH variable.
  • Then in R,
    1. install.packages('reticulate') # Install package reticulate
    2. library(reticulate) # Load package
    3. # You can also install miniconda in R by,
    4. # install_miniconda()
    5. py_install("requests") # Install python package requests
    6. py_install("pandas") # Install python package pandas
    7. # Helpful tip: Add interpreter in "Tools/Global options/Python/miniconda".
    You should be good to go now…

Introduction

nser helps you to download historical bhavcopy of Equities and F&O
segment easily.

Package website nser

Installation

You can install “nser” from
CRAN with:

  1. install.packages("nser")

Install it from github by:

  1. install.packages("devtools")
  2. library(devtools)
  3. install_github("nandp1/nser")

Example 1. Downloading Historical Equity Bhavcopy

  1. library(nser)
  2. # Download Bhavcopy of 1st July 2021
  3. report1 = bhav("01072021")

Example 2. Downloading Historical F&O Bhavcopy

  1. library(nser)
  2. # Download Bhavcopy of 1st July 2021
  3. report2 = fobhav("01072021")

Example 3. Downloading today’s Equity and F&O Bhavcopy

  1. library(nser)
  2. report3 = bhavtoday()
  3. report4 = fobhavtoday()

Example 4. Live F&O data.

  1. library(nser)
  2. nselive()

Example 5. Pre market open data of F&O stocks

  1. library(nser)
  2. nseopen("fo")

Example 6. Current and Upcoming IPO’s

library(nser)
nseipo()

Example 7. RSelenium to Download Equity Bhavcopy

  1. library(nser)
  2. library(RSelenium)
  3. # Start a selenium server and browser
  4. # For Google Chrome (Update Chrome to latest version)
  5. driver <- rsDriver(browser = c("chrome"), port = 3163L, chromever = "91.0.4472.101")
  6. remDr <- driver$client
  7. # or for Firefox
  8. driver <- rsDriver(browser = c("firefox"), port = 3799L)
  9. # Download Equity Bhavcopy zip file
  10. bhavs("03012000", 2)
  11. # Close the Browser
  12. remDr$close()

Example 8. RSelenium to Download F&O Bhavcopy

  1. library(nser)
  2. library(RSelenium)
  3. # Start a selenium server and browser
  4. # For Google Chrome (Update Chrome to latest version)
  5. driver <- rsDriver(browser = c("chrome"), port = 3163L, chromever = "91.0.4472.101")
  6. remDr <- driver$client
  7. # or for Firefox
  8. driver <- rsDriver(browser = c("firefox"), port = 3799L)
  9. # Download Equity Bhavcopy zip file
  10. bhavfos("03012000", 2)
  11. # Close the Browser
  12. remDr$close()

Example 9. NSE Treemap

  1. library(nser)
  2. # NIFTY 50 stocks
  3. nsetree()
  4. # F&O stocks
  5. nsetree("fo")

Example 10. Daily data to Weelkly data

  1. library(nser)
  2. data(dailydata)
  3. daytoweek(dailydata)

Example 11. Daily data to Monthly data

  1. library(nser)
  2. data(dailydata)
  3. daytomonth(dailydata)

Example 12. Option chain Nifty 50

  1. library(nser)
  2. optnifty()

Example 12. Option chain Banknifty

  1. library(nser)
  2. optbanknifty()

Example 13. Bhavcopy using bhav1 function

  1. library(nser)
  2. bhav1('05072024')