After some time of using R and loving it, I was wondering if there was any open source project combining some of my favourite packages to easily get financial data and have it displayed interactively in Shiny.
Since I found nothing on Github, I decided to start it myself - This is how the R Stocks project started.
- Libraries that are used to fetch the main data:
And of course I am also using Plotly and Shiny for the visualization and interactive dashboard building.
The App: R Stocks
Interactive Stocks Analysis with R
In the first tab, you will have available general information of the selected tickers:
The first panel is just using the yfR library to get the data displayed:
The panels below, are using QuanDL, so remember to have your API_key available:
Interactive Dividend Analysis with R
In the second tab of the dashboards, you can find information related to the historical dividends per selected ticker.
This panels have been possible thanks to QuantMod, where we can get access to historical dividen data and then create the following:
Also, thanks to QuanDL, we can have access to some interesting ratios concerning dividends:
Interactive Indexes Analysis with R
Once again, thanks to yfR we can query general market indexes, like SP500, DJ, Nikkei and check on how were the markets behaving globally at a given moment:
Interactive Commodities Analysis with R
Another interesting source of information can be created when comparing the price of commodities with the one of any of the indexes.
Thanks to yfR and this view, we can see the evolution in the relation of any pair index/commodity.
How Can I try the R Stocks Shiny App?
- If you read so far, you will want to try the App, I have deployed it using the latest Docker image.
- You can use it for free from any browser at: https://r-stocks.fossengineer.com/
- The Docker image that Im running is of course in DockerHub: https://hub.docker.com/repository/docker/fossengineer/r_stocks
What if the site can’t be reached?
- I am making an effort to self-host at home a version of this R Shiny App with Docker and Cloudflare tunnels.
- It might be that my Raspberry it is not powered at that moment or that I have decided to free resources. But dont worry, you can self-host it as well.
How can I self-host R-Stocks?
- You can build the R Stocks image from source.
- You can use the Docker image I already built:
How to deploy R Stocks with Docker and a GUI?
You can install Portainer with Docker and use the configuration above to self-host your own instance of RStocks with a GUI to manage the container.
How can I contribute?
The code is accesible from my Github Repository of R/Stocks
Please feel free to fork the repository and experiment with the code.