Function Varargout = Lmmpricing(Varargin)

Function Varargout = Lmmpricing(Varargin)

<p>function varargout = LMMpricing(varargin) % LMMPRICING M-file for LMMpricing.fig % LMMPRICING, by itself, creates a new LMMPRICING or raises the existing % singleton*. % % H = LMMPRICING returns the handle to a new LMMPRICING or the handle to % the existing singleton*. % % LMMPRICING('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in LMMPRICING.M with the given input arguments. % % LMMPRICING('Property','Value',...) creates a new LMMPRICING or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before LMMpricing_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to LMMpricing_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</p><p>% Edit the above text to modify the response to help LMMpricing</p><p>% Last Modified by GUIDE v2.5 23-Jun-2010 18:19:38</p><p>% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @LMMpricing_OpeningFcn, ... 'gui_OutputFcn', @LMMpricing_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</p><p>% --- Executes just before LMMpricing is made visible. function LMMpricing_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 LMMpricing (see VARARGIN)</p><p>% Choose default command line output for LMMpricing handles.output = hObject; set(handles.ratingsRef, 'Value', 5); set(handles.ratingsIns, 'Value', 2); set(handles.ratingsInv, 'Value', 4); defprobs = xlsread('DPs.xls'); s = size(defprobs); z = zeros(s(1),1); defprobs = [z defprobs]; global invOnly invOnly = 0; global hazRates hazRates = 100*defprobs(:, 2:end)./(100-cumsum(defprobs(:, 1:end-1),2)) % Update handles structure guidata(hObject, handles);</p><p>% UIWAIT makes LMMpricing wait for user response (see UIRESUME) % uiwait(handles.figure1); function rates = interpolateRates(yearlyRates, years, freq) s = size(yearlyRates); %years = size(s,2); ratings = s(1); yearlyRates = [zeros(ratings,1) yearlyRates]; rates = []; for i = 1:years deltas = (-yearlyRates(:,i) + yearlyRates(:,i+1))/freq; for j = 1:freq rates = [rates (yearlyRates(:,i) + j*deltas)]; end end</p><p>% --- Outputs from this function are returned to the command line. function varargout = LMMpricing_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)</p><p>% Get default command line output from handles structure varargout{1} = handles.output;</p><p> function edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double</p><p>% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function couponValue_Callback(hObject, eventdata, handles) % hObject handle to couponValue (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of couponValue as text % str2double(get(hObject,'String')) returns contents of couponValue as a double</p><p>% --- Executes during object creation, after setting all properties. function couponValue_CreateFcn(hObject, eventdata, handles) % hObject handle to couponValue (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double</p><p>% --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> 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)</p><p>% Hints: get(hObject,'String') returns contents of edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double</p><p>% --- 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</p><p>% 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</p><p> function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double</p><p>% --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double</p><p>% --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double</p><p>% --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of edit9 as text % str2double(get(hObject,'String')) returns contents of edit9 as a double</p><p>% --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles) % hObject handle to edit9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> 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)</p><p>% Hints: get(hObject,'String') returns contents of edit10 as text % str2double(get(hObject,'String')) returns contents of edit10 as a double</p><p>% --- 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</p><p>% 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</p><p>% --- Executes on button press in calculateButton. function calculateButton_Callback(hObject, eventdata, handles) % hObject handle to calculateButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.spread,'String','------'); pause(.1); years = round(str2num(get(handles.years, 'String'))); if years > 10 years = 10; set(handles.years, 'String', years); elseif years < 1 years = 1; set(handles.years, 'String', years); end</p><p> runs = str2num(get(handles.sims, 'String')); rhos = get(handles.corrTable, 'Data'); coupon = str2num(get(handles.couponValue, 'String'))/100; hazardRatesData = get(handles.referenceRateData, 'Data'); cdsSchedule = hazardRatesData(:,1); RRc = (get(handles.checkboxIns, 'Value'))*str2num(get(handles.rrIns, 'String'))/100; RRr = str2num(get(handles.rrRef, 'String'))/100; RRi = (get(handles.checkboxInv, 'Value'))*str2num(get(handles.rrInv, 'String'))/100; LMMorNo = get(handles.checkboxLMM, 'Value'); % if (LMMorNo == 0) % runs =1; % end couponData = get(handles.couponData, 'Data'); couponSchedule = couponData(:,1); steps = length(cdsSchedule);</p><p>% GENERATE accrued intersets between time t and t-1 for all runs randTimes = rand(runs, steps); sched = [cdsSchedule; years]; intervals = sched(2:end)- sched(1:end-1); tOfDefs = repmat(intervals',runs,1).*randTimes + repmat(cdsSchedule',runs,1); % time interval between curent time and previous % can be another distribution or simply mean uniform 0.5 for i=1:runs for j = 1:steps tDs(i,j) = timeFromCouponToDefault(tOfDefs(i,j), couponSchedule); end; end accruedInterest = tDs*coupon;</p><p>% FORWARD HAZARD RATES FOR REFERENCE hazardRatesRef = get(handles.referenceRateData, 'Data'); hazardRatesRef = hazardRatesRef(:,2)/100; volsRef = get(handles.referenceVolData, 'Data'); volsRef = volsRef(:,2)/100; lambdasRef = calc_vols(volsRef); forwardRatesRef = []; for i = 1:runs if LMMorNo forwardRatesRef = [forwardRatesRef; diag(forwards(hazardRatesRef, lambdasRef, years))']; else fprintf('turned off LMM for reference'); forwardRatesRef=[forwardRatesRef; hazardRatesRef']; end end %forwardRatesRef = mean(forwardRatesRef)</p><p>%set(handles.referenceRateData,'Data',[cdsSchedule 100*forwardRatesRef']);</p><p>% FORWARD HAZARD RATES FOR INVESTOR hazardRatesInv = get(handles.investorRateData, 'Data'); hazardRatesInv = hazardRatesInv(:,2)/100; volsInv = get(handles.investorVolData, 'Data'); volsInv = volsInv(:,2)/100; lambdasInv = calc_vols(volsInv); forwardRatesInv = []; for i = 1:runs if LMMorNo forwardRatesInv = [forwardRatesInv; diag(forwards(hazardRatesInv, lambdasInv, years))']; else fprintf('turned off LMM for investor') forwardRatesInv=[forwardRatesInv; hazardRatesInv']; end end %forwardRatesInv = mean(forwardRatesInv) %set(handles.investorRateData,'Data',[cdsSchedule 100*forwardRatesInv']);</p><p>% FORWARD HAZARD RATES FOR INSURER hazardRatesIns = get(handles.insurerRateData, 'Data'); hazardRatesIns = hazardRatesIns(:,2)/100; volsIns = get(handles.insurerVolData, 'Data'); volsIns = volsIns(:,2)/100; lambdasIns = calc_vols(volsIns); forwardRatesIns = []; for i = 1:runs if LMMorNo forwardRatesIns = [forwardRatesIns; diag(forwards(hazardRatesIns, lambdasIns, years))']; else fprintf('turned off LMM for insurer') forwardRatesIns = [forwardRatesIns; hazardRatesIns']; end end %forwardRatesIns = mean(forwardRatesIns) %set(handles.insurerRateData,'Data',[cdsSchedule 100*forwardRatesIns']);</p><p>% FORWARD RISK-FREE RATES rfRates = get(handles.rateData, 'Data'); rfRates = rfRates(:,2)/100; volRFRates = get(handles.rateVolData, 'Data'); volRFRates = volRFRates(:,2)/100; lambdasRate = calc_vols(volRFRates); forwardRFRates = []; for i = 1:runs if LMMorNo forwardRFRates = [forwardRFRates; diag(forwards(rfRates, lambdasRate, years))']; else fprintf('turned off LMM for rf rates') forwardRFRates = [forwardRFRates; rfRates']; end end %forwardRFRates = mean(forwardRFRates); %set(handles.rateData,'Data',[cdsSchedule 100*forwardRFRates']); spread = zeros(1,runs); bigEquationValues = zeros(1,runs); for i = 1:runs default_probs= zeros(steps,8); % default probabilities for this run for t=1:steps [default_probs(t,1), default_probs(t,2), default_probs(t,3), default_probs(t,4), default_probs(t,5), default_probs(t,6), default_probs(t,7), default_probs(t,8)]= joint_prob_lambda(forwardRatesRef(i, t),forwardRatesIns(i, t),forwardRatesInv(i, t),rhos); end % QUESTIONS: last parameter: time between default and last coupon % payment?? % TO DO: redo the delta_tau so that it takes a VECTOR OF TIME PERIODS % change the time periods,</p><p>% THIS SHOULD DO THE OPTIMIZATION options = optimset('LargeScale','off', 'Display', 'off'); s0 = 0; [s,fval,exitflag,output] = fminunc(@(s)bigequation(default_probs,RRr,accruedInterest(i,:), RRc,intervals,forwardRatesRef(i,:),forwardRFRates(i,:),steps(1),s,tDs(i,:), RRi),s0,options); bigEquationValues(i) = fval; spread(i) = s; end global cdsSpread cdsSpread = mean(spread); disp('MEAN OF THE BIG EQUATION :'); mean(bigEquationValues) set(handles.spread,'String',round(cdsSpread*100000)/1000);</p><p>% --- Executes on key press with focus on calculateButton and none of its controls. function calculateButton_KeyPressFcn(hObject, eventdata, handles) % hObject handle to calculateButton (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA)</p><p> function couponFreq_Callback(hObject, eventdata, handles) % hObject handle to couponFreq (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of couponFreq as text % str2double(get(hObject,'String')) returns contents of couponFreq as a double</p><p>% --- Executes during object creation, after setting all properties. function couponFreq_CreateFcn(hObject, eventdata, handles) % hObject handle to couponFreq (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> 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)</p><p>% Hints: get(hObject,'String') returns contents of edit12 as text % str2double(get(hObject,'String')) returns contents of edit12 as a double</p><p>% --- 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</p><p>% 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</p><p> function cdsFreq_Callback(hObject, eventdata, handles) % hObject handle to cdsFreq (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of cdsFreq as text % str2double(get(hObject,'String')) returns contents of cdsFreq as a double</p><p>% --- Executes during object creation, after setting all properties. function cdsFreq_CreateFcn(hObject, eventdata, handles) % hObject handle to cdsFreq (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on button press in applyButton. function applyButton_Callback(hObject, eventdata, handles) % hObject handle to applyButton (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global hazRates global invOnly set(handles.spread,'String','------'); couponFreq = str2num(get(handles.couponFreq,'String')); years = round(str2num(get(handles.years, 'String'))); if years > 10 years = 10; set(handles.years, 'String', years); elseif years < 1 years = 1; set(handles.years, 'String', years); end</p><p> coupon = str2num(get(handles.couponValue,'String')); delta = 1/couponFreq; timeData = [0:delta:years]'; set(handles.couponData,'Data',[timeData [0; coupon*ones(years*couponFreq , 1)/couponFreq]]);</p><p> cdsFreq = str2num(get(handles.cdsFreq,'String')); intRates = interpolateRates(hazRates,years, cdsFreq); delta = 1/cdsFreq; timeData = [0:delta:(years-delta)]'; insRating = get(handles.ratingsIns, 'Value'); invRating = get(handles.ratingsInv, 'Value'); refRating = get(handles.ratingsRef, 'Value');</p><p>%if invOnly == 0 set(handles.insurerRateData,'Data',[timeData intRates(insRating,:)']); set(handles.referenceRateData,'Data',[timeData intRates(refRating,:)']); %end set(handles.investorRateData,'Data',[timeData intRates(invRating,:)']); rfrates = 3*ones(years*cdsFreq ,1); set(handles.rateData,'Data',[timeData rfrates]); factr = [0:0.1:0.1*(length(timeData)-1)]';</p><p>%if invOnly == 0 set(handles.insurerVolData,'Data',[timeData 15 + factr]); set(handles.referenceVolData,'Data',[timeData 15 + factr]); %end set(handles.investorVolData,'Data',[timeData 15 + factr]);</p><p>%if invOnly == 0 % set(handles.insurerVolData,'Data',[timeData 0.1*intRates(insRating,:)']); % set(handles.referenceVolData,'Data',[timeData 0.1*intRates(refRating,:)']); % set(handles.investorVolData,'Data',[timeData 0.1*intRates(invRating,:)']); %end</p><p>%set(handles.rateVolData,'Data',[timeData 0.05*rfrates]); set(handles.rateVolData,'Data',[timeData 9 + factr]); set(handles.corrTable,'Data',[1 0.3 0.2; 0.3 1 0.01; 0.2 0.01 1]); set(handles.calculateButton,'Enable','on');</p><p> function principal_Callback(hObject, eventdata, handles) % hObject handle to principal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of principal as text % str2double(get(hObject,'String')) returns contents of principal as a double</p><p>% --- Executes during object creation, after setting all properties. function principal_CreateFcn(hObject, eventdata, handles) % hObject handle to principal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function years_Callback(hObject, eventdata, handles) % hObject handle to years (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of years as text % str2double(get(hObject,'String')) returns contents of years as a double</p><p>% --- Executes during object creation, after setting all properties. function years_CreateFcn(hObject, eventdata, handles) % hObject handle to years (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function sims_Callback(hObject, eventdata, handles) % hObject handle to sims (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of sims as text % str2double(get(hObject,'String')) returns contents of sims as a double</p><p>% --- Executes during object creation, after setting all properties. function sims_CreateFcn(hObject, eventdata, handles) % hObject handle to sims (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function rrRef_Callback(hObject, eventdata, handles) % hObject handle to rrRef (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of rrRef as text % str2double(get(hObject,'String')) returns contents of rrRef as a double</p><p>% --- Executes during object creation, after setting all properties. function rrRef_CreateFcn(hObject, eventdata, handles) % hObject handle to rrRef (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function rrIns_Callback(hObject, eventdata, handles) % hObject handle to rrIns (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of rrIns as text % str2double(get(hObject,'String')) returns contents of rrIns as a double</p><p>% --- Executes during object creation, after setting all properties. function rrIns_CreateFcn(hObject, eventdata, handles) % hObject handle to rrIns (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p> function rrInv_Callback(hObject, eventdata, handles) % hObject handle to rrInv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: get(hObject,'String') returns contents of rrInv as text % str2double(get(hObject,'String')) returns contents of rrInv as a double</p><p>% --- Executes during object creation, after setting all properties. function rrInv_CreateFcn(hObject, eventdata, handles) % hObject handle to rrInv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on button press in checkboxIns. function checkboxIns_Callback(hObject, eventdata, handles) % hObject handle to checkboxIns (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % handles structure with handles and user data (see GUIDATA) val = get(handles.checkboxIns, 'Value'); if val > 0 set(handles.rrIns,'Visible','on'); set(handles.text14,'Visible','on'); else set(handles.rrIns,'Visible','off'); set(handles.text14,'Visible','off'); end</p><p>% Hint: get(hObject,'Value') returns toggle state of checkboxIns</p><p>% --- Executes on button press in checkboxInv. function checkboxInv_Callback(hObject, eventdata, handles) % hObject handle to checkboxInv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) val = get(handles.checkboxInv, 'Value'); set(handles.ratingsRef,'String', ['AAaa'; 'Awsd' ]); if val > 0 set(handles.rrInv,'Visible','on'); set(handles.text19,'Visible','on'); else set(handles.rrInv,'Visible','off'); set(handles.text19,'Visible','off'); end</p><p>% Hint: get(hObject,'Value') returns toggle state of checkboxInv</p><p>% --- If Enable == 'on', executes on mouse press in 5 pixel border. % --- Otherwise, executes on mouse press in 5 pixel border or over checkboxInv. function checkboxInv_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to checkboxInv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% --- Executes on selection change in popupmenu3. function popupmenu3_Callback(hObject, eventdata, handles) % hObject handle to popupmenu3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu3</p><p>% --- Executes during object creation, after setting all properties. function popupmenu3_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on selection change in ratingsRef. function ratingsRef_Callback(hObject, eventdata, handles) % hObject handle to ratingsRef (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: contents = get(hObject,'String') returns ratingsRef contents as cell array % contents{get(hObject,'Value')} returns selected item from ratingsRef</p><p>% --- Executes during object creation, after setting all properties. function ratingsRef_CreateFcn(hObject, eventdata, handles) % hObject handle to ratingsRef (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on selection change in popupmenu2. function popupmenu2_Callback(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu2</p><p>% --- Executes during object creation, after setting all properties. function popupmenu2_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on selection change in ratingsIns. function ratingsIns_Callback(hObject, eventdata, handles) % hObject handle to ratingsIns (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: contents = get(hObject,'String') returns ratingsIns contents as cell array % contents{get(hObject,'Value')} returns selected item from ratingsIns</p><p>% --- Executes during object creation, after setting all properties. function ratingsIns_CreateFcn(hObject, eventdata, handles) % hObject handle to ratingsIns (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on button press in checkboxLMM. function checkboxLMM_Callback(hObject, eventdata, handles) % hObject handle to checkboxLMM (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hint: get(hObject,'Value') returns toggle state of checkboxLMM</p><p>% --- Executes on selection change in ratingsInv. function ratingsInv_Callback(hObject, eventdata, handles) % hObject handle to ratingsInv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hints: contents = get(hObject,'String') returns ratingsInv contents as cell array % contents{get(hObject,'Value')} returns selected item from ratingsInv</p><p>% --- Executes during object creation, after setting all properties. function ratingsInv_CreateFcn(hObject, eventdata, handles) % hObject handle to ratingsInv (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called</p><p>% 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</p><p>% --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) palette = zeros(15,3); palette(1,:) = [93 138 168]; palette(2,:) = [227 38 54]; palette(3,:) = [205 38 130]; palette(4,:) = [255 191 0]; palette(5,:) = [164 198 57]; palette(6,:) = [0 0 255]; palette(7,:) = [0 128 0]; palette(8,:) = [109 53 26]; palette(9,:) = [138 43 226]; palette(10,:) = [204 0 0]; palette(11,:) = [0 0 0]; palette(12,:) = [0 66 37]; palette(13,:) = [255 167 0]; palette(14,:) = [0 250 154]; palette(15,:) = [50 20 20]; palette = palette/255; global cdsSpread; invDefOption = get(handles.radioInvDefaults, 'Value'); RROption = get(handles.radioRR, 'Value'); RRInvOption = get(handles.radioInvRR, 'Value'); yearsOption = get(handles.radioYears, 'Value'); scrsz = get(0,'ScreenSize'); h1 = figure('OuterPosition',[1 scrsz(4)/2 0.75*scrsz(3) scrsz(4)/2])</p><p>% parameters of the run ratings = get(handles.ratingsInv, 'String'); rri = horzcat('Investor RR: ', get(handles.rrInv, 'String'), '%'); if(get(handles.checkboxInv,'Value')) rrr = horzcat('Reference RR: ', get(handles.rrRef, 'String'), '%'); else rrr = horzcat('Reference RR: 0%'); end rrs = horzcat('Insurer RR:', get(handles.rrIns, 'String'), '%'); cdsfre = horzcat('CDS Frequency: ', get(handles.cdsFreq, 'String'), ''); y = horzcat('Years: ', get(handles.years, 'String')); coufre = horzcat('Coupon Frequency: ', get(handles.couponFreq, 'String')); coup = horzcat('Coupon: ', get(handles.couponValue, 'String'), '%'); irate = horzcat('Investor Rating: ', ratings{get(handles.ratingsInv, 'Value')}); srate = horzcat('Insurer Rating: ', ratings{get(handles.ratingsIns, 'Value')}); rrate = horzcat('Reference Rating: ', ratings{get(handles.ratingsRef, 'Value')}); runs = get(handles.sims, 'String'); if (invDefOption) box1text = {rri; rrr; rrs; cdsfre; y; coufre; coup; srate; rrate}; elseif (RROption) box1text = {rri; rrs; cdsfre; y; coufre; coup; srate; rrate}; elseif (RRInvOption) box1text = {rrr; rrs; cdsfre; y; coufre; coup; srate; rrate}; elseif(yearsOption) box1text = {rri; rrr; rrs; cdsfre; coufre; coup; srate; rrate}; end mTextBox = uicontrol('style','text'); set(mTextBox,'String',box1text); set(mTextBox, 'Position', [1 10 110 130]); set(mTextBox,'HorizontalAlignment','left');</p><p> if (invDefOption) for lmmCheck = 0:1 set(handles.checkboxLMM,'Value', lmmCheck); ratings = get(handles.ratingsInv, 'String'); ratingsCount = length(ratings); spreads_inv = zeros(ratingsCount,1); for i = 1:ratingsCount set(handles.ratingsInv, 'Value', i); applyButton_Callback(hObject, eventdata, handles); calculateButton_Callback(hObject, eventdata, handles); spreads_inv(i) = cdsSpread*100; end %invOnly = 0; subplot(1,2, lmmCheck + 1) ploth = plot(spreads_inv, 'o-'); set(gca,'XTick',1:ratingsCount) set(gca,'XTickLabel',ratings); set(ploth, 'Color', mod(palette(i,:),15)); if (lmmCheck) title(horzcat( 'LMM used (', runs,' runs)')); else title('Constant rates'); end end elseif (RROption) for lmmCheck = 0:1 set(handles.checkboxLMM,'Value', lmmCheck); range = 20:10:80 spreads_inv = zeros(length(range),1); for i = 1:length(range) set(handles.rrRef, 'String', num2str(range(i)));</p><p> ratings = get(handles.ratingsInv, 'String'); ratingsCount = length(ratings); spreads_inv = zeros(ratingsCount,1); for ii = 1:ratingsCount set(handles.ratingsInv, 'Value', ii); applyButton_Callback(hObject, eventdata, handles); calculateButton_Callback(hObject, eventdata, handles); spreads_inv(ii) = cdsSpread*100; end %invOnly = 0; subplot(1,2, lmmCheck + 1) hold on ploth = plot(spreads_inv, 'o-'); set(gca,'XTick',1:ratingsCount) set(gca,'XTickLabel',ratings); set(ploth, 'Color', mod(palette(i,:),15)); if (lmmCheck) title(horzcat( 'LMM used (', runs,' runs)')); else title('Constant rates'); end</p><p> end end for k = 1:length(range) labels(k,:) = ['Reference RR = ' int2str(range(k)) '%']; end legh = legend(labels); set(legh,'FontSize',7); elseif (RRInvOption) for lmmCheck = 0:1 set(handles.checkboxLMM,'Value', lmmCheck); range = 20:10:80 spreads_inv = zeros(length(range),1); for i = 1:length(range) set(handles.rrInv, 'String', num2str(range(i)));</p><p> ratings = get(handles.ratingsInv, 'String'); ratingsCount = length(ratings); spreads_inv = zeros(ratingsCount,1); for ii = 1:ratingsCount set(handles.ratingsInv, 'Value', ii); applyButton_Callback(hObject, eventdata, handles); calculateButton_Callback(hObject, eventdata, handles); spreads_inv(ii) = cdsSpread*100; end %invOnly = 0; subplot(1,2, lmmCheck + 1) hold on ploth = plot(spreads_inv, 'o-'); set(gca,'XTick',1:ratingsCount) set(gca,'XTickLabel',ratings); set(ploth, 'Color', mod(palette(i,:),15)); if (lmmCheck) title(horzcat( 'LMM used (', runs,' runs)')); else title('Constant rates'); end</p><p> end end for k = 1:length(range) labels(k,:) = ['Investor RR = ' int2str(range(k)) '%']; end legh = legend(labels); set(legh,'FontSize',7); elseif (yearsOption) for lmmCheck = 0:1 set(handles.checkboxLMM,'Value', lmmCheck); yrs = 1:8 spreads_inv = zeros(length(yrs),1); for i = 1:length(yrs) set(handles.years, 'String', num2str(yrs(i))); ratings = get(handles.ratingsInv, 'String'); ratingsCount = length(ratings); spreads_inv = zeros(ratingsCount,1); for ii = 1:ratingsCount set(handles.ratingsInv, 'Value', ii); applyButton_Callback(hObject, eventdata, handles); calculateButton_Callback(hObject, eventdata, handles); spreads_inv(ii) = cdsSpread*100; end %invOnly = 0; subplot(1,2, lmmCheck + 1) hold on ploth = plot(spreads_inv, 'o-'); set(gca,'XTick',1:ratingsCount) set(gca,'XTickLabel',ratings); set(ploth, 'Color', mod(palette(i,:),15));</p><p> if (lmmCheck) title(horzcat( 'LMM used (', runs,' runs)')); else title('Constant rates'); end end end</p><p> for k = 1:length(yrs) labels(k,:) = ['Duration = ' int2str(yrs(k)) 'yr'] end legh = legend(labels); set(legh,'FontSize',7); end a = 0;</p><p>% --- Executes on button press in radiobutton7. function radiobutton7_Callback(hObject, eventdata, handles) % hObject handle to radiobutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hint: get(hObject,'Value') returns toggle state of radiobutton7</p><p>% --- Executes on button press in radiobutton8. function radiobutton8_Callback(hObject, eventdata, handles) % hObject handle to radiobutton8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hint: get(hObject,'Value') returns toggle state of radiobutton8</p><p>% --- Executes on button press in radiobutton9. function radiobutton9_Callback(hObject, eventdata, handles) % hObject handle to radiobutton9 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)</p><p>% Hint: get(hObject,'Value') returns toggle state of radiobutton9 </p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    24 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us