Introduction

This report presents the daily stock price data of listed companies in the Taiwan stock market over the most recent two-year period.

The data were obtained from the Taiwan Economic Journal (TEJ) database using the TSE/OTC Adjusted Price (Daily) dataset.

The objective of this assignment is to download, organize, inspect, and summarize daily stock price data for listed companies in Taiwan using R and R Markdown.

Data Source

The dataset was obtained from the Taiwan Economic Journal (TEJ) database.

The selected securities include common stocks from the Taiwan Stock Exchange (TWSE) and GreTai/Taipei Exchange market.

The observation period covers approximately two years, from October 2024 to October 2026.

The variables used in this report are:

Import Data

The combined TEJ dataset is imported from a CSV file.

stock_data <- read_csv(
  "Taiwan_Stocks_2024_2026_FINAL.csv",
  show_col_types = FALSE
)

Data Preparation

The Date variable is converted into R’s date format.

stock_data <- stock_data %>%
  mutate(
    Date = as.Date(Date, format = "%Y/%m/%d"),
    COID = as.character(COID)
  )

The structure of the dataset is shown below.

glimpse(stock_data)
## Rows: 957,924
## Columns: 8
## $ COID            <chr> "1101", "1101", "1101", "1101", "1101", "1101", "1101"…
## $ COID_Name       <chr> "TCC", "TCC", "TCC", "TCC", "TCC", "TCC", "TCC", "TCC"…
## $ Date            <date> 2024-10-07, 2024-10-08, 2024-10-09, 2024-10-11, 2024-…
## $ `Open(NTD)`     <dbl> 31.4261, 30.9148, 30.5893, 30.4499, 30.2639, 30.3104, …
## $ `High(NTD)`     <dbl> 31.4726, 31.1007, 30.6358, 30.6823, 30.4034, 30.4034, …
## $ `Low(NTD)`      <dbl> 30.9612, 30.5893, 30.1709, 30.1245, 30.1709, 30.1709, …
## $ `Close(NTD)`    <dbl> 31.1472, 30.7288, 30.1709, 30.2174, 30.2639, 30.2174, …
## $ `Volume(1000S)` <dbl> 13191, 14236, 11396, 9445, 6059, 8102, 10435, 7485, 10…

Data Preview

The first 10 observations are displayed below.

head(stock_data, 10)
## # A tibble: 10 × 8
##    COID  COID_Name Date       `Open(NTD)` `High(NTD)` `Low(NTD)` `Close(NTD)`
##    <chr> <chr>     <date>           <dbl>       <dbl>      <dbl>        <dbl>
##  1 1101  TCC       2024-10-07        31.4        31.5       31.0         31.1
##  2 1101  TCC       2024-10-08        30.9        31.1       30.6         30.7
##  3 1101  TCC       2024-10-09        30.6        30.6       30.2         30.2
##  4 1101  TCC       2024-10-11        30.4        30.7       30.1         30.2
##  5 1101  TCC       2024-10-14        30.3        30.4       30.2         30.3
##  6 1101  TCC       2024-10-15        30.3        30.4       30.2         30.2
##  7 1101  TCC       2024-10-16        30.2        30.2       29.9         29.9
##  8 1101  TCC       2024-10-17        29.9        30.3       29.9         30.2
##  9 1101  TCC       2024-10-18        30.3        30.4       29.9         30.4
## 10 1101  TCC       2024-10-21        30.6        30.6       30.0         30.0
## # ℹ 1 more variable: `Volume(1000S)` <dbl>

Dataset Dimensions

The number of observations and variables in the dataset is:

dim(stock_data)
## [1] 957924      8

The dataset contains 957,924 daily company observations and 8 variables.

Number of Listed Companies

The number of unique companies included in the dataset is calculated below.

stock_data %>%
  summarise(
    Number_of_Companies = n_distinct(COID)
  )
## # A tibble: 1 × 1
##   Number_of_Companies
##                 <int>
## 1                1987

The dataset contains 1,987 unique company IDs.

Date Range

The earliest and latest trading dates in the dataset are:

stock_data %>%
  summarise(
    Start_Date = min(Date),
    End_Date = max(Date),
    Number_of_Trading_Days = n_distinct(Date)
  )
## # A tibble: 1 × 3
##   Start_Date End_Date   Number_of_Trading_Days
##   <date>     <date>                      <int>
## 1 2024-10-07 2026-10-05                    485

The available data run from October 7, 2024 to October 5, 2026, covering 485 trading days.

Although the requested period begins around October 5, 2024, stock market data are only available on trading days. Therefore, the first available observation is October 7, 2024.

Missing Value Check

The dataset is checked for missing observations.

colSums(is.na(stock_data))
##          COID     COID_Name          Date     Open(NTD)     High(NTD) 
##             0             0             0             0             0 
##      Low(NTD)    Close(NTD) Volume(1000S) 
##             0             0             0

The selected variables do not contain missing values.

Duplicate Check

Each company should have no more than one observation for the same trading date.

duplicate_check <- stock_data %>%
  count(COID, Date) %>%
  filter(n > 1)

nrow(duplicate_check)
## [1] 0

A result of 0 indicates that there are no duplicated company-date observations.

Descriptive Statistics

Summary statistics for the price and trading volume variables are presented below.

stock_data %>%
  summarise(
    Mean_Open = mean(`Open(NTD)`, na.rm = TRUE),
    Mean_High = mean(`High(NTD)`, na.rm = TRUE),
    Mean_Low = mean(`Low(NTD)`, na.rm = TRUE),
    Mean_Close = mean(`Close(NTD)`, na.rm = TRUE),
    Mean_Volume = mean(`Volume(1000S)`, na.rm = TRUE)
  )
## # A tibble: 1 × 5
##   Mean_Open Mean_High Mean_Low Mean_Close Mean_Volume
##       <dbl>     <dbl>    <dbl>      <dbl>       <dbl>
## 1      108.      111.     106.       108.       2893.

Number of Companies by Trading Day

The following calculation shows how many companies have observations on each trading day.

daily_company_count <- stock_data %>%
  group_by(Date) %>%
  summarise(
    Number_of_Companies = n_distinct(COID),
    .groups = "drop"
  )

head(daily_company_count)
## # A tibble: 6 × 2
##   Date       Number_of_Companies
##   <date>                   <int>
## 1 2024-10-07                1935
## 2 2024-10-08                1935
## 3 2024-10-09                1935
## 4 2024-10-11                1935
## 5 2024-10-14                1935
## 6 2024-10-15                1936

Visualization

The figure below shows the number of companies with available observations on each trading day.

ggplot(
  daily_company_count,
  aes(x = Date, y = Number_of_Companies)
) +
  geom_line() +
  labs(
    title = "Number of Taiwan Listed Companies with Daily Price Data",
    x = "Trading Date",
    y = "Number of Companies"
  ) +
  theme_minimal()

Sample Company

As an example, the following table displays the first observations for company code 2330.

stock_data %>%
  filter(COID == "2330") %>%
  select(
    COID,
    COID_Name,
    Date,
    `Open(NTD)`,
    `High(NTD)`,
    `Low(NTD)`,
    `Close(NTD)`,
    `Volume(1000S)`
  ) %>%
  head(10)
## # A tibble: 10 × 8
##    COID  COID_Name Date       `Open(NTD)` `High(NTD)` `Low(NTD)` `Close(NTD)`
##    <chr> <chr>     <date>           <dbl>       <dbl>      <dbl>        <dbl>
##  1 2330  TSMC      2024-10-07        965.        981.       961.         976.
##  2 2330  TSMC      2024-10-08        971.        981.       969.         981.
##  3 2330  TSMC      2024-10-09       1001.       1005.       991.         991.
##  4 2330  TSMC      2024-10-11        996.       1020.       991.        1015.
##  5 2330  TSMC      2024-10-14       1015.       1025.      1005.        1015.
##  6 2330  TSMC      2024-10-15       1020.       1044.      1020.        1039.
##  7 2330  TSMC      2024-10-16       1010.       1039.      1005.        1015.
##  8 2330  TSMC      2024-10-17       1020.       1025.      1001.        1005.
##  9 2330  TSMC      2024-10-18       1064.       1069.      1044.        1054.
## 10 2330  TSMC      2024-10-21       1059.       1064.      1049.        1054.
## # ℹ 1 more variable: `Volume(1000S)` <dbl>

Conclusion

This report successfully imported and organized daily stock price data for companies listed in the Taiwan stock market over the most recent two-year period.

The final dataset contains 957,924 observations, 1,987 unique company IDs, and 485 trading days from October 7, 2024 to October 5, 2026.

The dataset includes daily open, high, low, and close prices together with trading volume. Data validation also shows that there are no missing values in the selected variables and no duplicated company-date observations.

The data are therefore ready for additional financial or time-series analysis in R.