Rstudio shiny tutorial6/15/2023 We then use the tq_transmute() function to compute the weekly log returns of the stock and rename the resulting column to “log_return”. To get the stock data, we use the tq_get() function from the tidyquant package to retrieve the adjusted stock prices for the selected security from Januto the present. The server function takes the input values from the UI (i.e. the selected stock and number of simulations) and uses them to get and analyze the stock data. The second section of the code defines the server function for the shiny app. The main panel contains two sections: one for the tidy_autoplot() output (a plot of the stock returns), and one for the tidy_empirical() output (a table of the log returns). The sidebar panel contains a select input that allows users to choose which FAANG stock to analyze, as well as a numeric input for the number of simulations to run. The UI consists of a title panel, a sidebar panel, and a main panel.
0 Comments
Leave a Reply. |