ICEACE Model: Closed Economy  1.0.0
Design Documentation of ICEACE Model
 All Data Structures Files Functions Variables Typedefs Macros Pages
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  */
9 {
10  double inflation, rcb, rcb_pre;
11 
12  if (CONSUMPTION_GOODS_PRICES[0] == 0) {
13  inflation = 0;
14  }
15  else {
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  */
63 {
64  double amount;
66 
67  //printf("Centalbank at interest paymements, pre-liquidity = %f\n", LIQUIDITY);
70  INTERESTS_ACCRUED += amount;
71  LIQUIDITY += amount;
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  */
83 {
84  double amount;
85 
86  //printf("Centalbank at debt requests, pre-liquidity = %f\n", LIQUIDITY);
87 
90  LOANS_BANKS += amount;
91  //LIQUIDITY -= amount;
93 
94 
97  LOANS_BANKS -= amount;
98  //LIQUIDITY += amount;
100 
101  LIQUIDITY_BANKS = 0;
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  */
118 {
119  /* No writeoff mechanism is implemneted yet.*/
120  TOTAL_WRITEOFFS = 0;
121 
125  if (NET_EARNINGS > 0) {
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  */
139 {
140  double amount;
141 
144  LOANS_GOVERNMENT += amount;
145  //LIQUIDITY -= amount;
147 
150  LOANS_GOVERNMENT -= amount;
151  //LIQUIDITY += amount;
153 
156  LIQUIDITY_GOVERNMENT = gov_centralbank_update_deposit_message->amount;
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  */
168 {
173  /* Equity Fund liquidity is disregarded. */
174  LIQUIDITY_EQUITYFUND = 0;
175 
176  double deposits, liabilities, loans;
177 
178  loans = LOANS_BANKS + LOANS_GOVERNMENT;
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