%bank loans (liabilities)
%------------------------
clear;
load tbsm3m.txt -ascii

rate=tbsm3m(:,2)/100;
n=1;
j=145; %start in 52/01
%constructing quarterly averages
while j+2<180
   rateq(n)=(rate(j)+rate(j+1)+rate(j+2))/3 + (2.09/100);
j=j+3;
n=n+1;
end;






load prime.txt -ascii
rate=prime(:,2)/100;
%series starts in 49/01
n=13;
i=1; %start in 52/01
%constructing quarterly averages
while i+2<612
rateq(n)=(rate(i)+rate(i+1)+rate(i+2))/3;
i=i+3;
n=n+1;
end;





loans_ls=8.9*1000;
load loans.txt -ascii
%series starts in 52/01

loans_a(1)=3.7;
loans_a(2)=3.1;
loans_a(3)=.7;
loans_a(4)=-1.9;
loans_a(5)=3.7;
loans_a(6)=4.2;




loans_a=loans_a*1000;

for n=1:6
   for i=1:4
   j=(n-1)*4+i
   loans_q(j)=(loans_a(n)/4);
  end
end


loans_q(25:25+190,1)=loans(:,2);
M=190+25
loans_l(1)=loans_ls+loans_q(1);
for n=2:M
   loans_l(n)=loans_l(n-1)+loans_q(n);
end   

for l=1:M
   loans_int(l)=loans_l(l)*((1+rateq(l))^(1/4)-1);
end   
loans_int=loans_int';
save int_loans  loans_int  -ascii
