ExportGenius Trade Analysis: Belarus

Author

Gagan Atreya

Published

October 13, 2024

Tobacco exports

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------
rm(list = ls())

pacman::p_load(readxl, vtable, tidyverse, 
               lubridate, data.table, zoo, 
               readODS, patchwork, scales)

df <- fread("~/Desktop/soc_ace_2024/data/exportgenius/tobacco/belarus/Belarus-MirrorExport-Tobacco.csv")

df$date <- dmy(df$Date)
df$description <- df$`Product Description`

df$destination_country <- df$`Destination Country`

df$supplier <- df$Exporter
df$importer <- df$Buyer

df$total_value <- df$`Total Value USD`
df$weight <- df$`Gross Weight Kg`

df$price_invoice <- df$total_value/df$weight

df <- df[, c("date", "description", "destination_country",
             "supplier", "importer", "price_invoice", "total_value")]

df02 <- fread("~/Desktop/soc_ace_2024/scripts/exportgenius/gold_analyses_latest/goldprice.csv")
df02$date <- ymd(df02$date)
df <- merge(df, df02, by = "date")
df$price_benchmark <- df$price_gram

## Remove outlier transaction:

# summary(df$total_value)

df <- df[df$total_value < 650000, ]

plot01 <- ggplot(df,
                 aes(x = date, 
                     y = total_value)) +
  geom_line() +
  geom_point() +  
  # ylim(15, 120) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  labs(title = "Belarus Tobacco Exports", 
       x = "Date", 
       y = "Total Value") +  
  theme_bw() 

plot01

Display code
plot02 <- df %>% 
  ggplot( aes(x = date, 
              y = total_value, 
              color = destination_country))+
  geom_line()+ 
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  
  geom_point()+
  labs(title = "Belarus Tobacco Exports", 
       x = "Date", 
       y = "Total value")+
  theme_bw()

plot02

Display code
plot03 <- df %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~destination_country, ncol = 3)+
  labs(title = "Belarus Tobacco Exports by Destination", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot03

Display code
df <- as.data.table(df)
df <- df[!is.na(price_invoice)]
df <- df[order(-price_invoice)]

df$price_difference <- df$price_invoice - df$price_benchmark

df03 <- df[, c("date", "price_invoice", "price_benchmark")]

df$price_difference2 <- scale(df$price_difference)
df$price_benchmark2 <- scale(df$price_benchmark)

df <- df[price_difference2 != max(price_difference2)]

plot04 <- ggplot(df, aes(x = date, 
                         y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2
                   #,color = price_difference2 > 0
  )) +
  geom_point(color = "black", size = 2) +
  #  ylim(-2,2)+
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Imports: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot04

Display code
table(df$destination_country)

   Belarus Kazakhstan     Russia    Ukraine 
       418         11          9          1 
Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

df11 <- df[df$destination_country %in% c("Belarus", "Kazakhstan", 
                                         "Russia", "Ukraine") ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~destination_country, ncol = 2)+
  labs(title = "Belarus Tobacco Exports", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  facet_wrap(~destination_country, ncol = 2)+
  guides(color = FALSE) 

plot12

Belarus

Display code
df11 <- df[df$destination_country == "Belarus", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~destination_country, ncol = 2)+
  labs(title = "Belarus Tobacco Exports: Belarus", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports to Belarus: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Kazakhstan

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

df11 <- df[df$destination_country == "Kazakhstan", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~destination_country, ncol = 2)+
  labs(title = "Belarus Tobacco Exports: KAZ", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports to KAZ: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Russia

Display code
df11 <- df[df$destination_country == "Russia", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~destination_country, ncol = 2)+
  labs(title = "Belarus Tobacco Exports", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports to Russia: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Ukraine

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

df11 <- df[df$destination_country == "Ukraine", ]

plot11 <- df11 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+   
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~destination_country, ncol = 2)+
  labs(title = "Belarus Tobacco Exports: Ukraine", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot11

Display code
## ----error = F, message = F, warning = F--------------------------------------------------------

plot12 <- ggplot(df11, aes(x = date, 
                           y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports to Ukraine: Price Differentials Over Time",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) 

plot12

Belarus Tobacco Exports: Exporting Companies (Suppliers)

Display code
df$exporter <- df$supplier

df <- df[df$price_difference2 < 3, ]

df$exporter1 <- ifelse(str_detect(df$exporter, "INVEST") == T, 
                       "LLC TABAK-INVEST", 
                ifelse(str_detect(df$exporter, "AURIUM") == T, 
                       "AURIUM CORPORATION", 
                ifelse(str_detect(df$exporter, "ARIUM") == T, 
                       "AURIUM CORPORATION", df$exporter)))


frequency_table <- df %>%
  count(exporter1, name = "Frequency") %>%
  arrange(desc(Frequency))

# Convert table to HTML and save it as a file
kable(frequency_table, 
      format = "html", 
      caption = "Belarus Tobacco Exports: Exporting Companies",
      table.attr = "class='table table-striped'") %>%
  kable_styling(full_width = FALSE)
Belarus Tobacco Exports: Exporting Companies
exporter1 Frequency
LLC TABAK-INVEST 220
LLC TOBAKKO'S INTER 154
UAB AROLANA 14
""LOMAC TRADING LP"" 7
AURIUM CORPORATION 6
petrotr de fze 6
UAB ""KIRASDINA"" 5
QUICK PICK LLC 4
capri trade limited hongkong by dov ismaev ibragim sularovich 4
petrotrade fze 3
CAPRI TRADE LIMITED 2
pagran pte ltd 2
FILIN LIMITED 1
LEXIUS LIMITED 1
LLC INTER TOBAKKO 1
OH TO VLATYA LOGISTIC OF LTD COMPANY OF LI-FREND BY ORDER 1
SCP INTERNATIONAL LTD 1
TESTSVYAZ IT LIMITED 1
foreign trade unitary enterprise british american tobacco trading company 1
Display code
## Extract first twenty companies:
l1 <- frequency_table[1:12, "exporter1"] %>% as.vector()
df500 <- df[df$exporter1 %in% l1$exporter, ]

plot03a <- df500 %>% 
  ggplot( aes(x = date, 
              y = total_value)) +
  geom_line()+ 
  geom_point()+  
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  facet_wrap(~exporter1, ncol = 4)+
  labs(title = "Belarus Tobacco Exports by Exporting Company (top 12)", 
       x = "Date", 
       y = "Total Value") +
  theme_bw()

plot03a

Display code
plot06 <- ggplot(df500, aes(x = date, 
                            y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports by Exporting Company: Price Differentials Over Time",
       subtitle = "(Top 12 companies)",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) +
  facet_wrap(~exporter1, 
             ncol = 4)

plot06

Display code
df500$filter <- ifelse(df500$exporter1 %in% c("LLC TABAK-INVEST", 
                                          "LLC TOBAKKO'S INTER"), 1, 0)

df600 <- df500[df500$filter == 1 , ]

plot07 <- ggplot(df600, aes(x = date, 
                            y = price_difference2)) +
  geom_segment(aes(x = date, 
                   xend = date, 
                   y = 0, 
                   yend = price_difference2, 
                   color = price_difference2 > 0)) +
  geom_point(color = "black", size = 2) +
  geom_vline(xintercept = as.Date("2022-02-24"), 
             linetype = "dashed", 
             color = "black", 
             size = 0.45) +
  theme_bw() +
  scale_color_manual(values = c("red", "blue")) +
  labs(title = "Belarus Tobacco Exports by Exporting Company: Price Differentials Over Time",
       subtitle = "(Top 2 companies)",
       x = "Date",
       y = "Price differential (standardized)") +
  guides(color = FALSE) +
  facet_wrap(~exporter1, 
             ncol = 1)

plot07