library(tidyverse) aprilBond %>% mutate_at(vars(total, planned, tenure, coupon), as.numeric) %>% mutate(code = str_extract(stocks, "[0-9]+(?=\\()")) %>% mutate(code = case_when( nchar(code) == 4 ~ str_c(code, ".HK"), str_detect(code, "^6") ~ str_c(code, ".SH"), TRUE ~ str_c(code, ".SZ") )) %>% # filter(lubridate::ymd(date) >= lubridate::ymd("2020-04-01")) %>% mutate(stock_name = str_extract(stocks, "(?<=[0-9]{4,6}\\()[^\\(\\)]+(?=\\))")) %>% select("name", "long_name", "stock_name") %>% unique() %>% writexl::write_xlsx("aprilnames.xlsx") group_by(stock_name, first) %>% summarise(n = n(), sum = sum(total)) %>% filter(stock_name == "金融街") %>% slice(1) %>% pull("sum") %>% paste0(., "亿") group_by(code, name) %>% summarise(sum = sum(total, na.rm = TRUE)) %>% drop_na() %>% arrange(desc(sum))
aprStock %>% inner_join(candidates, by = "stock_name") candidates %>% anti_join(aprStock, by = "stock_name")
colnames(names) <- c("code", "name") names %>% mutate(code = case_when( str_detect(code, "[A-Z]") ~ code, nchar(code) == 5 ~ str_remove(code, "^0") %>% str_c(".HK"), str_detect(code, "^6") ~ paste0(code, ".SH"), TRUE ~ str_c(code, ".SZ") )) -> names writexl::write_xlsx("names.xlsx")
names %>% anti_join(stock, by = c("code")) stock$stock_name
aprilnames %>% anti_join(stock, by = "stock_name") %>% tidyr::drop_na()
off_extra$coupon
tibble( coupon = c(NA, 7.875 , 5.625 , 5.125 , 3.850 , 9.970 , 5.750 ,12.000 ,11.500) ) %>% mutate_at(vars(coupon), ~ as.numeric)
aprilBond %>% # filter(month(date) == 4) %>% mutate_at(vars(total, tenure, coupon), as.numeric) %>% left_join(aprilnames, by = "name") %>% mutate(name = if_else(!is.na(stock_name), stock_name, name)) %>% # filter(name== "万科企业") group_by(name) %>% summarise(total = sum(total, na.rm = TRUE)) %>% arrange(desc(total))
aprilBond %>% # filter(month(date) == 4) %>% mutate_at(vars(total, tenure, coupon), as.numeric) %>% filter(name == "万科") %>% summarise(mcost = weighted.mean(coupon, total))
readRDS("E:/offshore")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.