特斯拉公司

特斯拉(Tesla)是一家美國新能源汽車和清潔能源公司,成立於2003年,總部位於加州帕羅奧圖。該公司的使命是推動世界向可持續能源的轉型。特斯拉以其創新的電動汽車和先進的電池技術而聞名,包括Model S、Model 3、Model X和Model Y等車型。除了汽車業務外,特斯拉還從事太陽能和能源存儲產品的開發和製造,如Solar Roof和Powerwall。特斯拉以其對環境的承諾和技術創新而受到廣泛讚譽,被視為電動汽車和可再生能源的領先企業之一。
資料來源
YAHOO!FINANCE

df <- data.frame(Date=index(TSLA), coredata(TSLA))

# annotation
a <- list(text = "2024 Q1",
          x = '2024-04-22',
          y = 1.02,
          xref = 'x',
          yref = 'paper',
          xanchor = 'left',
          showarrow = FALSE
)

# use shapes to create a line
l <- list(type = 'line',
          x0 = '2024-04-22',
          x1 = '2024-04-22',
          y0 = 0,
          y1 = 1,
          xref = 'x',
          yref = 'paper',
          line = list(color = 'black',
                      width = 0.5)
)

# annotation for fire accident
fire <- list(text = "fire accident",
             x = '2013-10-01',
             y = 1.02,
             xref = 'x',
             yref = 'paper',
             xanchor = 'left',
             showarrow = FALSE
)

# use shapes to create a line for fire accident
lfire <- list(type = 'line',
              x0 = '2013-10-01',
              x1 = '2013-10-01',
              y0 = 0,
              y1 = 1,
              xref = 'x',
              yref = 'paper',
              line = list(color = 'black',
                          width = 0.5)
)
Q3_2019 <- list(text = "2019 Q3",
             x = '2019-10-27',
             y = 1.02,
             xref = 'x',
             yref = 'paper',
             xanchor = 'left',
             showarrow = FALSE
)

LQ3_2019  <- list(type = 'line',
              x0 = '2019-10-27',
              x1 = '2019-10-27',
              y0 = 0,
              y1 = 1,
              xref = 'x',
              yref = 'paper',
              line = list(color = 'black',
                          width = 0.5)
)
Q1_2021 <- list(text = "2021 Q1",
             x = '2021-01-27',
             y = 1.02,
             xref = 'x',
             yref = 'paper',
             xanchor = 'left',
             showarrow = FALSE
)

LQ1_2021  <- list(type = 'line',
              x0 = '2021-01-27',
              x1 = '2021-01-27',
              y0 = 0,
              y1 = 1,
              xref = 'x',
              yref = 'paper',
              line = list(color = 'black',
                          width = 0.5)
)
fig <- df %>% plot_ly(x = ~Date, type="candlestick",
                      open = ~TSLA.Open, close = ~TSLA.Close,
                      high = ~TSLA.High, low = ~TSLA.Low) 

fig <- fig %>% layout(title = "Tesla Stock",
                      annotations = list(a, fire,Q3_2019,Q1_2021 ),
                      shapes = list(l, lfire,LQ3_2019,LQ1_2021 ))

fig

歷史

2013年10月1日,特斯拉(Tesla)的股價受到車輛起火事件的影響,股價下跌超過6%。車主稱該車在高速公路上撞擊大型金屬物後起火,但車輛設計保護性能優良。特斯拉董事長穆斯克發表聲明強調電動車安全性。分析師懷疑特斯拉股價上升名不副實,影片曝光後股價重挫。然而,車主稱車輛表現出色,並表示仍然信任特斯拉,股市隨即回升。

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.