function varargout = GUI3(varargin)
% GUI3 M-file for GUI3.fig
%      GUI3, by itself, creates a new GUI3 or raises the existing
%      singleton*.
%
%      H = GUI3 returns the handle to a new GUI3 or the handle to
%      the existing singleton*.
%
%      GUI3('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI3.M with the given input arguments.
%
%      GUI3('Property','Value',...) creates a new GUI3 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI3_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI3_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 GUI3

% Last Modified by GUIDE v2.5 18-Oct-2012 04:46:28

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @GUI3_OpeningFcn, ...
    'gui_OutputFcn',  @GUI3_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 GUI3 is made visible.
function GUI3_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
handles.redoption = 'Off';
handles.redk = 0;
handles.redsl = 'Short';
handles.redline = line(0,0);
handles.redr = 0;
handles.redV = 0;
handles.redS = 0;
handles.redT = 0;
handles.redY = 0;
handles.redPrice = 0;
handles.redX = 0;

handles.blueoption = 'Off';
handles.bluek = 0;
handles.bluesl = 'Short';
handles.blueline = line(0,0);
handles.blue_r = 0;
handles.blue_V = 0;
handles.blue_S = 0;
handles.blue_T = 0;
handles.blue_Y = 0;
handles.bluePrice = 0;
handles.blueX = 0;

handles.greenoption = 'Off';
handles.greenk = 0;
handles.greensl = 'Short';
handles.greenline = line(0,0);
handles.greenr = 0;
handles.greenV = 0;
handles.greenS = 0;
handles.greenT = 0;
handles.greenY = 0;
handles.greenPrice = 0;
handles.greenX = 0;

handles.yellowoption = 'Off';
handles.yellowk = 0;
handles.yellowsl = 'Short';
handles.yellowline = line(0,0);
handles.yellowr = 0;
handles.yellowV = 0;
handles.yellowS = 0;
handles.yellowT = 0;
handles.yellowY = 0;
handles.yellowPrice = 0;
handles.yellowX = 0;

handles.blackline = line(0,0);
% 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 GUI3 (see VARARGIN)
axis([0 100 0 100]);

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

% Update handles structure
guidata(hObject, handles);

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

% --- Outputs from this function are returned to the command line.
function varargout = GUI3_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;


% --- Executes on selection change in yellow_sl.
function yellow_sl_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.yellowsl = string_list{val};
guidata(hObject, handles)
% hObject    handle to yellow_sl (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns yellow_sl contents as cell array
%        contents{get(hObject,'Value')} returns selected item from yellow_sl


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

% Hint: popupmenu 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 yellow_k_Callback(hObject, eventdata, handles)
handles.yellowk = str2double(get(hObject,'String'));
guidata(hObject, handles)
% hObject    handle to yellow_k (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 yellow_k as text
%        str2double(get(hObject,'String')) returns contents of yellow_k as a double


% --- Executes during object creation, after setting all properties.
function yellow_k_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yellow_k (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 selection change in yellow_options.
function yellow_options_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.yellowoption = string_list{val};
guidata(hObject, handles)
% hObject    handle to yellow_options (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns yellow_options contents as cell array
%        contents{get(hObject,'Value')} returns selected item from yellow_options


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

% Hint: popupmenu 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 selection change in green_sl.
function green_sl_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.greensl = string_list{val};
guidata(hObject, handles)
% hObject    handle to green_sl (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns green_sl contents as cell array
%        contents{get(hObject,'Value')} returns selected item from green_sl


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

% Hint: popupmenu 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 green_k_Callback(hObject, eventdata, handles)
handles.greenk = str2double(get(hObject,'String'));
guidata(hObject, handles)
% hObject    handle to green_k (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 green_k as text
%        str2double(get(hObject,'String')) returns contents of green_k as a double


% --- Executes during object creation, after setting all properties.
function green_k_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_k (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 selection change in green_options.
function green_options_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.greenoption = string_list{val};
guidata(hObject, handles)
% hObject    handle to green_options (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns green_options contents as cell array
%        contents{get(hObject,'Value')} returns selected item from green_options


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

% Hint: popupmenu 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 selection change in blue_sl.
function blue_sl_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.bluesl = string_list{val};
guidata(hObject, handles)
% hObject    handle to blue_sl (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns blue_sl contents as cell array
%        contents{get(hObject,'Value')} returns selected item from blue_sl


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

% Hint: popupmenu 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 blue_k_Callback(hObject, eventdata, handles)
handles.bluek = str2double(get(hObject,'String'));
guidata(hObject, handles)

% hObject    handle to blue_k (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 blue_k as text
%        str2double(get(hObject,'String')) returns contents of blue_k as a double


% --- Executes during object creation, after setting all properties.
function blue_k_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_k (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 selection change in blue_options.
function blue_options_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.blueoption = string_list{val};
guidata(hObject, handles)
% hObject    handle to blue_options (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns blue_options contents as cell array
%        contents{get(hObject,'Value')} returns selected item from blue_options


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

% Hint: popupmenu 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 selection change in red_options.
function red_options_Callback(hObject, eventdata, handles)
% hObject    handle to red_options (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.redoption = string_list{val};
guidata(hObject, handles)

% Hints: contents = cellstr(get(hObject,'String')) returns red_options contents as cell array
%        contents{get(hObject,'Value')} returns selected item from red_options


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

% Hint: popupmenu 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 selection change in red_sl.
function red_sl_Callback(hObject, eventdata, handles)
% hObject    handle to red_sl (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
val = get(hObject,'Value');
string_list = get(hObject,'String');
handles.redsl = string_list{val};
guidata(hObject, handles)
% The user selected the second item
% etc.
% Hints: contents = cellstr(get(hObject,'String')) returns red_sl contents as cell array
%        contents{get(hObject,'Value')} returns selected item from red_sl


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

% Hint: popupmenu 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 red_k_Callback(hObject, eventdata, handles)
% hObject    handle to red_k (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.redk = str2double(get(hObject,'String'));
guidata(hObject, handles)


% --- Executes during object creation, after setting all properties.
function red_k_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_k (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 yellow_plot.
function yellow_plot_Callback(hObject, eventdata, handles)
delete(handles.yellowline);
if strcmp(handles.yellowoption,'Off')
    handles.yellowline = plot(0,0);
    guidata(hObject, handles);
else
    st = 0:0.1:200;
    
    if strcmp(handles.yellowsl, 'Long')
        handles.yellowX = -handles.yellowPrice;
    else
        handles.yellowX = handles.yellowPrice;
    end
    guidata(hObject, handles);
    y = testfunc(handles.yellowoption, handles.yellowsl, handles.yellowk, st);
    y = y+handles.yellowX;;
    if strcmp(handles.yellowoption,'Bond')
        handles.yellowline = plot(st,y,'y.');
        guidata(hObject, handles);
    else
        handles.yellowline = line(st,y,'color','yellow','linewidth',3);
        guidata(hObject, handles);
    end
    hold on
    axis manual;
    axis on;
    axis([0 200 -100 100]);
    %hTitle  = title ('PayOff Graph');
    hXLabel = xlabel('St');
    hYLabel = ylabel('Payoff');
    set( gca, 'FontName', 'Helvetica');
    %set( hTitle                    , ...
    %   'FontSize'   , 12          , ...
    %  'FontWeight' , 'bold'      );
    set(gca, ...
        'Box'         , 'on'     , ...
        'TickDir'     , 'out'     , ...
        'TickLength'  , [.02 .02] , ...
        'XMinorTick'  , 'on'      , ...
        'YMinorTick'  , 'on'      , ...
        'YGrid'       , 'on'      , ...
        'XGrid'       , 'on'      , ...
        'XColor'      , [.3 .3 .3], ...
        'YColor'      , [.3 .3 .3], ...
        'LineWidth'   , 1         );
    
end
% hObject    handle to yellow_plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in green_plot.
function green_plot_Callback(hObject, eventdata, handles)
delete(handles.greenline);
if strcmp(handles.greenoption,'Off')
    handles.greenline = plot(0,0);
    guidata(hObject, handles);
else
    st = 0:0.1:200;
    
   
    if strcmp(handles.greensl, 'Long')
        handles.greenX = -handles.greenPrice;
    else
        handles.greenX = handles.greenPrice;
    end
    
    y = testfunc(handles.greenoption, handles.greensl, handles.greenk, st);
    y = y+handles.greenX;
    if strcmp(handles.greenoption,'Bond')
        handles.greenline = plot(st,y,'r.');
        guidata(hObject, handles);
    else
        handles.greenline = line(st,y,'color','green','linewidth',3);
        guidata(hObject, handles);
    end
    hold on
    axis manual;
    axis on;
    axis([0 200 -100 100]);
    %hTitle  = title ('PayOff Graph');
    hXLabel = xlabel('St');
    hYLabel = ylabel('Payoff');
    set( gca, 'FontName', 'Helvetica');
    %set( hTitle                    , ...
    %   'FontSize'   , 12          , ...
    %  'FontWeight' , 'bold'      );
    set(gca, ...
        'Box'         , 'on'     , ...
        'TickDir'     , 'out'     , ...
        'TickLength'  , [.02 .02] , ...
        'XMinorTick'  , 'on'      , ...
        'YMinorTick'  , 'on'      , ...
        'YGrid'       , 'on'      , ...
        'XGrid'       , 'on'      , ...
        'XColor'      , [.3 .3 .3], ...
        'YColor'      , [.3 .3 .3], ...
        'LineWidth'   , 1         );
    
end
% hObject    handle to green_plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in blue_plot.
function blue_plot_Callback(hObject, eventdata, handles)
delete(handles.blueline);
if strcmp(handles.blueoption,'Off')
    handles.blueline = plot(0,0);
    guidata(hObject, handles);
else
    st = 0:0.1:200;
    
   
    if strcmp(handles.bluesl, 'Long')
        handles.blueX = -handles.bluePrice;
    else
        handles.blueX = handles.bluePrice;
    end
    
    y = testfunc(handles.blueoption, handles.bluesl, handles.bluek, st);
    y = y+handles.blueX;
    if strcmp(handles.blueoption,'Bond')
        handles.blueline = plot(st,y,'b.');
        guidata(hObject, handles);
    else
        handles.blueline = line(st,y,'color','blue','linewidth',3);
        guidata(hObject, handles);
    end
    hold on
    axis manual;
    axis on;
    axis([0 200 -100 100]);
    %hTitle  = title ('PayOff Graph');
    hXLabel = xlabel('St');
    hYLabel = ylabel('Payoff');
    set( gca, 'FontName', 'Helvetica');
    %set( hTitle                    , ...
    %   'FontSize'   , 12          , ...
    %  'FontWeight' , 'bold'      );
    set(gca, ...
        'Box'         , 'on'     , ...
        'TickDir'     , 'out'     , ...
        'TickLength'  , [.02 .02] , ...
        'XMinorTick'  , 'on'      , ...
        'YMinorTick'  , 'on'      , ...
        'YGrid'       , 'on'      , ...
        'XGrid'       , 'on'      , ...
        'XColor'      , [.3 .3 .3], ...
        'YColor'      , [.3 .3 .3], ...
        'LineWidth'   , 1         );
    
end

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


% --- Executes on button press in red_plot.
function red_plot_Callback(hObject, eventdata, handles)
delete(handles.redline);
if strcmp(handles.redoption,'Off')
    handles.redline = plot(0,0);
    guidata(hObject, handles);
else
    st = 0:0.1:200;
    
    
    if strcmp(handles.redsl, 'Long')
        handles.redX = -handles.redPrice;
    else
        handles.redX = handles.redPrice;
    end
    guidata(hObject, handles)
    y = testfunc(handles.redoption, handles.redsl, handles.redk, st);
    y = y+handles.redX;
    if strcmp(handles.redoption,'Bond')
        handles.redline = plot(st,y,'r.');
        guidata(hObject, handles);
    else
        handles.redline = line(st,y,'color','red','linewidth',3);
        guidata(hObject, handles);
    end
    hold on
    axis manual;
    axis on;
    axis([0 200 -100 100]);
    %hTitle  = title ('PayOff Graph');
    hXLabel = xlabel('St');
    hYLabel = ylabel('Payoff');
    set( gca, 'FontName', 'Helvetica');
    %set( hTitle                    , ...
    %   'FontSize'   , 12          , ...
    %  'FontWeight' , 'bold'      );
    set(gca, ...
        'Box'         , 'on'     , ...
        'TickDir'     , 'out'     , ...
        'TickLength'  , [.02 .02] , ...
        'XMinorTick'  , 'on'      , ...
        'YMinorTick'  , 'on'      , ...
        'YGrid'       , 'on'      , ...
        'XGrid'       , 'on'      , ...
        'XColor'      , [.3 .3 .3], ...
        'YColor'      , [.3 .3 .3], ...
        'LineWidth'   , 1         );
    
end
%GUI3('addition_Callback',hObject,eventdata,guidata(hObject));
% hObject    handle to red_plot (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on selection change in addition.
function addition_Callback(hObject, eventdata, handles)
val = get(hObject,'Value');
string_list = get(hObject,'String');
option = string_list{val};
st = 0:0.1:200;
delete(handles.blackline);
if strcmp(option,'Off')
    handles.blackline = plot(0,0);
    guidata(hObject, handles);
elseif strcmp(option,'Add All')
    if strcmp(handles.redoption,'Off')
        y1 = 0;
    else
        y1 = testfunc(handles.redoption, handles.redsl, handles.redk, st) + handles.redX;
    end
    
    if strcmp(handles.greenoption,'Off')
        y2 = 0;
    else
        y2 =testfunc(handles.greenoption, handles.greensl, handles.greenk, st) + handles.greenX;
    end
    
    if strcmp(handles.blueoption,'Off')
        y3 = 0;
    else
        y3 =testfunc(handles.blueoption, handles.bluesl, handles.bluek, st) + handles.blueX;
    end
    
    if strcmp(handles.yellowoption,'Off')
        y4 = 0;
    else
        y4 = testfunc(handles.yellowoption, handles.yellowsl, handles.yellowk, st) + handles.yellowX;
    end
    
    y = y1+y2+y3+y4;
    
    handles.blackline = line(st,y,'color','black','linewidth',3);
    guidata(hObject, handles);
    
    hold on
    axis manual;
    axis on;
    axis([0 200 -100 100]);
    %hTitle  = title ('PayOff Graph');
    hXLabel = xlabel('St');
    hYLabel = ylabel('Payoff');
    set( gca, 'FontName', 'Helvetica');
    %set( hTitle                    , ...
    %   'FontSize'   , 12          , ...
    %  'FontWeight' , 'bold'      );
    set(gca, ...
        'Box'         , 'on'     , ...
        'TickDir'     , 'out'     , ...
        'TickLength'  , [.02 .02] , ...
        'XMinorTick'  , 'on'      , ...
        'YMinorTick'  , 'on'      , ...
        'YGrid'       , 'on'      , ...
        'XGrid'       , 'on'      , ...
        'XColor'      , [.3 .3 .3], ...
        'YColor'      , [.3 .3 .3], ...
        'LineWidth'   , 1         );
    
    
    
end
%guidata(hObject, handles)

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

% Hints: contents = cellstr(get(hObject,'String')) returns addition contents as cell array
%        contents{get(hObject,'Value')} returns selected item from addition


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

% Hint: popupmenu 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 edit27_Callback(hObject, eventdata, handles)
% hObject    handle to edit27 (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 edit27 as text
%        str2double(get(hObject,'String')) returns contents of edit27 as a double


% --- Executes during object creation, after setting all properties.
function edit27_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit27 (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 edit28_Callback(hObject, eventdata, handles)
% hObject    handle to edit28 (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 edit28 as text
%        str2double(get(hObject,'String')) returns contents of edit28 as a double


% --- Executes during object creation, after setting all properties.
function edit28_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit28 (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 edit29_Callback(hObject, eventdata, handles)
% hObject    handle to edit29 (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 edit29 as text
%        str2double(get(hObject,'String')) returns contents of edit29 as a double


% --- Executes during object creation, after setting all properties.
function edit29_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit29 (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 edit30_Callback(hObject, eventdata, handles)
% hObject    handle to edit30 (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 edit30 as text
%        str2double(get(hObject,'String')) returns contents of edit30 as a double


% --- Executes during object creation, after setting all properties.
function edit30_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit30 (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 edit31_Callback(hObject, eventdata, handles)
% hObject    handle to edit31 (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 edit31 as text
%        str2double(get(hObject,'String')) returns contents of edit31 as a double


% --- Executes during object creation, after setting all properties.
function edit31_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit31 (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 edit32_Callback(hObject, eventdata, handles)
% hObject    handle to edit32 (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 edit32 as text
%        str2double(get(hObject,'String')) returns contents of edit32 as a double


% --- Executes during object creation, after setting all properties.
function edit32_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit32 (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 edit21_Callback(hObject, eventdata, handles)
% hObject    handle to edit21 (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 edit21 as text
%        str2double(get(hObject,'String')) returns contents of edit21 as a double


% --- Executes during object creation, after setting all properties.
function edit21_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit21 (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 edit22_Callback(hObject, eventdata, handles)
% hObject    handle to edit22 (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 edit22 as text
%        str2double(get(hObject,'String')) returns contents of edit22 as a double


% --- Executes during object creation, after setting all properties.
function edit22_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit22 (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 edit23_Callback(hObject, eventdata, handles)
% hObject    handle to edit23 (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 edit23 as text
%        str2double(get(hObject,'String')) returns contents of edit23 as a double


% --- Executes during object creation, after setting all properties.
function edit23_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit23 (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 edit24_Callback(hObject, eventdata, handles)
% hObject    handle to edit24 (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 edit24 as text
%        str2double(get(hObject,'String')) returns contents of edit24 as a double


% --- Executes during object creation, after setting all properties.
function edit24_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit24 (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 edit25_Callback(hObject, eventdata, handles)
% hObject    handle to edit25 (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 edit25 as text
%        str2double(get(hObject,'String')) returns contents of edit25 as a double


% --- Executes during object creation, after setting all properties.
function edit25_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit25 (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 edit26_Callback(hObject, eventdata, handles)
% hObject    handle to edit26 (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 edit26 as text
%        str2double(get(hObject,'String')) returns contents of edit26 as a double


% --- Executes during object creation, after setting all properties.
function edit26_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit26 (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 edit39_Callback(hObject, eventdata, handles)
% hObject    handle to edit39 (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 edit39 as text
%        str2double(get(hObject,'String')) returns contents of edit39 as a double


% --- Executes during object creation, after setting all properties.
function edit39_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit39 (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 edit40_Callback(hObject, eventdata, handles)
% hObject    handle to edit40 (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 edit40 as text
%        str2double(get(hObject,'String')) returns contents of edit40 as a double


% --- Executes during object creation, after setting all properties.
function edit40_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit40 (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 edit41_Callback(hObject, eventdata, handles)
% hObject    handle to edit41 (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 edit41 as text
%        str2double(get(hObject,'String')) returns contents of edit41 as a double


% --- Executes during object creation, after setting all properties.
function edit41_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit41 (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 edit42_Callback(hObject, eventdata, handles)
% hObject    handle to edit42 (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 edit42 as text
%        str2double(get(hObject,'String')) returns contents of edit42 as a double


% --- Executes during object creation, after setting all properties.
function edit42_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit42 (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 edit43_Callback(hObject, eventdata, handles)
% hObject    handle to edit43 (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 edit43 as text
%        str2double(get(hObject,'String')) returns contents of edit43 as a double


% --- Executes during object creation, after setting all properties.
function edit43_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit43 (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 edit44_Callback(hObject, eventdata, handles)
% hObject    handle to edit44 (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 edit44 as text
%        str2double(get(hObject,'String')) returns contents of edit44 as a double


% --- Executes during object creation, after setting all properties.
function edit44_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit44 (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 edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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 red_r_Callback(hObject, eventdata, handles)
% hObject    handle to red_r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.redr = str2double(get(hObject,'String'));
guidata(hObject, handles)

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


% --- Executes during object creation, after setting all properties.
function red_r_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_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 red_V_Callback(hObject, eventdata, handles)
% hObject    handle to red_V (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.redV = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of red_V as text
%        str2double(get(hObject,'String')) returns contents of red_V as a double


% --- Executes during object creation, after setting all properties.
function red_V_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_V (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 red_S_Callback(hObject, eventdata, handles)
% hObject    handle to red_S (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.redS = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of red_S as text
%        str2double(get(hObject,'String')) returns contents of red_S as a double


% --- Executes during object creation, after setting all properties.
function red_S_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_S (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 red_T_Callback(hObject, eventdata, handles)
% hObject    handle to red_T (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.redT = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of red_T as text
%        str2double(get(hObject,'String')) returns contents of red_T as a double


% --- Executes during object creation, after setting all properties.
function red_T_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_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 edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (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 red_calc.
function red_calc_Callback(hObject, eventdata, handles)
% hObject    handle to red_calc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[call, put] = blsprice(handles.redS, handles.redk, handles.redr, handles.redT, handles.redV, handles.redY);

out = 0;
if strcmp(handles.redoption,'Call')
    set(handles.red_Price,'String', call);
    out = call;
elseif strcmp(handles.redoption,'Put')
    set(handles.red_Price,'String', put);
    out = put;
else
    set(handles.red_Price,'String', 0);
    out = 0;
end

handles.redPrice = out;
guidata(hObject, handles)



function red_Y_Callback(hObject, eventdata, handles)
% hObject    handle to red_Y (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.redY = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of red_Y as text
%        str2double(get(hObject,'String')) returns contents of red_Y as a double


% --- Executes during object creation, after setting all properties.
function red_Y_CreateFcn(hObject, eventdata, handles)
% hObject    handle to red_Y (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 green_r_Callback(hObject, eventdata, handles)
% hObject    handle to green_r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.greenr = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of green_r as text
%        str2double(get(hObject,'String')) returns contents of green_r as a double


% --- Executes during object creation, after setting all properties.
function green_r_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_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 green_V_Callback(hObject, eventdata, handles)
% hObject    handle to green_V (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.greenV = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of green_V as text
%        str2double(get(hObject,'String')) returns contents of green_V as a double


% --- Executes during object creation, after setting all properties.
function green_V_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_V (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 green_S_Callback(hObject, eventdata, handles)
% hObject    handle to green_S (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.greenS = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of green_S as text
%        str2double(get(hObject,'String')) returns contents of green_S as a double


% --- Executes during object creation, after setting all properties.
function green_S_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_S (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 green_T_Callback(hObject, eventdata, handles)
% hObject    handle to green_T (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.greenT = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of green_T as text
%        str2double(get(hObject,'String')) returns contents of green_T as a double


% --- Executes during object creation, after setting all properties.
function green_T_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_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


% --- Executes on button press in green_calc.
function green_calc_Callback(hObject, eventdata, handles)
% hObject    handle to green_calc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[call, put] = blsprice(handles.greenS, handles.greenk, handles.greenr, handles.greenT, handles.greenV, handles.greenY);
out = 0;
if strcmp(handles.greenoption,'Call')
    set(handles.green_Price,'String', call);
    out = call;
elseif strcmp(handles.greenoption,'Put')
    set(handles.green_Price,'String', put);
    out = put;
else
    set(handles.green_Price,'String', 0);
    out = 0;
end

handles.greenPrice = out;
guidata(hObject, handles)


function green_Y_Callback(hObject, eventdata, handles)
% hObject    handle to green_Y (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.greenY = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of green_Y as text
%        str2double(get(hObject,'String')) returns contents of green_Y as a double


% --- Executes during object creation, after setting all properties.
function green_Y_CreateFcn(hObject, eventdata, handles)
% hObject    handle to green_Y (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 yellowr_Callback(hObject, eventdata, handles)
% hObject    handle to yellowr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.yellowr = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of yellowr as text
%        str2double(get(hObject,'String')) returns contents of yellowr as a double


% --- Executes during object creation, after setting all properties.
function yellowr_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yellowr (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 yellowV_Callback(hObject, eventdata, handles)
% hObject    handle to yellowV (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.yellowV = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of yellowV as text
%        str2double(get(hObject,'String')) returns contents of yellowV as a double


% --- Executes during object creation, after setting all properties.
function yellowV_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yellowV (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 yellowS_Callback(hObject, eventdata, handles)
% hObject    handle to yellowS (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.yellowS = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of yellowS as text
%        str2double(get(hObject,'String')) returns contents of yellowS as a double


% --- Executes during object creation, after setting all properties.
function yellowS_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yellowS (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 yellowT_Callback(hObject, eventdata, handles)
% hObject    handle to yellowT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.yellowT = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of yellowT as text
%        str2double(get(hObject,'String')) returns contents of yellowT as a double


% --- Executes during object creation, after setting all properties.
function yellowT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yellowT (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 yellow_calc.
function yellow_calc_Callback(hObject, eventdata, handles)
% hObject    handle to yellow_calc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[call, put] = blsprice(handles.yellowS, handles.yellowk, handles.yellowr, handles.yellowT, handles.yellowV, handles.yellowY);

out = 0;
if strcmp(handles.yellowoption,'Call')
    set(handles.yellow_Price,'String', call);
    out = call;
elseif strcmp(handles.yellowoption,'Put')
    set(handles.yellow_Price,'String', put);
    out = put;
else
    set(handles.yellow_Price,'String', 0);
    out = 0;
end

handles.yellowPrice = out;
guidata(hObject, handles)





function yellowY_Callback(hObject, eventdata, handles)
% hObject    handle to yellowY (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.yellowY = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of yellowY as text
%        str2double(get(hObject,'String')) returns contents of yellowY as a double


% --- Executes during object creation, after setting all properties.
function yellowY_CreateFcn(hObject, eventdata, handles)
% hObject    handle to yellowY (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 blue_r_Callback(hObject, eventdata, handles)
% hObject    handle to blue_r (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.blue_r = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of blue_r as text
%        str2double(get(hObject,'String')) returns contents of blue_r as a double


% --- Executes during object creation, after setting all properties.
function blue_r_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_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 blue_V_Callback(hObject, eventdata, handles)
% hObject    handle to blue_V (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.blue_V = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of blue_V as text
%        str2double(get(hObject,'String')) returns contents of blue_V as a double


% --- Executes during object creation, after setting all properties.
function blue_V_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_V (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 during object creation, after setting all properties.
function blue_S_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_S (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called



function blue_T_Callback(hObject, eventdata, handles)
% hObject    handle to blue_T (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.blue_T = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of blue_T as text
%        str2double(get(hObject,'String')) returns contents of blue_T as a double


% --- Executes during object creation, after setting all properties.
function blue_T_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_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


% --- Executes on button press in blue_calc.
function blue_calc_Callback(hObject, eventdata, handles)
[call, put] = blsprice(handles.blue_S, handles.bluek, handles.blue_r, handles.blue_T, handles.blue_V, handles.blue_Y);

out = 0;
if strcmp(handles.blueoption,'Call')
    set(handles.blue_Price,'String', call);
    out = call;
elseif strcmp(handles.blueoption,'Put')
    set(handles.blue_Price,'String', put);
    out = put;
else
    set(handles.blue_Price,'String', 0);
    out = 0;
end

handles.bluePrice = out;
guidata(hObject, handles)


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



function blue_Y_Callback(hObject, eventdata, handles)
% hObject    handle to blue_Y (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.blue_Y = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of blue_Y as text
%        str2double(get(hObject,'String')) returns contents of blue_Y as a double


% --- Executes during object creation, after setting all properties.
function blue_Y_CreateFcn(hObject, eventdata, handles)
% hObject    handle to blue_Y (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 blue_S_Callback(hObject, eventdata, handles)
% hObject    handle to blue_S (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.blue_S = str2double(get(hObject,'String'));
guidata(hObject, handles)
% Hints: get(hObject,'String') returns contents of blue_S as text
%        str2double(get(hObject,'String')) returns contents of blue_S as a double
