Ayesha Ansari
2026-06-23
Developing Data Products — Week 4 Assignment
Why this matters:
What our Shiny app provides:
data("EuStockMarkets")
cat("Size:", nrow(EuStockMarkets), "trading days x",
ncol(EuStockMarkets), "indices\n")
Size: 1860 trading days x 4 indices
cat("Indices:", colnames(EuStockMarkets), "\n")
Indices: DAX SMI CAC FTSE
prices <- as.numeric(EuStockMarkets[, "DAX"])
n <- length(prices)
cum_ret <- (prices[n] / prices[1]) - 1
years <- n / 260
ann_ret <- (1 + cum_ret)^(1 / years) - 1
daily_r <- diff(prices) / prices[-length(prices)]
vol <- sd(daily_r) * sqrt(260)
cat(sprintf("Cumulative Return : %+.1f%%", cum_ret * 100), "\n")
Cumulative Return : +236.1%
cat(sprintf("Annualised Return : %+.1f%%", ann_ret * 100), "\n")
Annualised Return : +18.5%
cat(sprintf("Volatility : %.1f%%", vol * 100), "\n")
Volatility : 16.6%
Widgets used: radioButtons, sliderInput x2, checkboxInput, selectInput, actionButton
Live Application: https://ayeshaansari.shinyapps.io/STOCK_RETURN_CALCULATOR/
What you can do with the app:
Thank you!