This report uses daily stock prices of listed companies in the Taiwan
stock market for the last two years. The data was downloaded as a CSV
file (20261005053449.csv) and analyzed with R.
prices <- read_tsv("20261005053449.csv",
locale = locale(encoding = "UTF-16"),
col_types = cols(.default = "c"))
dim(prices)
## [1] 527881 6
glimpse(prices)
## Rows: 527,881
## Columns: 6
## $ CO_ID <chr> "2390 Everspring", "1101 TCC", "2392 Foxlink", "1102 ACC"…
## $ Date <chr> "20241007", "20241007", "20241007", "20241007", "20241007…
## $ `Open(NTD)` <chr> "13.2000", "31.4261", "59.5187", "41.8325", "304.9880", "…
## $ `High(NTD)` <chr> "13.3000", "31.4726", "60.0767", "42.0090", "305.9426", "…
## $ `Low(NTD)` <chr> "13.1500", "30.9612", "59.0538", "41.4795", "298.7832", "…
## $ `Close(NTD)` <chr> "13.3000", "31.1472", "59.3328", "41.7884", "301.6470", "…
head(prices, 10)
## # A tibble: 10 × 6
## CO_ID Date `Open(NTD)` `High(NTD)` `Low(NTD)` `Close(NTD)`
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 2390 Everspring 20241007 13.2000 13.3000 13.1500 13.3000
## 2 1101 TCC 20241007 31.4261 31.4726 30.9612 31.1472
## 3 2392 Foxlink 20241007 59.5187 60.0767 59.0538 59.3328
## 4 1102 ACC 20241007 41.8325 42.0090 41.4795 41.7884
## 5 2395 Advantech 20241007 304.9880 305.9426 298.7832 301.6470
## 6 1109 HSINGTA 20241007 16.6025 16.8244 16.6025 16.6469
## 7 2399 Biostar 20241007 37.7500 38.7000 37.2000 38.7000
## 8 1210 GREATWALL 20241007 46.9865 47.7981 46.9865 47.2570
## 9 2401 Sunplus 20241007 31.6000 31.6000 31.0500 31.3500
## 10 1213 Oceanic Bev. 20241007 11.6769 11.7742 11.5796 11.7742
prices <- prices %>%
rename(co_id = 1, date = 2, open = 3, high = 4, low = 5, close = 6) %>%
separate(co_id, into = c("stock_id", "name"),
sep = " ", extra = "merge", fill = "right") %>%
mutate(
date = ymd(date),
across(c(open, high, low, close), as.numeric)
)
glimpse(prices)
## Rows: 527,881
## Columns: 7
## $ stock_id <chr> "2390", "1101", "2392", "1102", "2395", "1109", "2399", "1210…
## $ name <chr> "Everspring", "TCC", "Foxlink", "ACC", "Advantech", "HSINGTA"…
## $ date <date> 2024-10-07, 2024-10-07, 2024-10-07, 2024-10-07, 2024-10-07, …
## $ open <dbl> 13.2000, 31.4261, 59.5187, 41.8325, 304.9880, 16.6025, 37.750…
## $ high <dbl> 13.3000, 31.4726, 60.0767, 42.0090, 305.9426, 16.8244, 38.700…
## $ low <dbl> 13.1500, 30.9612, 59.0538, 41.4795, 298.7832, 16.6025, 37.200…
## $ close <dbl> 13.3000, 31.1472, 59.3328, 41.7884, 301.6470, 16.6469, 38.700…
range(prices$date, na.rm = TRUE)
## [1] "2024-10-07" "2026-10-05"
n_distinct(prices$stock_id)
## [1] 1095
n_distinct(prices$date)
## [1] 485
nrow(prices)
## [1] 527881
colSums(is.na(prices))
## stock_id name date open high low close
## 0 0 0 0 0 0 0
prices %>%
group_by(stock_id, name) %>%
summarise(days = n(), avg_close = mean(close, na.rm = TRUE), .groups = "drop") %>%
arrange(desc(avg_close)) %>%
head(10)
## # A tibble: 10 × 4
## stock_id name days avg_close
## <chr> <chr> <int> <dbl>
## 1 2059 King Slide 485 3950.
## 2 6515 WinWay 485 3528.
## 3 3661 Alchip 485 3272.
## 4 7769 HON 468 3023.
## 5 3008 Largan 485 2816.
## 6 3653 Jentech 485 2529.
## 7 3443 GUC 485 2400.
## 8 2383 EMC 485 2070.
## 9 2454 MediaTek 485 1987.
## 10 3533 Lotes 485 1633.
prices %>%
filter(stock_id == "2330") %>%
ggplot(aes(date, close)) +
geom_line() +
labs(title = "2330 Closing Price", x = NULL, y = "Close (NTD)")
The dataset contains 527,881 daily price records for 1,095 listed securities over 485 trading days, from 2024-10-07 to 2026-10-05, with no missing values. The data was imported, cleaned (company ID and name separated, dates and prices converted to proper types), and summarized in R Markdown.