function [C, P] = CRRfws(T, S0, T1, r, v, N)
%  Octave/MATLAB function to price forward start
%  Call and Put options using the Cox-Ross-Rubinstein
%  (CRR) binomial pricing model.
% INPUTS:                                   (Example)
%   T  =  expiration time in years          (1)
%   S0 =  spot stock spot price             (90)
%   T1 =  strike price set time; 0<T1<T     (0.5)
%   r  =  risk-free annual yield            (0.02)
%   v  =  volatility; must be >0            (0.15)
%   N  =  height of the binomial tree       (10)
% OUTPUT:
%   C =  price of the Call option at gridpoints (n,j).
%   P =  price of the put option at gridpoints (n,j).
% EXAMPLE:
%  [C,P] = CRRfws(1, 90, 0.5, 0.02, 0.15, 10);
%  C(1,1),P(1,1)  % get just C(0),P(0) as output
%
  [pu,up,R] = CRRparams(T,r,v,N); % Use CRR values 
  M = round(T1*N/T); % set strike price grid time
  for(j=0:M)
    SMj(j+1)= S0*up^(2*j-M); % modeled S(M,j)
  end
  for(j=0:M) % price at-the-money vanilla options
    [C,P]=CRReur(T,S0,SMj(j+1),r,v,N); % vanilla
    CMj(j+1)=C(M+1,j+1);  % Call price at (M,j)
    PMj(j+1)=P(M+1,j+1);  % Put price at (M,j)
  end
  % Reinitialize smaller forward start C and P:
  C=zeros(M+1,M+1); P=zeros(M+1,M+1);
  for j=0:M  %  set terminal values at time M
    C(M+1,j+1)=CMj(j+1); P(M+1,j+1)=PMj(j+1);
  end
  for n = M-1:-1:0  % backward induction
    for j = 0:n     % binomial pricing
      C(n+1,j+1)=(pu*C(n+2,j+2)+(1-pu)*C(n+2,j+1))/R;
      P(n+1,j+1)=(pu*P(n+2,j+2)+(1-pu)*P(n+2,j+1))/R;
    end
  end
  return; % Prices in C and P are all defined.
end
