| Date | Open | High | Low | Close | Adj Close | Volume |
|---|---|---|---|---|---|---|
| 1999-01-22 | 0.4375 | 0.4883 | 0.388 | 0.4102 | 0.3764 | 271468800 |
| 1999-01-25 | 0.4427 | 0.4583 | 0.4102 | 0.4531 | 0.4158 | 51048000 |
| 1999-01-26 | 0.4583 | 0.4674 | 0.4115 | 0.418 | 0.3835 | 34320000 |
| 1999-01-27 | 0.4193 | 0.4297 | 0.3958 | 0.4167 | 0.3823 | 24436800 |
| 1999-01-28 | 0.4167 | 0.4193 | 0.4128 | 0.4154 | 0.3811 | 22752000 |
| Date | Open | High | Low | Close | Adj Close | Volume |
|---|---|---|---|---|---|---|
| 2024-03-15 | 869.3 | 895.5 | 862.6 | 878.4 | 878.4 | 64019300 |
| 2024-03-18 | 903.9 | 924 | 870.8 | 884.5 | 884.5 | 66897600 |
| 2024-03-19 | 867 | 905.4 | 850.1 | 894 | 894 | 67217100 |
| 2024-03-20 | 898 | 904.1 | 882.2 | 903.7 | 903.7 | 47448700 |
| 2024-03-21 | 922.9 | 926.5 | 904 | 913.9 | 913.9 | 36735127 |
Looking at the summary:
| Min. | 1st Qu. | Median | Mean | 3rd Qu. | Max. |
|---|---|---|---|---|---|
| 0.3411 | 2.755 | 4.535 | 49.66 | 40.66 | 926.7 |
## [1] "Variance: 12099.7842486755"
Range: 0.341146 to 926.690002
Visualization showing the closing price of NVIDIA stock from 1999 to 2023:
ggplot(data = NVIDIA99to24, mapping = aes(x = Date, y = Close))+
geom_line()+
labs(title = "NVIDIA Closing Stock Price 1999-2024")
NVIDIA20to24 <- NVIDIA99to24%>%
filter(Date > as.Date("2020-01-01"))
ggplot(data = NVIDIA20to24, aes(x = Date, y = Close))+
geom_line()+
labs(title = "NVIDIA Closing Stock Price 2020-2024")
Using this condensed data frame, we can see the finer detail of the closing prices during this time. Now, this gives the opportunity to ask questions such as why did the closing price decline going into 2022 and what happened at the start of 2024 that created a massive spike in value?
As we can see in the visualization, NVIDIA’s stock price restarted their steady incline in late 2022. What happened in late 2022?
On September 20, 2022, an article was posted on NVIDIA’s titled “GeForce RTX 40 Series Graphics Cards: Up To 4X Faster, Powered By 3rd Gen RTX Architecture & NVIDIA DLSS 3” by Andrew Burnes, showcasing the new updates and products NVIDIA’s planned on releasing later that year including the GeForce RTX 4090 graphics card that was set to come out on October 12th, 2022. This correctly correlates with the graph and reinforces the validity of the data set.
NVIDIA23to24 <- NVIDIA99to24%>%
filter(Date > as.Date("2024-01-01"))
ggplot(data = NVIDIA23to24, aes(x = Date))+
geom_line(aes(y = Open, colour = "High"))+
geom_line(aes(y = Low, colour = "Low"))+
labs(title = "High vs Low 2024",
x = "Date",
y = "Price")+
scale_colour_manual(values = c("High" = "#008080", "Low" = "#FF0000"))
By shrinking the data frame even more, we can see the difference in the “High” price of the stock vs the “Low” price of the stock, especially the difference in March. Using this visualization we can analyze the most optimal days where the difference between the low and the high of the day was large.
NVIDIA23to24%>%
filter(High > 900.0 & Date > as.Date('2024-03-01'))%>%
select(Date, High, Close)
## # A tibble: 9 × 3
## Date High Close
## <date> <dbl> <dbl>
## 1 2024-03-07 928. 927.
## 2 2024-03-08 974 875.
## 3 2024-03-12 920. 919.
## 4 2024-03-13 915. 909.
## 5 2024-03-14 906. 879.
## 6 2024-03-18 924. 885.
## 7 2024-03-19 905. 894.
## 8 2024-03-20 904. 904.
## 9 2024-03-21 926. 914.
And from the script above, we can single out that on ‘2024-03-08’, the high reached its peak at ‘974’ with a closing price of ‘875’.
NVIDIA15to24 <- NVIDIA99to24 %>%
filter(Date >= as.Date("2015-01-01") & Date <= as.Date("2023-12-31"))
ggplot(data = NVIDIA15to24, aes(x = Date)) +
geom_line(aes(y = Open, colour = "Open"), linewidth = 0.25) +
geom_line(aes(y = Close, colour = "Close"), linewidth = 0.25) +
labs(title = "NVIDIA Opening and Closing Stock Prices",
x = "Date",
y = "Price (USD)",
colour = "Price Type") +
theme_minimal() +
scale_colour_manual(values = c("Open" = "#008080", "Close" = "#964B00")) +
theme(legend.position="bottom")
# Calculate the absolute difference between Open and Close prices for each day
NVIDIA99to24$Price_Difference <- abs(NVIDIA99to24$Open - NVIDIA99to24$Close)
# Order the data by the price difference in descending order and get the top 5
top_diff_days <- NVIDIA99to24 %>%
arrange(desc(Price_Difference)) %>%
slice_head(n = 10)
# Display the top 5 dates with the highest price differences
pander(top_diff_days[, c("Date", "Open", "Close", "Price_Difference")])
| Date | Open | Close | Price_Difference |
|---|---|---|---|
| 2024-03-08 | 951.4 | 875.3 | 76.1 |
| 2024-03-12 | 880.5 | 919.1 | 38.64 |
| 2024-02-22 | 750.2 | 785.4 | 35.13 |
| 2023-08-14 | 404.9 | 437.5 | 32.67 |
| 2023-08-24 | 502.2 | 471.6 | 30.53 |
| 2021-12-16 | 311.5 | 283.9 | 27.65 |
| 2024-01-08 | 495.1 | 522.5 | 27.41 |
| 2022-02-24 | 210.1 | 237.5 | 27.33 |
| 2024-03-19 | 867 | 894 | 26.98 |
| 2021-11-04 | 272.3 | 298 | 25.72 |
# Create a bar chart to display the price differences
ggplot(top_diff_days, aes(x = reorder(Date, -Price_Difference), y = Price_Difference)) +
geom_bar(stat = "identity", fill = "#008080") + # Using a fixed shade of teal for all bars
labs(x = "Date", y = "Price Difference (USD)", title = "Top 10 Days with Highest Price Differences for NVIDIA Stock") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, hjust = 1), legend.position = "none") # Rotate the dates on x-axis for better readability
# Print the top differences for a table view
pander(top_diff_days[, c("Date", "Open", "Close", "Price_Difference")])
| Date | Open | Close | Price_Difference |
|---|---|---|---|
| 2024-03-08 | 951.4 | 875.3 | 76.1 |
| 2024-03-12 | 880.5 | 919.1 | 38.64 |
| 2024-02-22 | 750.2 | 785.4 | 35.13 |
| 2023-08-14 | 404.9 | 437.5 | 32.67 |
| 2023-08-24 | 502.2 | 471.6 | 30.53 |
| 2021-12-16 | 311.5 | 283.9 | 27.65 |
| 2024-01-08 | 495.1 | 522.5 | 27.41 |
| 2022-02-24 | 210.1 | 237.5 | 27.33 |
| 2024-03-19 | 867 | 894 | 26.98 |
| 2021-11-04 | 272.3 | 298 | 25.72 |
# Correctly calculate daily returns for closing prices
NVIDIA99to24 <- NVIDIA99to24 %>%
mutate(Daily_Returns = (Close / lag(Close, default = first(Close)) - 1) * 100)
# Create a line chart to display daily returns
ggplot(NVIDIA99to24, aes(x = Date, y = Daily_Returns)) +
geom_line(color = "#964B00", size = 1) + # Use 'size' for the width of the line, and set the color to brown
labs(x = "Date", y = "Daily Returns (%)", title = "Daily Returns of NVIDIA Stock") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) # Rotate the dates on x-axis for better readability
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
It tells us how the stock’s closing price has changed from one day to the next, represented as a percentage. This is a measure of the stock’s volatility; sharp spikes in the chart, both positive and negative, indicate days with large price movements, suggesting significant buying or selling pressure or reactions to news or market events.
Periods with closely packed vertical movements suggest higher volatility, which could be due to various factors such as earnings announcements, shifts in investor sentiment, or broader market trends. Conversely, flatter periods indicate times of relative stability in the stock’s price.
For investors or traders, such a chart can be critical. High volatility may present trading opportunities, with potential for significant gains (or losses), especially for short-term traders. Long-term investors might use this information to identify potentially stable entry or exit points to avoid market noise. It’s also noteworthy that such patterns, in the context of broader market trends and news, can inform strategies around risk management and portfolio diversification.