ICEACE Model: Closed Economy  1.0.0
Design Documentation of ICEACE Model
 All Data Structures Files Functions Variables Typedefs Macros Pages
centralbank_functions_top.c
Go to the documentation of this file.
1 #include "header.h"
3 
4 
5 /*
6  * \fn: int centralbank_init_balancesheet()
7  * \brief:
8  */
10 {
11  double amount;
12 
13  LOANS_BANKS = 0;
17 
18 
19 
20  LIQUIDITY_BANKS = 0;
23  LIQUIDITY_BANKS += amount;
25 
28  LIQUIDITY_GOVERNMENT = amount;
30 
31 
34  LIQUIDITY_EQUITYFUND = amount;
36  /* Equity Fund liquidity is disregarded. */
38 
39  LIQUIDITY = 0;
40  EQUITY = 0;
41  LOANS_GOVERNMENT = 0;
42  TOTAL_WRITEOFFS = 0;
43 
44  double loans, deposits, liabilities;
45  loans = LOANS_BANKS + LOANS_GOVERNMENT;
46  deposits = LIQUIDITY_BANKS + LIQUIDITY_GOVERNMENT + LIQUIDITY_EQUITYFUND;
47  /* Fiat money in this case equal to firms total loans minus private sector deposits. */
48  FIAT_MONEY = loans - deposits;
49  if (FIAT_MONEY < 0) {
50  LIQUIDITY = -1 * FIAT_MONEY;
51  FIAT_MONEY = 0;
52 
53  }
54  liabilities = FIAT_MONEY + deposits;
55  TOTAL_ASSETS = loans + LIQUIDITY;
56  EQUITY = TOTAL_ASSETS - liabilities;
57 
58  return 0; /* Returning zero means the agent is not removed */
59 }
60 
61 /*
62  * \fn: int centralbank_iterate()
63  * \brief:
64  */
66 {
68  if (IT_NO == 0) {
69  char * filename;
70  FILE * file1;
71 
72  /* @/fn: centralbank_do_balance_sheet() */
73  filename = malloc(100*sizeof(char));
74  filename[0]=0;
75  strcpy(filename, "./outputs/data/CentralBank_snapshot.txt");
76  file1 = fopen(filename,"w");
77  fprintf(file1,"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\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");
78  //fprintf(file1,"%d %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);
79  fclose(file1);
80  free(filename);
81  }
82 
83  if (IT_NO == 0) {
84  char * filename;
85  FILE * file1;
86 
87  /* @/fn: () */
88  filename = malloc(40*sizeof(char));
89  filename[0]=0;
90  strcpy(filename, "./outputs/data/BankruptcyInspection.txt");
91  file1 = fopen(filename,"w");
92  fprintf(file1,"%s %s %s %s %s %s\n","IT", "ID", "Agent", "Writeoff_Type", "Bank", "Amount");
93  fclose(file1);
94  free(filename);
95  }
96  }
97 
98  IT_NO++;
99  return 0; /* Returning zero means the agent is not removed */
100 }
101 
102 
103 /*
104  * \fn: int centralbank_update_deposits()
105  * \brief:
106  */
108 {
109  double pre, post, delta_deposits;
110 
112 
113 
114  LIQUIDITY_BANKS = 0;
118 
119  LIQUIDITY_GOVERNMENT = 0;
121  LIQUIDITY_GOVERNMENT = gov_centralbank_update_deposit_message->amount;
123 
126  LIQUIDITY_EQUITYFUND = fund_centralbank_update_deposit_message->amount;
128 
129 
130  post = LIQUIDITY_BANKS + LIQUIDITY_EQUITYFUND + LIQUIDITY_GOVERNMENT;
131 
132  delta_deposits = post - pre;
133 
134  LIQUIDITY += delta_deposits;
135 
136  /* This is where Central Bank prints banknotes. */
137  if (LIQUIDITY < 0) {
139  LIQUIDITY = 0;
140  }
141 
142 
143  return 0; /* Returning zero means the agent is not removed */
144 }
145