ggplot
and gganimate
to craft stunning animated visualizations. These plots aren’t just eye candy; they’re the content that keeps Sectors Instagram account buzzing (make sure to check them out and hit that follow button!). Each plot is based on meticulously curated data from the Sectors team, providing insightful analysis, particularly focusing on the Indonesia Stock Exchange. So, without further ado, let’s dive into the excitement of our third recipe in this animation plot series!
Financial Ratio Valuation Metrics
In the last two recipes, we already used the market capitalization and transaction volume to do some analysis. In this recipe, we will use financial ratio to do some valuation on each stock price. There are two financial ratio valuation metrics that we will use here which arePrice to Earning Ratio
(PE Value) and Price to Book Value Ratio
(PBV).
PE Value Ratio
The price-to-earnings (P/E) ratio is a metric that evaluates a company’s stock price in relation to its earnings per share (EPS). This ratio is crucial for determining the value of a company’s stock, as it allows for comparisons of a company’s valuation over time, with other companies in the same industry, or with the broader market.Example: A P/E ratio of 15 means that the company’s current market value equals 15 times its annual earnings.The P/E ratio serves as a valuable tool for investors to gauge whether a stock is undervalued or overvalues. A high P/E ratio may indicate that the stock is overvalued, suggesting either optimistic growth expectations or inflated market sentiment and vice versa. Additionally, by calculating the median P/E ratio across several years, investors can establish a standardized benchmark to determine a stock’s potential worth. However, a notable limitation of using P/E ratios arises when comparing companies across different sectors. Variations in valuation and growth rates are common among industries due to differences in revenue generation timing and business models, making direct P/E ratio comparisons less reliable.
PBV Ratio
The price-to-book ratio (P/B ratio) of a company is calculated by dividing its current stock price per share by its book value per share (BVPS). This ratio provides insight into how the market values the company relative to its book value.Example A P/B ratio of 1 means that the stock price is trading in line with the book value of the company. In other words, the stock price would be considered fairly valued, strictly from a P/B standpoint.Typically, a P/B ratio below one suggests that a company is undervalued, whereas a ratio above one suggests that the stock is trading at a premium. However, the significance of these values can vary significantly across industries. Different sectors have their own norms, where lower or higher P/B ratios may be considered typical. However, the P/B ratio has its limitations. For instance, it does not take into account intangible assets such as intellectual property and brand value, which can be significant in certain industries. As a result, the P/B ratio may not always accurately reflect a company’s true value. Furthermore, the P/B ratio may be less relevant for companies with a high proportion of intangible assets, such as technology firms, where the value lies more in ideas and innovations than in physical assets.
Plot Creation
After reading about the financial ratios valuation metrics, now we can start to play with the data and create a animated plot to shown the comparisons of the financial valuation metrics (PE and PBV) of some major banks in Indonesia.Data Fetching
To get the data you can use Sectors Financial API to directly fetch the data from the Sectors website, it will be easier for you to directly ping the API and use the data than curated the data by yourself, so don’t forget to subscribe to Sectors Financial API plan. Here is the code to fetch the historical valuation data using the API.stocks
list. Finally, here is the result of the fetching code.
symbol | year | pe | pb | pe_peer_avg | pb_peer_avg |
---|---|---|---|---|---|
BBCA.JK | 2020 | 30.45000 | 4.4800000 | 27.29648 | 1.2624248 |
BBCA.JK | 2021 | 28.35000 | 4.3900000 | 15.01456 | 1.4663059 |
BBNI.JK | 2022 | 9.30000 | 1.2500000 | 15.12926 | 1.0085239 |
BBNI.JK | 2023 | 9.30000 | 1.3000000 | 13.15047 | 0.7844267 |
BBRI.JK | 2020 | 27.30000 | 2.2400000 | 27.29648 | 1.2624248 |
Data Manipulation
In the data there arepe_peer_avg
and pb_peer_avg
columns which are the Sectors PE ratio and PBV ratio in each year and every symbol will have the same value if the year is the same. Therefore, we will convert those value and bind it into our data using the code below.
symbol | year | pe | pb |
---|---|---|---|
Banks Sub-Sector | 2020 | 27.29648 | 1.2624248 |
BBCA.JK | 2020 | 30.45000 | 4.4800000 |
BBCA.JK | 2021 | 28.35000 | 4.3900000 |
BBNI.JK | 2022 | 9.30000 | 1.2500000 |
BBNI.JK | 2023 | 9.30000 | 1.3000000 |
BBRI.JK | 2020 | 27.30000 | 2.2400000 |
Data Visualization
Same like before, we will create a custom theme for our plot just for the content purpose, you don’t need to use this custom theme if you don’t want to.Yearly Plot
Usually, we compared the PE and PBV ratio for same stock in different time to see whether a stock is overvalued or undervalued compare to their historical valuation. Therefore in this section, we will try to make a plot that see the difference between PE and PBV ratio forBBCA.JK
from year 2020 to 2023 using the code below.

Sectors plot
Another analysis that we can use to determine a value of a stock is by compare it to another stock in the same sector or compare it to the Sectors average. The code below will make a plot that enable that analysis.
Animation Plot
Using the two plots above that create the plot for comparisons of PE and PBV ratio of one company over the years, and the plot to compare PE and PBV ratio of some companies in one sector in one year. We can combine it to create a plot that show the PE and PBV ratio comparison of some companies in a sub-sector over the years. And, we will create an animation plot to achieve that. Here is the code to create the static plot first before we configure the transition and create an animation plot..gif
file.
