-
Notifications
You must be signed in to change notification settings - Fork 7
/
abmresults.m
83 lines (64 loc) · 4.75 KB
/
abmresults.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function[abmresults] = abmresults(banks,n_banks,MRR)
LA_variables = {'Number of borrowers';'Total requests';'Available reserves';'Hoarding multiplier';...
'Hoarding_LM';'Hoarding_PM';'Total loans';'Expected repayment';'Final repayment';'Reserves after repayment'};
BA_variables = {'Number of lenders';'Total requests';'Total loans';'Required repayment';'Available reserves';...
'Desired firesales';'Final firesales';'Final repayment';'Reserves after repayment'};
BS_variables = {'Cash';'External assets';'Deposits';'Capital'};
Inv_variables = {'Desired investment';'Final investment'};
for i = 1:n_banks
% Balance sheet
cash_array = [banks(i).balancesheet.assets.cash(1,1) banks(i).balancesheet.assets.cash(2:banks(i).failtime,4)'];
ea_array = [banks(i).balancesheet.assets.external_assets(1,1) banks(i).balancesheet.assets.external_assets(2:banks(i).failtime,4)'];
dep_array = [banks(i).balancesheet.liabilities.deposits(1,1) banks(i).balancesheet.liabilities.deposits(2:banks(i).failtime,2)'];
cap_array = [banks(i).balancesheet.liabilities.capital(1,1) banks(i).balancesheet.liabilities.capital(2:banks(i).failtime,4)'];
BS_array = [cash_array; ea_array; dep_array; cap_array];
abmresults(i).balancesheet = array2table(BS_array);
abmresults(i).balancesheet.Properties.RowNames = BS_variables;
% Investment
Inv_array = [banks(i).balancesheet.assets.des_investment; banks(i).balancesheet.assets.investment];
abmresults(i).investment = array2table(Inv_array);
abmresults(i).investment.Properties.RowNames = Inv_variables;
% Interbank market
lender_array = [linspace(1,length(banks(i).IBM.L_tot_requests),length(banks(i).IBM.L_tot_requests));
banks(i).IBM.NB;
banks(i).IBM.L_tot_requests;
banks(i).IBM.L_tot_loans_BH;
banks(i).IBM.L_hoardingmultiplier;
%(banks(i).balancesheet.assets.cash(1:banks(i).failtime,2).*(1-MRR))';
banks(i).IBM.L_tot_requests - banks(i).IBM.L_tot_loans_BH;
banks(i).IBM.L_tot_loans_BH - banks(i).IBM.L_tot_loans;
banks(i).IBM.L_tot_loans;
banks(i).IBM.L_tot_exp_repay;
banks(i).IBM.L_tot_repaid_loans;
banks(i).balancesheet.assets.cash(1:banks(i).failtime,3)'];
tempL = lender_array;
clearvars lender_array
lender_array = tempL(:,all(~isnan(tempL)));
clearvars tempL
if ~isempty(lender_array)
abmresults(i).interbankmarket.lenderactivity = array2table(lender_array(2:end,:));
abmresults(i).interbankmarket.lenderactivity.Properties.RowNames = LA_variables;
abmresults(i).interbankmarket.lenderactivity.Properties.VariableNames = strcat('t',strtrim(cellstr(num2str(lender_array(1,:)'))'));
end
borrower_array = [linspace(1,length(banks(i).IBM.B_tot_requests),length(banks(i).IBM.B_tot_requests))
banks(i).IBM.NL;
banks(i).IBM.B_tot_requests;
banks(i).IBM.B_tot_loans;
banks(i).IBM.B_req_tot_loanrepay;
(banks(i).balancesheet.assets.cash(1:banks(i).failtime,2).*(1-MRR))';
banks(i).firesales.tot_des_FS;
banks(i).firesales.final_firesales;
banks(i).IBM.B_fin_tot_loanrepay
banks(i).balancesheet.assets.cash(1:banks(i).failtime,3)'];
tempB = borrower_array;
clearvars borrower_array
borrower_array = tempB(:,all(~isnan(tempB)));
clearvars tempB
if ~isempty(borrower_array)
abmresults(i).interbankmarket.borroweractivity = array2table(borrower_array(2:end,:));
abmresults(i).interbankmarket.borroweractivity.Properties.RowNames = BA_variables;
abmresults(i).interbankmarket.borroweractivity.Properties.VariableNames = strcat('t',strtrim(cellstr(num2str(borrower_array(1,:)'))'));
end
abmresults(i).failtime = banks(i).failtime;
end
end