knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(MiscImport) library(tidyverse) library(lubridate) library(zoo)
inst_investors_assets = import_boi_institutional_portolio_asset_class() pension_balance = import_boi_pension_funds_balance()
inst_investors_assets %>% mutate(investor_type = as_factor(investor_type)) %>% mutate(investor_type = fct_collapse( investor_type, pensia = c("pensia_vatikot","pensia_claliot_hadashot", "pensia_mekifot_hadashot"), bituah = c("bituah_mavtihot_tsua", "bituah_mishtatfot_berevahim"))) %>% group_by(date, investor_type) %>% summarise(value = sum(value), .groups = "drop") %>% ggplot(aes(date, value, color = investor_type)) + geom_line(lwd = 1)
inst_investors_assets %>% mutate(asset_class = as_factor(asset_class)) %>% mutate(asset_class = fct_collapse( asset_class, gov_bond = c("gov_bond-traded", "gov_bond-not_traded", "makam"), corp_bond = c("corp_bond-traded", "corp_bond-not_traded", "bond-etf"), stock = c("stocks-traded", "stocks-not_traded", "stocks-etf"), cash = c("cash_and_deposits-linked", "cash_and_deposits-nominal"))) %>% group_by(date, asset_class) %>% summarise(value = sum(value), .groups = "drop") %>% group_by(date) %>% mutate(value = value / sum(value)) %>% ungroup() %>% # filter(asset_class %in% c("corp_bond", "stock")) %>% ggplot(aes(date,value)) + geom_line(aes(color = asset_class)) + scale_color_viridis_d() + scale_y_continuous(labels = scales::percent_format()) + xlab(NULL) + ylab(NULL) + ggtitle("Asset class shares in institutional portfolio") + theme(legend.title = element_blank())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.