├── .gitignore ├── FinancialDashboard.Rproj ├── FinancialDashboard ├── rsconnect │ └── shinyapps.io │ │ └── maxmlang │ │ └── FinancialDashboard.dcf ├── ui.R └── server.R └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /FinancialDashboard.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /FinancialDashboard/rsconnect/shinyapps.io/maxmlang/FinancialDashboard.dcf: -------------------------------------------------------------------------------- 1 | name: FinancialDashboard 2 | title: FinancialDashboard 3 | username: 4 | account: maxmlang 5 | server: shinyapps.io 6 | hostUrl: https://api.shinyapps.io/v1 7 | appId: 4703923 8 | bundleId: 5929735 9 | url: https://maxmlang.shinyapps.io/FinancialDashboard/ 10 | when: 1653127295.48544 11 | lastSyncTime: 1653127295.48545 12 | asMultiple: FALSE 13 | asStatic: FALSE 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FinancialDashboard: Shiny Application for Market Data 2 | 3 | Welcome to the repository for FinancialDashboard, a comprehensive Shiny application designed to display key financial indices, stocks, cryptocurrencies, and more. This application serves as a dynamic and interactive tool for anyone interested in financial markets and data analysis. 4 | 5 | ## About FinancialDashboard 6 | 7 | FinancialDashboard leverages data from Yahoo Finance to present real-time market information. It's a versatile tool for investors, traders, and finance enthusiasts to keep track of market trends and make informed decisions. 8 | 9 | ### Key Features: 10 | 11 | - **Diverse Market Data:** Covers a range of financial instruments including stocks, indices, and cryptocurrencies. 12 | - **Real-Time Updates:** Integrates data from Yahoo Finance to ensure current and relevant market insights. 13 | - **Interactive Interface:** Built using Shiny, the app offers an engaging and user-friendly experience. 14 | 15 | 16 | ## Contributions and Feedback 17 | 18 | Your contributions and feedback are invaluable in enhancing the capabilities of FinancialDashboard. Feel free to fork this repository, submit pull requests, or open issues for any suggestions or improvements you have in mind. 19 | 20 | ## License 21 | 22 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. 23 | 24 | --- 25 | 26 | **Disclaimer:** The FinancialDashboard is intended for informational purposes only. It should not be construed as financial advice. All investments involve risk, including the potential loss of principal. 27 | 28 | -------------------------------------------------------------------------------- /FinancialDashboard/ui.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(shinydashboard) 3 | library(shinyWidgets) 4 | library(tidyquant) 5 | library(tidyverse) 6 | library(plotly) 7 | 8 | 9 | watchlist <- c("QCOM","NVDA", "TSM", "SRPT", "MSFT", "AAPL", "AMZN") 10 | 11 | # Header ---- 12 | header <- dashboardHeader(title = "Financial Dashboard") 13 | # Sidebar ---- 14 | sidebar <- dashboardSidebar( 15 | sidebarMenu( 16 | menuItem("Home", tabName = "home", icon = icon("home")), 17 | menuItem("Stocks", tabName = "stocks", icon = icon("chart-line")), 18 | menuItem("Cryptocurrency", tabName = "crypto", icon = icon("bitcoin")) 19 | ) 20 | ) 21 | # Body ---- 22 | body <- dashboardBody( 23 | ## Home Tab ---- 24 | tabItems( 25 | tabItem(tabName= "home", 26 | fluidRow( 27 | ### Index Box ---- 28 | tabBox( 29 | title = "Indexes", 30 | id = "indexes", 31 | tabPanel("Dow Jones", plotlyOutput("dow")), 32 | tabPanel("S&P 500", plotlyOutput("sp500")), 33 | tabPanel("Dax", plotlyOutput("dax")), 34 | tabPanel("Hang Seng", plotlyOutput("hsi")) 35 | ), 36 | ### Watchlist Box ---- 37 | box( 38 | title = "Watchlist", 39 | id= "watchlist", 40 | dataTableOutput("watchlist") 41 | ) 42 | ), 43 | fluidRow( 44 | ### Crypto Box ---- 45 | tabBox( 46 | title = "Crypto", 47 | id= "crypto", 48 | tabPanel("Bitcoin", plotlyOutput("btc")), 49 | tabPanel("Ethereum", plotlyOutput("eth")), 50 | tabPanel("Bitcoin Cash", plotlyOutput("bch")), 51 | tabPanel("Litecoin", plotlyOutput("ltc")), 52 | tabPanel("Dogecoin", plotlyOutput("doge")) 53 | ), 54 | ### Minerals Box ---- 55 | tabBox( 56 | title = "Minerals", 57 | id= "minerals", 58 | tabPanel("Gold", plotlyOutput("gold")), 59 | tabPanel("Silver", plotlyOutput("silver")), 60 | tabPanel("Brent Oil", plotlyOutput("oil")) 61 | ) 62 | ) 63 | ), 64 | tabItem(tabName = "stocks", 65 | fluidRow(infoBoxOutput("dowbox"), 66 | infoBoxOutput("daxbox")), 67 | fluidRow(pickerInput("tickers",label= "Search", choices = watchlist, 68 | multiple = F, selected = watchlist[2])), 69 | fluidRow(radioButtons("period", label = h4("Period"), 70 | choices = list("1 month" = 1, "3 months" = 2, "6 months" = 3, "12 months" = 4, "YTD" = 5), 71 | selected = 4, inline=TRUE)), 72 | fluidRow(tabBox(title="Charts of selected stocks", 73 | id= "charts", 74 | tabPanel("Chart", plotlyOutput("chart")), 75 | tabPanel("Candlechart", plotOutput("candlechart"))), 76 | box(title = "Monthly returns", 77 | id= "returns", 78 | plotlyOutput("returns"))) 79 | ) 80 | , 81 | tabItem(tabName = "crypto", 82 | fluidRow(tabBox(title="Charts of selected coins", 83 | id= "coincharts", 84 | tabPanel("Chart", plotlyOutput("coinchart")), 85 | tabPanel("Candlechart", plotOutput("coincchart")))) 86 | ) 87 | ) 88 | 89 | ) 90 | 91 | 92 | 93 | 94 | ui <- dashboardPage(header, sidebar, body) 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /FinancialDashboard/server.R: -------------------------------------------------------------------------------- 1 | library(shiny) 2 | library(shinydashboard) 3 | library(shinyWidgets) 4 | library(quantmod) 5 | library(tidyquant) 6 | library(tidyverse) 7 | library(plotly) 8 | library(DataCombine) 9 | library(rvest) 10 | options(warn= -1) 11 | 12 | # Functions ---- 13 | get_yearly_data <- function(ticker){ 14 | data <- tq_get(ticker, get= "stock.prices", complete_cases = TRUE) 15 | data %>% filter(date >= today()-months(12)) 16 | } 17 | 18 | plot_index_graph <- function(data){ 19 | ggplotly({data %>% 20 | ggplot(aes(date, close)) + 21 | geom_line(size = 0.4, alpha = .9) + 22 | xlab("Time")+ 23 | ylab("Points")+ 24 | theme_minimal()} 25 | ) 26 | } 27 | 28 | plot_standard_graph <- function(data, colour){ 29 | ggplotly(data %>% 30 | ggplot(aes(date, close)) + 31 | geom_line(size = 0.4, alpha = .9, colour= colour) + 32 | xlab("Time")+ 33 | ylab("Value in US-Dollars")+ 34 | theme_minimal() 35 | ) 36 | } 37 | 38 | watchlist <- c("QCOM","NVDA", "TSM", "SRPT", "MSFT", "AAPL", "AMZN") 39 | dow <- get_yearly_data("^DJI") 40 | dax <- get_yearly_data("^GDAXI") 41 | sp500 <- get_yearly_data("^GSPC") 42 | hsi <- get_yearly_data("^HSI") 43 | 44 | dax_open <- dax %>% filter(date== max(dax$date)) %>% pull(open) 45 | dax_close <- dax %>% filter(date== max(dax$date)) %>% pull(close) 46 | dow_open <- dow %>% filter(date== max(dow$date)) %>% pull(open) 47 | dow_close <- dow %>% filter(date== max(dow$date)) %>% pull(close) 48 | 49 | dow <- get_yearly_data("^DJI") 50 | dax <- get_yearly_data("^GDAXI") 51 | sp500 <- get_yearly_data("^GSPC") 52 | hsi <- get_yearly_data("^HSI") 53 | 54 | dax_open <- dax %>% filter(date== max(dax$date)) %>% pull(open) 55 | dax_close <- dax %>% filter(date== max(dax$date)) %>% pull(close) 56 | dow_open <- dow %>% filter(date== max(dow$date)) %>% pull(open) 57 | dow_close <- dow %>% filter(date== max(dow$date)) %>% pull(close) 58 | # Watchlists ---- 59 | watchlist <- c("QCOM","NVDA", "TSM", "SRPT", "MSFT", "AAPL", "AMZN") 60 | watchlist_data <- tq_get(watchlist) %>% 61 | filter(date>= today()-days(1)) 62 | 63 | # Crypto Data Import ---- 64 | btc <- get_yearly_data("BTC-USD") 65 | eth <- get_yearly_data("ETH-USD") 66 | bch <- get_yearly_data("BCH-USD") 67 | ltc <- get_yearly_data("LTC-USD") 68 | doge <- get_yearly_data("DOGE-USD") 69 | 70 | # Minerals Data Import ---- 71 | gold <- get_yearly_data("GC=F") 72 | silver <- get_yearly_data("SI=F") 73 | oil <- get_yearly_data("BZ=F") 74 | 75 | server <- function(input, output) { 76 | showNotification("Booting up... Please wait.", type = "message", duration = 30) 77 | # Home Tab ---- 78 | # Index Data Import ---- 79 | dow <- get_yearly_data("^DJI") 80 | dax <- get_yearly_data("^GDAXI") 81 | sp500 <- get_yearly_data("^GSPC") 82 | hsi <- get_yearly_data("^HSI") 83 | 84 | dax_open <- dax %>% filter(date== max(dax$date)) %>% pull(open) 85 | dax_close <- dax %>% filter(date== max(dax$date)) %>% pull(close) 86 | dow_open <- dow %>% filter(date== max(dow$date)) %>% pull(open) 87 | dow_close <- dow %>% filter(date== max(dow$date)) %>% pull(close) 88 | 89 | # Watchlists ---- 90 | watchlist <- c("QCOM","NVDA", "TSM", "SRPT", "MSFT", "AAPL", "AMZN") 91 | watchlist_data <- tq_get(watchlist) %>% 92 | filter(date>= max(.$date)) 93 | 94 | # Crypto Data Import ---- 95 | btc <- get_yearly_data("BTC-USD") 96 | eth <- get_yearly_data("ETH-USD") 97 | bch <- get_yearly_data("BCH-USD") 98 | ltc <- get_yearly_data("LTC-USD") 99 | doge <- get_yearly_data("DOGE-USD") 100 | 101 | # Minerals Data Import ---- 102 | gold <- get_yearly_data("GC=F") 103 | silver <- get_yearly_data("SI=F") 104 | oil <- get_yearly_data("BZ=F") 105 | 106 | # Index plots ---- 107 | output$dow <- renderPlotly({ 108 | print(plot_index_graph(dow)) 109 | }) 110 | output$sp500 <- renderPlotly({ 111 | print(plot_index_graph(sp500)) 112 | }) 113 | 114 | output$dax <- renderPlotly({ 115 | print(plot_index_graph(dax)) 116 | }) 117 | 118 | output$hsi <- renderPlotly({ 119 | print(plot_index_graph(hsi)) 120 | }) 121 | # watchlist ---- 122 | output$watchlist <- renderDataTable(watchlist_data) 123 | 124 | 125 | 126 | # Crypto plots ---- 127 | output$btc <- renderPlotly({ 128 | print(plot_standard_graph(btc, "#ff9900")) 129 | }) 130 | 131 | output$eth <- renderPlotly({ 132 | print(plot_standard_graph(eth, "#522e92")) 133 | }) 134 | 135 | output$bch <- renderPlotly({ 136 | print(plot_standard_graph(bch, "#8dc351")) 137 | }) 138 | 139 | output$ltc <- renderPlotly({ 140 | print(plot_standard_graph(ltc, "#A9A9A9")) 141 | }) 142 | 143 | output$doge <- renderPlotly({ 144 | print(plot_standard_graph(doge, "#E1C699")) 145 | }) 146 | 147 | # Minerals plots ---- 148 | output$gold <- renderPlotly({ 149 | print(plot_standard_graph(gold, colour = "black")) 150 | }) 151 | 152 | output$silver <- renderPlotly({ 153 | print(plot_standard_graph(silver, colour = "black")) 154 | }) 155 | 156 | output$oil <- renderPlotly({ 157 | print(plot_standard_graph(oil, colour = "black")) 158 | }) 159 | 160 | # Stocks Tab ---- 161 | 162 | 163 | observeEvent(c(input$period, input$tickers), { 164 | stock_prices <- tq_get(watchlist, get= "stock.prices", complete_cases = TRUE) 165 | stock_prices <- stock_prices %>% 166 | filter(symbol %in% input$tickers) 167 | 168 | crypto_tickers <- c("BTC-USD", "ETH-USD", "ALGO-USD", "BCH-USD", "XLM-USD", 169 | "BNB-USD", "DOGE-USD") 170 | 171 | crypto_prices <- tq_get(crypto_tickers, 172 | get = "stock.prices", 173 | from = today()-months(6), 174 | to = today(), 175 | complete_cases = F) 176 | 177 | 178 | if (input$period == 1) { 179 | stock_prices <- stock_prices %>% 180 | filter( 181 | date >= today()-months(1)) 182 | } 183 | 184 | if (input$period == 2) { 185 | stock_prices <- stock_prices %>% 186 | filter( 187 | date >= today()-months(2)) 188 | } 189 | 190 | if (input$period == 3) { 191 | stock_prices <- stock_prices %>% 192 | filter( 193 | date >= today()-months(3)) 194 | } 195 | 196 | if (input$period == 4) { 197 | stock_prices <- stock_prices %>% 198 | filter( 199 | date >= today()-months(12)) 200 | } 201 | if (input$period == 5) { 202 | stock_prices <- stock_prices 203 | } 204 | 205 | 206 | # Create plot 207 | output$chart <- renderPlotly({ 208 | print(ggplotly(stock_prices %>% 209 | ggplot(aes(x = date, y = close)) + 210 | geom_line()+ 211 | labs(y = "Closing Price", x = "Time") + 212 | theme_tq())) 213 | 214 | }) 215 | 216 | output$candlechart <- renderPlot({ 217 | print(stock_prices %>% 218 | ggplot(aes(x = date, y = close, open = open, high = high, low = low)) + 219 | geom_candlestick(aes(open = open, high = high, low = low, close = close)) + 220 | labs(title = "Candlestick Chart", y = "Closing Price", x = "") + 221 | theme_tq()) 222 | }) 223 | 224 | output$returns <- renderPlotly({ 225 | print(ggplotly(stock_prices %>% 226 | group_by(symbol) %>% 227 | tq_transmute(select=adjusted, 228 | mutate_fun=periodReturn, 229 | period="monthly", 230 | col_rename = "monthly_return") %>% 231 | ggplot(aes(date, monthly_return, color=symbol)) + 232 | xlab("Time")+ 233 | geom_line()+ 234 | theme_minimal())) 235 | }) 236 | 237 | 238 | output$dowbox <- renderInfoBox({ 239 | infoBox("Dow Jones", round(dow_close - dow_open,2), 240 | icon = icon(ifelse(dow_close - dow_open>=0,"arrow-up", 241 | "arrow-down")), 242 | color = ifelse(dow_close - dow_open>=0,"green", "red")) 243 | }) 244 | output$daxbox <- renderInfoBox({ 245 | infoBox("DAX", round(dax_close - dax_open,2), icon= icon(ifelse(dax_close - dax_open>=0,"arrow-up", 246 | "arrow-down")), 247 | color = ifelse(dax_close - dax_open>=0,"green", "red")) 248 | }) 249 | 250 | 251 | output$coinchart <- renderPlotly({ 252 | print(ggplotly( crypto_prices %>% 253 | ggplot(aes(date, close,colour = symbol)) + 254 | geom_line(size = 0.4, alpha = .9) + 255 | labs(colour="Cryptocurrency")+ 256 | xlab("Time")+ 257 | ylab("Value in $") + 258 | theme_tq())) 259 | 260 | }) 261 | 262 | output$coincchart <- renderPlot({ 263 | print(crypto_prices %>% 264 | ggplot(aes(x = date, y = close)) + 265 | geom_candlestick(aes(open = open, high = high, low = low, close = close)) + 266 | labs(title = "Candlestick Chart", y = "Closing Price", x = "") + 267 | theme_tq()) 268 | }) 269 | 270 | 271 | } 272 | ) 273 | } 274 | 275 | 276 | 277 | 278 | --------------------------------------------------------------------------------