%commercial paper on the liability side
%-------------------------------------
%-------------------------------------




clear;
%before 71/04 we're using the 3 month Tbill rate
%-----------------------------------------------
load tbsm3m.txt -ascii % 3-month T-Bill ;starts in Jan 34

rate=tbsm3m(:,2)/100;
n=1;
j=145;   


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





%after April 71 we're using the rate on commercial paper
load hcp3m.txt -ascii  %3-month commercial paper; starts in April 71   
rate=hcp3m(:,2)/100;


i=1; 

%--------------------------------
%constructing quarterly averages
%--------------------------------
while i<=345
rateq(n)=(rate(i)+rate(i+1)+rate(i+2))/3;
i=i+3;
n=n+1;
end;

 

%loading the series on issues of commercial paper
loans_ls=.1*1000;
load openmc.txt -ascii     %code 103169700
%series starts in 52/01
%no quarterly data prior to 52
loans_a(1)=0.0;
loans_a(2)=0.1;
loans_a(3)=0.1
loans_a(4)=0;.1
loans_a(5)=-0.1;
loans_a(6)=-0.1;




loans_a=loans_a*1000;

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


M=25+190-1;

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

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