function varargout = ALB(varargin)
% ALB M-file for ALB.fig
%      ALB, by itself, creates a new ALB or raises the existing
%      singleton*.
%
%      H = ALB returns the handle to a new ALB or the handle to
%      the existing singleton*.
%
%      ALB('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ALB.M with the given input arguments.
%
%      ALB('Property','Value',...) creates a new ALB or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ALB_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ALB_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ALB

% Last Modified by GUIDE v2.5 27-Sep-2011 22:02:11

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ALB_OpeningFcn, ...
                   'gui_OutputFcn',  @ALB_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before ALB is made visible.
function ALB_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to ALB (see VARARGIN)

% Choose default command line output for ALB
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes ALB wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = ALB_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function S0_Callback(hObject, eventdata, handles)
% hObject    handle to S0 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of S0 as text
%        str2double(get(hObject,'String')) returns contents of S0 as a double
S0= str2double(get(hObject,'String'));
if(isempty(S0))
errordlg('Enter valid Stock Price ','Illegal input','modal');
elseif (isnan(S0)|| S0<0 || S0==0)
errordlg('Enter valid Stock Price','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function S0_CreateFcn(hObject, eventdata, handles)
% hObject    handle to S0 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
S0 = str2double(get(handles.S0,'string'));  
sigma = str2double(get(handles.sigma,'string'));
r = str2double(get(handles.r,'string'));
T = str2double(get(handles.T,'string'));
m= str2double(get(handles.m,'string'));
sigma1= str2double(get(handles.sigma1,'string'));
S1= str2double(get(handles.S1,'string'));
S2= str2double(get(handles.S2,'string'));
sigma2= str2double(get(handles.sigma2,'string'));
n = str2double(get(handles.n,'string'));
int= str2double(get(handles.int,'string'));
lst= str2double(get(handles.lst,'string'));
w1= str2double(get(handles.w1,'string'));
w2= str2double(get(handles.w2,'string'));
w3= str2double(get(handles.w3,'string'));

Dt = T/m;

% int is initial period and lst denotes start of the average period,m is number of
% lookback dates,n-number of simulations ,w1,w2,w3 weights for respective assets and S1,S2 and others are the parameters, we still have same r and T ;
ranvec= randn(n,m);
Spath1=S0*[ones(n,1),cumprod(exp((r-0.5*sigma^2)*Dt+sigma*sqrt(Dt)*ranvec),2)];
Spath2=S1*[ones(n,1),cumprod(exp((r-0.5*sigma1^2)*Dt+sigma1*sqrt(Dt)*ranvec),2)];
Spath3=S2*[ones(n,1),cumprod(exp((r-0.5*sigma2^2)*Dt+sigma2*sqrt(Dt)*ranvec),2)];

%ESpath= S*[ones(n,1),cumprod(exp(r*Dt)*ones(n,m),2)];
Spath=w1*Spath1+w2*Spath2+w3*Spath3;
fs1=Spath(:,2:int);


%mean(fs1,1)
fs2=min(mean(fs1,1)); %strike price 
[cb1 cb2]=min(mean(fs1,1));
ss1=Spath(:,lst:m+1);
arithave = mean(mean(ss1,1)); %average price 
get_type=get(handles.radiobutton3,'Value');
if get_type
Parith = exp(-r*T)*max(arithave-fs2,0); % price
sterror=std(mean(Spath,2))/sqrt(n);
for i=1:(m+1)
mm1(i)=[i];
end

% for i=1:m

 
% hold on ;
% end
set(handles.SP,'string',fs2);
set(handles.AP,'string',arithave);
set(handles.P,'string',Parith);
set(handles.Er,'string',sterror);
cla reset;
plot(handles.axes1,mm1,mean(Spath,1));
% hline(fs2,'r','Strike Price ');
% hline(fs2,'r','Strike');
text(cb2,fs2,' \leftarrow Strike','FontSize',9);
vline(int,'r','A');
vline(lst,'r','B');
vline(m,'r','C');
else
    
    for i=1:(m+1)
mm1(i)=[i];
end
  Parith = exp(-r*T)*max(fs2-arithave,0);
 sterror=std(mean(Spath,2))/sqrt(n);
set(handles.SP,'string',fs2);
set(handles.AP,'string',arithave);
set(handles.P,'string',Parith);
set(handles.Er,'string',sterror);
plot(handles.axes1,mm1,mean(Spath,1));
vline(int,'r','A');
vline(lst,'r','B');
vline(m,'r','C');
end

guidata(hObject, handles);


function SP_Callback(hObject, eventdata, handles)
% hObject    handle to SP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of SP as text
%        str2double(get(hObject,'String')) returns contents of SP as a double


% --- Executes during object creation, after setting all properties.
function SP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to SP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function AP_Callback(hObject, eventdata, handles)
% hObject    handle to AP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of AP as text
%        str2double(get(hObject,'String')) returns contents of AP as a double


% --- Executes during object creation, after setting all properties.
function AP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to AP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function P_Callback(hObject, eventdata, handles)
% hObject    handle to P (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of P as text
%        str2double(get(hObject,'String')) returns contents of P as a double


% --- Executes during object creation, after setting all properties.
function P_CreateFcn(hObject, eventdata, handles)
% hObject    handle to P (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Er_Callback(hObject, eventdata, handles)
% hObject    handle to Er (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Er as text
%        str2double(get(hObject,'String')) returns contents of Er as a double


% --- Executes during object creation, after setting all properties.
function Er_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Er (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function r_Callback(hObject, eventdata, handles)
% hObject    handle to r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of r as text
%        str2double(get(hObject,'String')) returns contents of r as a double
r= str2double(get(hObject,'String'));
if(isempty(r))
errordlg('Enter valid rate','Illegal input','modal');
elseif (isnan(r)|| r<0 || r==0)
errordlg('Enter valid rate','Illegal input','modal');
end


% --- Executes during object creation, after setting all properties.
function r_CreateFcn(hObject, eventdata, handles)
% hObject    handle to r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function T_Callback(hObject, eventdata, handles)
% hObject    handle to T (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of T as text
%        str2double(get(hObject,'String')) returns contents of T as a double
T= str2double(get(hObject,'String'));
if(isempty(T))
errordlg('Enter valid time period','Illegal input','modal');
elseif (isnan(T)|| T<0 || T==0)
errordlg('Enter valid time period','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function T_CreateFcn(hObject, eventdata, handles)
% hObject    handle to T (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double


% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function m_Callback(hObject, eventdata, handles)
% hObject    handle to m (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of m as text
%        str2double(get(hObject,'String')) returns contents of m as a double
m= str2double(get(hObject,'String'));
if(isempty(m))
errordlg('Enter valid number','Illegal input','modal');
elseif (isnan(m)|| m<0 || m==0)
errordlg('Enter valid number','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function m_CreateFcn(hObject, eventdata, handles)
% hObject    handle to m (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function n_Callback(hObject, eventdata, handles)
% hObject    handle to n (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of n as text
%        str2double(get(hObject,'String')) returns contents of n as a double
n= str2double(get(hObject,'String'));
if(isempty(n))
errordlg('Enter valid number','Illegal input','modal');
elseif (isnan(n)|| n<0 || n==0)
errordlg('Enter valid number','Illegal input','modal');
end


% --- Executes during object creation, after setting all properties.
function n_CreateFcn(hObject, eventdata, handles)
% hObject    handle to n (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function int_Callback(hObject, eventdata, handles)
% hObject    handle to int (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of int as text
%        str2double(get(hObject,'String')) returns contents of int as a double
int= str2double(get(hObject,'String'));
if(isempty(int))
errordlg('Enter valid number','Illegal input','modal');
elseif (isnan(int)|| int<0 || int==0)
errordlg('Enter valid number','Illegal input','modal');
end



% --- Executes during object creation, after setting all properties.
function int_CreateFcn(hObject, eventdata, handles)
% hObject    handle to int (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function lst_Callback(hObject, eventdata, handles)
% hObject    handle to lst (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of lst as text
%        str2double(get(hObject,'String')) returns contents of lst as a double
lst= str2double(get(hObject,'String'));
if(isempty(lst))
errordlg('Enter valid number','Illegal input','modal');
elseif (isnan(lst)|| lst<0 || lst==0)
errordlg('Enter valid number','Illegal input','modal');
end



% --- Executes during object creation, after setting all properties.
function lst_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lst (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function S2_Callback(hObject, eventdata, handles)
% hObject    handle to S2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of S2 as text
%        str2double(get(hObject,'String')) returns contents of S2 as a
%        double
S2= str2double(get(hObject,'String'));
if(isempty(S2))
errordlg('Enter valid Stock Price ','Illegal input','modal');
elseif (isnan(S2)|| S2<0 || S2==0)
errordlg('Enter valid Stock Price','Illegal input','modal');
end


% --- Executes during object creation, after setting all properties.
function S2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to S2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function sigma2_Callback(hObject, eventdata, handles)
% hObject    handle to sigma2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of sigma2 as text
%        str2double(get(hObject,'String')) returns contents of sigma2 as a double
sigma2= str2double(get(hObject,'String'));
if(isempty(sigma2))
errordlg('Enter valid volatility','Illegal input','modal');
elseif (isnan(sigma2)|| sigma2<0 || sigma2==0)
errordlg('Enter valid volatility','Illegal input','modal');
end


% --- Executes during object creation, after setting all properties.
function sigma2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sigma2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function w3_Callback(hObject, eventdata, handles)
% hObject    handle to w3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of w3 as text
%        str2double(get(hObject,'String')) returns contents of w3 as a double
w3= str2double(get(hObject,'String'));
if(isempty(w3))
errordlg('Enter valid weights','Illegal input','modal');
elseif (isnan(w3)|| w3<0 || w3==0)
errordlg('Enter valid weights','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function w3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function S1_Callback(hObject, eventdata, handles)
% hObject    handle to S1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of S1 as text
%        str2double(get(hObject,'String')) returns contents of S1 as a double
S1= str2double(get(hObject,'String'));
if(isempty(S1))
errordlg('Enter valid Stock Price ','Illegal input','modal');
elseif (isnan(S1)|| S1<0 || S1==0)
errordlg('Enter valid Stock Price','Illegal input','modal');
end


% --- Executes during object creation, after setting all properties.
function S1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to S1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function sigma1_Callback(hObject, eventdata, handles)
% hObject    handle to sigma1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of sigma1 as text
%        str2double(get(hObject,'String')) returns contents of sigma1 as a double
sigma1= str2double(get(hObject,'String'));
if(isempty(sigma1))
errordlg('Enter valid volatility','Illegal input','modal');
elseif (isnan(sigma1)|| sigma1<0 || sigma1==0)
errordlg('Enter valid volatility','Illegal input','modal');
end


% --- Executes during object creation, after setting all properties.
function sigma1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sigma1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function w2_Callback(hObject, eventdata, handles)
% hObject    handle to w2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of w2 as text
%        str2double(get(hObject,'String')) returns contents of w2 as a double

w2= str2double(get(hObject,'String'));
if(isempty(w2))
errordlg('Enter valid weights','Illegal input','modal');
elseif (isnan(w2)|| w2<0 || w2==0)
errordlg('Enter valid weights','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function w2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function sigma_Callback(hObject, eventdata, handles)
% hObject    handle to sigma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of sigma as text
%        str2double(get(hObject,'String')) returns contents of sigma as a double

sigma= str2double(get(hObject,'String'));
if(isempty(sigma))
errordlg('Enter valid volatility','Illegal input','modal');
elseif (isnan(sigma)|| sigma<0 || sigma==0)
errordlg('Enter valid volatility','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function sigma_CreateFcn(hObject, eventdata, handles)
% hObject    handle to sigma (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function w1_Callback(hObject, eventdata, handles)
% hObject    handle to w1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of w1 as text
%        str2double(get(hObject,'String')) returns contents of w1 as a double
w1= str2double(get(hObject,'String'));
if(isempty(w1))
errordlg('Enter valid weights','Illegal input','modal');
elseif (isnan(w1)|| w1<0 || w1==0)
errordlg('Enter valid weights','Illegal input','modal');
end

% --- Executes during object creation, after setting all properties.
function w1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1


% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2
