Skip to content
0

Should your fund invest in Bitcoin?

📖 Background

You work as an analyst at an investment fund in New York. Your CFO wants to explore if it is a good idea to invest some of the fund's assets in Bitcoin. You have to prepare a report on this asset and how it compares to the stock market in general.

💾 The data


#library(gridExtra) gridExtra::grid.arrange()

install.packages('tidyquant')
install.packages('ggdark')

library(tidyverse)
library(tidyquant)

Bitcoin daily data in US dollars

  • "date" - date from September 17, 2014 to November 17, 2021
  • "open" - the price at the beginning of the trading day
  • "high" - the highest price reached that day
  • "low" - the lowest price reached that day
  • "close" - the price at the closing of the trading day
  • "volume" - how many Bitcoin were traded that day

bitcoin <- read_csv("./data/bitcoin-usd.csv", show_col_types = FALSE) %>% 
    drop_na() %>% glimpse() 

S&P 500 daily data

  • "date" - date from September 17, 2014 to November 17, 2021
  • "open" - the index level at the beginning of the trading day
  • "high" - the highest level reached that day
  • "low" - the lowest level reached that day
  • "close" - the level at the closing of the trading day
  • "volume" - how many shares in the companies that make up the index were traded that day

sp500 <- read_csv("./data/sp500.csv", show_col_types = FALSE) %>% 
    glimpse()

Inflation and gold as monthly data

  • "date" - date from September, 2014 to November, 2021
  • "gold_usd" - price in usd of gold for that month
  • "cpi_us" - the inflation index for the US for that month (cpi = consumer price index)

CPI data from the U.S. Bureau of Labor Statistics (https://www.bls.gov/cpi/). Publicly available information.


monthly_data <- read_csv("./data/monthly_data.csv", show_col_types = FALSE) %>% 
    glimpse()

Overall growth per week & total percent increase since September 2014


# growth days = close - open / days
#((60276 - 457) / 2615) * 7
#paste0(scales::comma((60276 - 457) / 457 * 100, 1), "%")

bitcoin %>%
    filter(date > "2021-06-01") %>%
    ggplot(aes(date, close, volume = volume, 
               color_up = "#7FFF00", color_down = "red", 
               fill_up = "#7FFF00", fill_down = "red")) + 
    geom_candlestick(aes(open = open, high = high, low = low, close = close)) +
    geom_smooth(method = 'lm', formula = 'y~x', se = FALSE) +
    scale_y_continuous(breaks = seq(0, 100000, 5000), labels = scales::dollar) +
    scale_x_date(date_labels = '%b %y', date_breaks = '1 week') +
    ggdark::dark_theme_classic() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
    labs(title = paste0("Bitcoin Jun 2021-Present"), y = '', x = '',
         caption = paste0("*overall growth rate since ", 
                          format(as.Date(dplyr::first(bitcoin$date)), "%b %d,%Y") )) +
    annotate("text", x = as.Date('2021-07-01'), y = 60000 , 
             label = paste0("Overall growth: $", 
            round(((dplyr::last(bitcoin$close) - dplyr::first(bitcoin$close)) / nrow(bitcoin)) * 7, 2),
                            "/week")) +
    annotate("text", x = as.Date('2021-07-01'), y = 55000,
             label = paste0("Percent increase: ",
             round((dplyr::last(bitcoin$close) - dplyr::first(bitcoin$close)) / dplyr::first(bitcoin$close) 
             * 100, 2), "%"))

monthly_data %>%
    ggplot(aes(date, gold_usd)) +
    geom_point(color = 'chartreuse') +
    geom_line(color = 'chartreuse') +
    geom_smooth(method = 'lm', formula = 'y~x', se = FALSE) +
    scale_y_continuous(breaks = seq(0, 3000, 100), labels = scales::dollar) +
    scale_x_date(date_labels = '%b %y', date_breaks = '4 months') +
    ggdark::dark_theme_classic() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
    labs(title = "Gold 2014-Present", y = '', x = '') +
    annotate("text", x = min(monthly_data$date), y = max(monthly_data$gold_usd),
             hjust = -0.42, vjust = 5.42,
             label = paste0("Overall growth: $", 
    round(((last(monthly_data$gold_usd) - first(monthly_data$gold_usd)) / nrow(monthly_data)) / 4.333, 2), 
        "/week")) +
    annotate("text", x = min(monthly_data$date), y = max(monthly_data$gold_usd), 
             hjust = -0.42, vjust = 10.42, 
             label = paste0("Percent increase: ",
             round((last(monthly_data$gold_usd) - first(monthly_data$gold_usd)) / first(monthly_data$gold_usd)
                   * 100, 2), "%"))

sp500 %>%
    filter(date > '2021-06-01') %>%
    ggplot(aes(factor(date), close, volume = volume, 
               color_up = "#7FFF00", color_down = "red", 
               fill_up = "#7FFF00", fill_down = "red")) + 
    geom_candlestick(aes(open = open, high = high, low = low, close = close)) +
    scale_y_continuous(breaks = seq(0, 5000, 100), labels = scales::comma) +
    ggdark::dark_theme_classic() +
    theme(axis.text.x = element_blank()) +
    labs(title = "S&P 500 Jun 2021-Present", y = '', x = '',
         caption = paste0("*overall growth rate since ", 
                          format(as.Date(dplyr::first(sp500$date)), "%b %d,%Y") )) +
    annotate("text", x = '2021-07-01', y = 4650,
             label = paste0("Overall growth: ", 
                            round((last(sp500$close) - first(sp500$close)) / nrow(sp500) * 5, 2), 
                            " points/week")) +
    annotate("text", x = '2021-07-01', y = 4600,
             label = paste0("Percent increase: ",
                            round((last(sp500$close) - first(sp500$close)) / first(sp500$close) * 100, 2)
                            , "%"))

Everything goes up, makes sense to put your life savings into Bitcoin ASAP.

Go big or go home.

Bitcoin runs the world.

💪 Competition challenge

Create a report that covers the following:

  1. How does the performance of Bitcoin compare to the S&P 500 and the price of gold?
  2. Analyze Bitcoin's returns and volatility profile. Do you believe it could help improve the performance of a portfolio? Do you believe Bitcoin could be used as a hedge versus inflation?
  3. The CFO is looking to lower volatility in the fund. Explore building a portfolio using some or all of these assets. Make a recommendation that minimizes overall risk.

🧑‍⚖️ Judging criteria

Recommendations (35%)

  • Clarity of recommendations - how clear and well presented the recommendation is.
  • Quality of recommendations - are appropriate analytic techniques used & are the conclusions valid?
  • Number of relevant insights found for the target audience.

Story telling (30%)

  • How well the data and insights are connected to the recommendation.
  • How the narrative and whole report connects together.
  • Balancing making the report in depth enough but also concise.

Visualizations (25%)

  • Appropriateness of visualization used.
  • Clarity of insight from visualization.

Upvotes (10%)

  • Upvoting - most upvoted entries get the most points.

✅ Checklist before publishing into the competition

  • Rename your workspace to make it descriptive of your work. N.B. you should leave the notebook name as notebook.Rmd.
  • Remove redundant cells like the judging criteria so the workbook is focused on your story.
  • Make sure the workbook reads well and explains how you found your insights.
  • Check that all the cells run without error.

⌛️ Time is ticking. Good luck!