Trends of Sale / Commodity Price

Published

May 24, 2024


1 Data Preparation

  • In order to analyze trends of sale between several fiscal years, historical daily PL needs to be combined.

  • The combined data consists of P&L data from X Department between FY2021 and FY2024.

Caution

All data and names have been randomized to prevent identification of any specific company.

Code
historical_data <- read_xlsx("data/Historical_Data_20210330.xlsx")

historical_data$date <- as.Date(historical_data$date)

2 PL By Fiscal Year

  • P&L of X Department by fiscal year

3 Yearly Risk Return

3.1 Revenue Efficiency

  • Analyze the trends in revenue efficiency for each sales department based on the average daily PL and average 1-day VaR over the past 250 days.

  • The formula for calculating revenue efficiency is defined as follows.

\[RiskReturn = \frac{\bar{DailyPL}}{|\bar{1dayVaR}|}\]

\[1dayVaR = \frac{10dayVaR}{\sqrt{10}}\]

3.2 Revenue Efficiency - Z-Score -

  • The Z-score is a statistical measure that represents the dispersion of values based on the mean.

    • “μ” : Population mean / “σ” : Population standard deviation

\[z = \frac{x - \mu}{\sigma}\]

  • By standardizing the data, it becomes possible to compare different data sets.

  • Interpretation of the Z-score (assuming a normal distribution):

    • Probability within 1σ: Approximately 68%

    • Probability within 2σ: Approximately 95%

    • Probability within 3σ: Approximately 99.7%


4 Monthly PL of Each Division

Note

Displayed the monthly PL for each division using a stacked bar chart. 🙃

Code
# 月間NE
## data setting

h <- historical_data %>%
  mutate(
    month = as.Date(cut(date, breaks = "month"))
  ) %>%
  group_by(area, month) %>%
  summarise(
    mtd_ne = sum(daily_ne)
  )

## data visualization

hc_h <- highchart(type = "chart") %>%
  hc_yAxis_multiples(
    create_yaxis(
      naxis = 1,
      height = c(2, 1),
      turnopposite = TRUE,
      title = c(
        list(title = list(text = "Monthly PL (mil JPY)"))
      )
    )
  ) %>%
  hc_chart(
    backgroundColor = "#FFF1E0",
    zoomType = "x"
  ) %>%
  hc_add_series(
    data = h,
    type = "area",
    yAxis = 0,
    hcaes(
      x = month,
      y = round(mtd_ne, 2),
      group = area
    )
  ) %>%
  hc_xAxis(
    type = "datetime",
    labels = list(format = "{value:%Y-%m}"),
    dateTimeLabelFormats = list(month = "%Y-%m"),
    tickInterval = 1 * 30 * 24 * 3600 * 1000
  ) %>%
  hc_title(text = "X Department Monthly PL") %>%
  hc_legend(
    layout = "horizontal",
    align = "center",
    verticalAlign = "bottom"
  ) %>%
  hc_plotOptions(area = list(stacking = "normal")) %>%
  hc_exporting(enabled = TRUE)

hc_h

6 References

 

A work by Shuntaro Ono

shun2286@gmail.com