%all liquid assets held by non-fram non-financial coporations
%-------------------------------------------------------------
%includes 21,22,23,24,25..28 on p. 169 of Guide
%liquid asset series in levels
%-----------------------------------------------
%the interest rate imputed is the rate on 3 mont commercial Paper
%before 49 we're using the rate on 3month TBill
%-----------------------------------------------

clear

load tbsm3m.txt -ascii

rate=tbsm3m(:,2)/100;
n=1;
j=145; 
%constructing quarterly averages
%--------------------------------
while j+2<447
   rateq(n)=(rate(j)) + (.70212/100);
j=j+3;
n=n+1;
end;




%after 49 we're using the rate on 3-month Commercial paper
%---------------------------------------------------------
load hcp3m.txt -ascii
rate=hcp3m(:,2)/100;
%series starts in 49/01
i=1; %start in 52/01
%constructing quarterly averages
while i+2<345
rateq(n)=(rate(i)+rate(i+1)+rate(i+2))/3;
i=i+3;
n=n+1;
end;

 


loans_l(1)=(19.0+18.5+.3)*1000;
load liqasset.txt -ascii    %code 104001005
load munia.txt -ascii %code 103062003
%series starts in 52/01




%from balance sheet data
loans_a(1)=19.5+12.8+.3;
loans_a(2)=21.4+.9+.1+12.3+.4;
loans_a(3)=21.9+.9+.2+12.9+.5;
loans_a(4)=22.9+.9+.3+14.7+.5;
loans_a(5)=24.2+.9+.1+17.9+.7+.1;
loans_a(6)=25.9+.9+.1+18.7+.8+.1;


loans_tl(1)=.25*1000;
%series starts in 52/01
%from balance sheet data
loans_ta(1)=0.31;
loans_ta(2)=0.35;
loans_ta(3)=0.45;
loans_ta(4)=0.49;
loans_ta(5)=0.65;
loans_ta(6)=0.84;



loans_a=loans_a*1000;

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

loans_tq(1:4,1)=(.31/4)*1000;

for n=1:6
   for i=1:4
   j=(n-1)*4+i
   loans_tl(j,1)=loans_ta(n);
  end
end

%tax-exempt securities: data in flows
%------------------------------------
loans_tq(25:25+190,1)=munia(:,2);
M=190+25
for n=25:M
   loans_tl(n)=loans_tl(n-1)+loans_tq(n);
end  

M=25+190-1;
%liquid assets data in levels
%------------------------
loans_l(25:25+190,1)=liqasset(:,2)*1000;


for l=1:M
   loans_int(l)=(loans_l(l)-loans_tl(l))*((1+rateq(l))^(1/4)-1);
end   


loans_int=loans_int';

save int_liqa loans_int -ascii 