Q1 Import Tesla for the last one year.

## # A tibble: 251 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2018-10-24  301.  304.  286.  288. 20058300     288.
##  2 2018-10-25  317.  321   301.  315. 20840700     315.
##  3 2018-10-26  308.  340.  307.  331. 27425500     331.
##  4 2018-10-29  337.  347.  326.  335. 14486000     335.
##  5 2018-10-30  328.  338.  322.  330.  9126700     330.
##  6 2018-10-31  333.  342   329.  337.  7624300     337.
##  7 2018-11-01  338.  348.  335.  344.  8000100     344.
##  8 2018-11-02  344.  349.  341.  346.  7808000     346.
##  9 2018-11-05  340.  344.  330.  341.  7831000     341.
## 10 2018-11-06  339.  349.  336.  341.  6762900     341.
## # … with 241 more rows

Hint: Copy and revise the importing part of the code from above.

Q2 Calculate 15-day and 50-day simple moving averages.

## # A tibble: 251 x 9
##    date        open  high   low close   volume adjusted SMA.short SMA.long
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>     <dbl>    <dbl>
##  1 2018-10-24  301.  304.  286.  288. 20058300     288.        NA       NA
##  2 2018-10-25  317.  321   301.  315. 20840700     315.        NA       NA
##  3 2018-10-26  308.  340.  307.  331. 27425500     331.        NA       NA
##  4 2018-10-29  337.  347.  326.  335. 14486000     335.        NA       NA
##  5 2018-10-30  328.  338.  322.  330.  9126700     330.        NA       NA
##  6 2018-10-31  333.  342   329.  337.  7624300     337.        NA       NA
##  7 2018-11-01  338.  348.  335.  344.  8000100     344.        NA       NA
##  8 2018-11-02  344.  349.  341.  346.  7808000     346.        NA       NA
##  9 2018-11-05  340.  344.  330.  341.  7831000     341.        NA       NA
## 10 2018-11-06  339.  349.  336.  341.  6762900     341.        NA       NA
## # … with 241 more rows

Q3 Transform data to long form from wide form for graphing.

## # A tibble: 753 x 3
##    date       type  price
##    <date>     <chr> <dbl>
##  1 2018-10-24 close  288.
##  2 2018-10-25 close  315.
##  3 2018-10-26 close  331.
##  4 2018-10-29 close  335.
##  5 2018-10-30 close  330.
##  6 2018-10-31 close  337.
##  7 2018-11-01 close  344.
##  8 2018-11-02 close  346.
##  9 2018-11-05 close  341.
## 10 2018-11-06 close  341.
## # … with 743 more rows

Q4 Visualize data.

Q5 If you had invested $1 million on the day of the first bullish crossover and sold your shares on the following bearish crosover, how much would you have won or lost?

You would lose $20,529.95 if you bought the shares on 7/2/2019 and tried to sell them on /16/2019

Q6 The bullish crossover missed the actual bottom. How long (in days) was the time lag?

The time lag was 29 days.

Q7 What would you change in the moving average model to reduce the time lag? Create another chart below with the change, and count the reduced time lag (in days).

## # A tibble: 251 x 7
##    date        open  high   low close     volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>      <dbl>    <dbl>
##  1 2018-10-24 2738. 2743. 2652. 2656. 4709310000    2656.
##  2 2018-10-25 2675. 2723. 2668. 2706. 4634770000    2706.
##  3 2018-10-26 2668. 2692. 2628. 2659. 4803150000    2659.
##  4 2018-10-29 2683. 2707. 2604. 2641. 4673700000    2641.
##  5 2018-10-30 2641. 2685. 2635. 2683. 5106380000    2683.
##  6 2018-10-31 2706. 2737. 2706. 2712. 5112420000    2712.
##  7 2018-11-01 2718. 2742. 2709. 2740. 4708420000    2740.
##  8 2018-11-02 2745. 2757. 2700. 2723. 4237930000    2723.
##  9 2018-11-05 2726. 2744. 2718. 2738. 3623320000    2738.
## 10 2018-11-06 2738. 2757. 2737. 2755. 3510860000    2755.
## # … with 241 more rows
## # A tibble: 251 x 9
##    date        open  high   low close    volume adjusted SMA.short SMA.long
##    <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>     <dbl>    <dbl>
##  1 2018-10-24 2738. 2743. 2652. 2656.    4.71e9    2656.       NA        NA
##  2 2018-10-25 2675. 2723. 2668. 2706.    4.63e9    2706.       NA        NA
##  3 2018-10-26 2668. 2692. 2628. 2659.    4.80e9    2659.       NA        NA
##  4 2018-10-29 2683. 2707. 2604. 2641.    4.67e9    2641.       NA        NA
##  5 2018-10-30 2641. 2685. 2635. 2683.    5.11e9    2683.       NA        NA
##  6 2018-10-31 2706. 2737. 2706. 2712.    5.11e9    2712.       NA        NA
##  7 2018-11-01 2718. 2742. 2709. 2740.    4.71e9    2740.       NA        NA
##  8 2018-11-02 2745. 2757. 2700. 2723.    4.24e9    2723.       NA        NA
##  9 2018-11-05 2726. 2744. 2718. 2738.    3.62e9    2738.       NA        NA
## 10 2018-11-06 2738. 2757. 2737. 2755.    3.51e9    2755.     2701.       NA
## # … with 241 more rows
## # A tibble: 753 x 3
##    date       type  price
##    <date>     <chr> <dbl>
##  1 2018-10-24 close 2656.
##  2 2018-10-25 close 2706.
##  3 2018-10-26 close 2659.
##  4 2018-10-29 close 2641.
##  5 2018-10-30 close 2683.
##  6 2018-10-31 close 2712.
##  7 2018-11-01 close 2740.
##  8 2018-11-02 close 2723.
##  9 2018-11-05 close 2738.
## 10 2018-11-06 close 2755.
## # … with 743 more rows

Q8 Hide the messages and the code, but display results of the code from the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.