function AnaliticalFinanceProject(K,pricecall,priceput,r,So,OpNum,x,TradeCosts,date)
NumDays = daysdif(today, date , x);
if (TradeCosts==false);
    t=0;
else 
    t=0.02;
end
display(NumDays);
UnSto=100;
UnNum=UnSto*OpNum;
portfolio1=UnNum*-pricecall*ones(100000,1);
portfolio2=UnNum*-priceput*ones(100000,1);
S= zeros(100000,NumDays);
S(:,1)=So;
S2= zeros(100000,NumDays);
S2(:,1)=So;
vol1=blsimpv(So,K,r,NumDays/252,pricecall);
Class=false;
vol2=blsimpv(So,K,r,NumDays/252,priceput,[],[],[],Class);

display(vol1);
display(vol2);

adj=zeros(100000,NumDays);

for i=1 : NumDays-1
    z=randn(100000,1);
    S(:,i+1)=S(:,i).*exp(z*vol1*sqrt(1/252)+(r-(vol1^2)/2)*1/252);
    S2(:,i+1)=S2(:,i).*exp(z*vol2*sqrt(1/252)+(r-(vol2^2)/2)*1/252);
end
tempDelta1=zeros(100000,1);
T=ones(100000,1)*(NumDays:-1:1);
delta1=normcdf((log(S/K)+(r+(vol1^2)/2).*(T/252))./(vol1+sqrt(T/252)),0,1);
delta2=(normcdf((log(S2/K)+(r+(vol2^2)/2).*(T/252))./(vol2+sqrt(T/252)),0,1)-1);
tempDelta1(:,1)=round(delta1(:,1)*UnNum)/UnNum;
tempDelta2(:,1)=round(delta2(:,1)*UnNum)/UnNum;
portfolio1(:,1)=portfolio1(:,1)+UnNum*tempDelta1(:,1).*(S(:,1))*(1-t);
portfolio2(:,1)=portfolio2(:,1)+UnNum*tempDelta2(:,1).*(S2(:,1))*(1-t);

for j=1:100000
    for i=2:NumDays
        if  abs(delta1(j,i)-tempDelta1(j,1))>10/OpNum
            adj(j,i)=round(delta1(j,i)*UnNum)/UnNum-tempDelta1(j,1);
            tempDelta1(j,1)=round(delta1(j,i)*UnNum)/UnNum;
            portfolio1(j,1)=portfolio1(j,1)+UnNum*(adj(j,i).*S(j,i))-(abs(adj(j,i))*t);
        end
        if  abs(delta2(j,i)-tempDelta2(j,1))>10/OpNum
           
            adj(j,i)=round(delta2(j,i)*UnNum)/UnNum-tempDelta2(j,1);
            tempDelta2(j,1)=round(delta2(j,i)*UnNum)/UnNum; 
            portfolio2(j,1)=portfolio2(j,1)+UnNum*(adj(j,i).*S2(j,i))-(abs(adj(j,i))*t);
        end
    portfolio1(j,1)=exp(r*1/252)*portfolio1(j,1);   
    portfolio2(j,1)=exp(r*1/252)*portfolio2(j,1); 
    end   
end

portfolio1(:,1)=exp(-r*NumDays/252)*(portfolio1(:,1)+UnNum*(max((S(:,NumDays)-K),0)-tempDelta1(:,1).*(S(:,NumDays))*(1+t)));
portfolio2(:,1)=exp(-r*NumDays/252)*(portfolio2(:,1)+UnNum*(max((K-S2(:,NumDays)),0)-tempDelta2(:,1).*(S2(:,NumDays))*(1+t)));
display('Call Mean: ');
display(mean(portfolio1));
display('Call Variance: ');
display(var(portfolio1));
display('Put Mean: ');
display(mean(portfolio2));
display('Put Variance: ');
display(var(portfolio2));

display('Call skewness');
display(mean(skewness(portfolio1)));
display('Put skewness');
display(mean(skewness(portfolio2)));
%
hist(portfolio1,40);
%xlabel('SEK');
%
title('Call Option Hedged And Transaction Costs NOT Implied');
%plot(S2(1:1000,10));
display('Without hedging: ');
wportfolio1= UnNum*-pricecall*ones(100000,1);
wportfolio2= UnNum*-priceput*ones(100000,1);
wportfolio1(:,1)=wportfolio1(:,1)+UnNum*(exp(-r*NumDays/252)*max((S(:,NumDays)-K),0));
wportfolio2(:,1)=wportfolio2(:,1)+UnNum*(exp(-r*NumDays/252)*max((K-S2(:,NumDays)),0));
display('Call Mean: ');
display(mean(wportfolio1));
display('Call Variance: ');
display(var(wportfolio1));
display('Put Mean: ');
display(mean(wportfolio2));
display('Put Variance: ');
display(var(wportfolio2));
display('Call skewness');
display((skewness(wportfolio1)));
display('Put skewness');
display((skewness(wportfolio2)));
display(mean(portfolio1)/mean(wportfolio1)*100);
display(var(portfolio1)/var(wportfolio1)*100);
display(skewness(portfolio1)/skewness(wportfolio1)*100);
display(mean(portfolio2)/mean(wportfolio2)*100);
display(var(portfolio2)/var(wportfolio2)*100);
display(skewness(portfolio2)/skewness(wportfolio2)*100);
%
%hist(wportfolio2,50);
%
%title('Put Option Unhedged');
%hist(S(:,NumDays));

