ICEACE Model: Closed Economy
1.0.0
Design Documentation of ICEACE Model
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
IceaceModel1.0
Market_Credit
centralbank_functions_credit.c
Go to the documentation of this file.
1
#include "../header.h"
2
#include "../centralbank_agent_header.h"
3
4
/*
5
* \fn: int centralbank_set_interest_rate()
6
* \brief:
7
*/
8
int
centralbank_set_interest_rate
()
9
{
10
double
inflation, rcb, rcb_pre;
11
12
if
(
CONSUMPTION_GOODS_PRICES
[0] == 0) {
13
inflation = 0;
14
}
15
else
{
16
inflation = (
CONSUMPTION_GOODS_PRICES
[11] -
CONSUMPTION_GOODS_PRICES
[0]) /
CONSUMPTION_GOODS_PRICES
[0];
17
}
18
19
20
// Taylors Rule:
21
rcb = inflation;
22
rcb += (inflation -
INFLATION_TARGET
) * 0.5;
23
rcb -=
UNEMPLOYMENT_RATE
* 0.5;
24
25
26
/* This is added temporarily for experimentation. */
27
double
rcb_delta;
28
rcb_pre =
INTEREST_RATE
;
29
30
rcb_delta = rcb -
INTEREST_RATE
;
31
32
if
(fabs(rcb_delta) > 0.025) {
33
if
(rcb_delta > 0) {
34
rcb = rcb_pre + 0.025;
35
}
36
else
{
37
rcb = rcb_pre - 0.025;
38
}
39
}
40
if
(rcb > 0.25) {rcb = 0.25;}
41
42
/* experimentation end */
43
44
if
(rcb < 0.005){rcb = 0.005;}
45
46
47
48
INFLATION_RATE
= inflation;
49
INTEREST_RATE = rcb;
50
51
add_interest_rate_message
(INTEREST_RATE);
52
53
54
return
0;
/* Returning zero means the agent is not removed */
55
}
56
57
58
/*
59
* \fn: int centralbank_collect_interest_payments()
60
* \brief: Central Bank collects interest payments from banks.
61
*/
62
int
centralbank_collect_interest_payments
()
63
{
64
double
amount;
65
INTERESTS_ACCRUED
= 0;
66
67
//printf("Centalbank at interest paymements, pre-liquidity = %f\n", LIQUIDITY);
68
START_BANK_CENTRALBANK_INTEREST_PAYMENT_MESSAGE_LOOP
69
amount =
bank_centralbank_interest_payment_message
->
amount
;
70
INTERESTS_ACCRUED
+= amount;
71
LIQUIDITY
+= amount;
72
FINISH_BANK_CENTRALBANK_INTEREST_PAYMENT_MESSAGE_LOOP
73
74
//printf("Centalbank at interest paymements, post-liquidity = %f\n", LIQUIDITY);
75
return
0;
/* Returning zero means the agent is not removed */
76
}
77
78
/*
79
* \fn: int centralbank_process_debt_requests()
80
* \brief: Central Bank handles each bank debt request.
81
*/
82
int
centralbank_process_debt_requests
()
83
{
84
double
amount;
85
86
//printf("Centalbank at debt requests, pre-liquidity = %f\n", LIQUIDITY);
87
88
START_BANK_CENTRALBANK_DEBT_REQUEST_MESSAGE_LOOP
89
amount =
bank_centralbank_debt_request_message
->
amount
;
90
LOANS_BANKS
+= amount;
91
//LIQUIDITY -= amount;
92
FINISH_BANK_CENTRALBANK_DEBT_REQUEST_MESSAGE_LOOP
93
94
95
START_BANK_CENTRALBANK_DEBT_PAYMENT_MESSAGE_LOOP
96
amount =
bank_centralbank_debt_payment_message
->
amount
;
97
LOANS_BANKS
-= amount;
98
//LIQUIDITY += amount;
99
FINISH_BANK_CENTRALBANK_DEBT_PAYMENT_MESSAGE_LOOP
100
101
LIQUIDITY_BANKS
= 0;
102
START_BANK_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
103
LIQUIDITY_BANKS +=
bank_centralbank_update_deposit_message
->
amount
;
104
FINISH_BANK_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
105
106
//printf("Centalbank at debt requests, post-liquidity = %f\n", LIQUIDITY);
107
108
return
0;
/* Returning zero means the agent is not removed */
109
}
110
111
112
/*
113
* \fn: int centralbank_compute_income_statement()
114
* \brief: Central Bank computes the income statement.
115
* Profits are sent to the government.
116
*/
117
int
centralbank_compute_income_statement
()
118
{
119
/* No writeoff mechanism is implemneted yet.*/
120
TOTAL_WRITEOFFS
= 0;
121
122
REVENUES
=
INTERESTS_ACCRUED
;
123
TOTAL_COSTS
=
TOTAL_WRITEOFFS
;
124
NET_EARNINGS
=
REVENUES
-
TOTAL_COSTS
;
125
if
(
NET_EARNINGS
> 0) {
126
add_centralbank_government_profit_message
(
NET_EARNINGS
);
127
LIQUIDITY
-=
NET_EARNINGS
;
128
}
129
130
return
0;
/* Returning zero means the agent is not removed */
131
}
132
133
134
/*
135
* \fn: int centralbank_process_government_requests()
136
* \brief:
137
*/
138
int
centralbank_process_government_requests
()
139
{
140
double
amount;
141
142
START_GOV_CENTRALBANK_DEBT_REQUEST_MESSAGE_LOOP
143
amount =
gov_centralbank_debt_request_message
->
amount
;
144
LOANS_GOVERNMENT
+= amount;
145
//LIQUIDITY -= amount;
146
FINISH_GOV_CENTRALBANK_DEBT_REQUEST_MESSAGE_LOOP
147
148
START_GOV_CENTRALBANK_DEBT_PAYMENT_MESSAGE_LOOP
149
amount =
gov_centralbank_debt_payment_message
->
amount
;
150
LOANS_GOVERNMENT
-= amount;
151
//LIQUIDITY += amount;
152
FINISH_GOV_CENTRALBANK_DEBT_PAYMENT_MESSAGE_LOOP
153
154
LIQUIDITY_GOVERNMENT
= 0;
155
START_GOV_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
156
LIQUIDITY_GOVERNMENT =
gov_centralbank_update_deposit_message
->
amount
;
157
FINISH_GOV_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
158
159
return
0;
/* Returning zero means the agent is not removed */
160
}
161
162
163
/*
164
* \fn: int centralbank_do_balance_sheet()
165
* \brief: Central Bank does the balance sheet accounting.
166
*/
167
int
centralbank_do_balance_sheet
()
168
{
169
LIQUIDITY_EQUITYFUND
= 0;
170
START_FUND_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
171
LIQUIDITY_EQUITYFUND
=
fund_centralbank_update_deposit_message
->
amount
;
172
FINISH_FUND_CENTRALBANK_UPDATE_DEPOSIT_MESSAGE_LOOP
173
/* Equity Fund liquidity is disregarded. */
174
LIQUIDITY_EQUITYFUND = 0;
175
176
double
deposits, liabilities, loans;
177
178
loans =
LOANS_BANKS
+
LOANS_GOVERNMENT
;
179
deposits =
LIQUIDITY_BANKS
+
LIQUIDITY_GOVERNMENT
+
LIQUIDITY_EQUITYFUND
;
180
FIAT_MONEY
= loans - deposits;
181
if
(
FIAT_MONEY
< 0) {
182
LIQUIDITY
= -1 *
FIAT_MONEY
;
183
FIAT_MONEY
= 0;
184
}
185
186
liabilities =
FIAT_MONEY
+ deposits;
187
TOTAL_ASSETS
= loans +
LIQUIDITY
;
188
EQUITY
=
TOTAL_ASSETS
- liabilities;
189
190
if
(
DATA_COLLECTION_MODE
) {
191
char
* filename;
192
FILE * file1;
193
filename = malloc(100*
sizeof
(
char
));
194
filename[0]=0;
195
strcpy(filename,
"./outputs/data/CentralBank_snapshot.txt"
);
196
197
file1 = fopen(filename,
"a"
);
198
fprintf(file1,
"%d %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n"
,
IT_NO
,
INTEREST_RATE
,
INFLATION_RATE
,
REVENUES
,
TOTAL_COSTS
,
NET_EARNINGS
,
TOTAL_ASSETS
, LIQUIDITY,
LOANS_BANKS
, LOANS_GOVERNMENT,
EQUITY
,
FIAT_MONEY
,
LIQUIDITY_BANKS
,
LIQUIDITY_GOVERNMENT
, LIQUIDITY_EQUITYFUND);
199
fclose(file1);
200
free(filename);
201
}
202
203
return
0;
/* Returning zero means the agent is not removed */
204
}
205
206
207
Generated on Tue Apr 8 2014 13:25:19 for ICEACE Model: Closed Economy by
1.8.3.1