Skip to content
Valery Barmin edited this page Jun 2, 2015 · 1 revision

#Bar chart

Download 101 form for all days

library(cbrAPI)
data101 <- download.dbf.all(form = 101)

Until 2007, the account sums are stored in ITOGO column, then in IITG column. Need to fix it with one column.

data <- data101[ , which(names(data101) %in% c('REGN','NUM_SC','ITOGO','IITG','A_P','DT'))]
x <- subset(data, DT < '2007-01-01')
y <- subset(data, DT >= '2007-01-01')
data$ITOGO <- c(x$ITOGO, y$IITG)
data <- data[ , -which(names(data) %in% c('IITG'))]
rm(x,y)

Let's take some Bank, e.g. Sberbank

data.small <- subset(data, REGN == 1481)

Multiply all the assets of (-1) to find the sum. ITGAP rows (total for asset / liability) will become NA values — it's not terrible.

data.small$NUM_SC <- as.integer(as.character(data.small$NUM_SC))
data.small$ITOGO <- as.integer(as.character(data.small$ITOGO))
x <- subset(data.small, subset=A_P==1)
y <- subset(data.small, subset=A_P==2)
x$ITOGO <- x$ITOGO * (-1)
data.small <- rbind(x,y)
data.small <- data.small[with(data.small, order(DT, REGN, NUM_SC)), ]
rm(x,y)

Find the volume of liabilities on the interbank market, it's 300 - 329 passive accounts

data.small <- subset(data.small, subset=A_P==2)
data.small <- subset(data.small, subset=(NUM_SC %in% c(30000:32902)))
data.sub <- matrix(nrow=0,ncol=2)
colnames(data.sub) <- c("DT", "Corporate")
for (i in levels(as.factor(data.small$DT))) {
  corporate <- subset(data.small, subset=(DT==i))
  data.sub <- rbind(data.sub, c(i, sum(corporate$ITOGO)))
}
data.sub <- as.data.frame(data.sub)
rm(corporate)

Draw a bar chart with standard tools

barplot(as.numeric(as.character(data.sub$Corporate))/1000000,
        main=paste("Bar Chart of", getBankInfo(data.small$REGN[1])$name),
        xlab="Date, months", ylab="Volume, millions of rubles",
        names.arg=data.sub$DT)

bar chart

Clone this wiki locally