scrape_onefirm: Web Scraping of Stock Price Data for One Brand

Description Usage Arguments Value Examples

View source: R/scrape_onefirm.r

Description

Calculate the number of pages required to get all stock price data for one brand, and execute scrape_onepage for each page using the loop syntax. At this time, in order to avoid the load on the server, after finishing scraping for one page, wait one second and execute scraping for the next page. Use the bind_rows of the dplyr package o connect the stock price data on each page in the row direction.

Usage

1
scrape_onefirm(code, name = NULL, start_date, end_date, datatype)

Arguments

code

numeric. Specify a brand code

name

character. Specify company name. If specified, ignore code argument and find out brand code by code_detect.

start_date

numeric. Specify the start date of the stock price data you want to acquire in the format of yyyymmdd.

end_date

numeric. Specify the end date of the stock price data you want to acquire in the format of yyyymmdd.

datatype

character. Specify the type of stock price data. If datatype = "d", get daily data. If datatype = "w", get weekly data. If 'datatype = "m", get monthly data.

Value

A tibble data containing stock price data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Acquire 2014 daily stock price data of Sony Group (brand code 6758)
scrape_onefirm(
  6758,
  start_date = 20140101,
  end_date = 20141231,
  datatype = "d"
)

# Acquire 2014 monthly stock price data of APAMAN
scrape_onefirm(
  name = "APAMAN",
  start_date = 20140101,
  end_date = 20141231,
  datatype = "m"
)

KatoPachi/YahooFinance documentation built on Feb. 9, 2022, 3:22 p.m.