ICEACE Model: Closed Economy  1.0.0
Design Documentation of ICEACE Model
 All Data Structures Files Functions Variables Typedefs Macros Pages
equityfund_functions_credit.c
Go to the documentation of this file.
1 #include "../header.h"
2 #include "../equityfund_agent_header.h"
3 
4 
5 
6 
7 /*
8  * \fn: equityfund_credit_invest_illiquids()
9  * \brief: Equity Fund receives investement request. Firms send request when they need
10  * liquidity.
11  */
13 {
14  double request;
15  int firm_id;
16 
18  request = fund_request_message->amount;
19  firm_id = fund_request_message->firm_id;
20 
21  if (PRINT_DEBUG_MODE) {
22  printf("Equity Fund: Liquidity = %f, Liquidity request = %f from Firm ID = %d. \n",LIQUIDITY, request, firm_id);
23  }
24 
25  //if (request <= DIVIDENDS_RECIEVED - FIRM_INVESTMENT ) {
26  add_fund_request_ack_message(firm_id, request);
27  if (PRINT_DEBUG_MODE) {
28  printf("Firm ID = %d receives investment from Equity Fund. \n", firm_id);
29  }
30  LIQUIDITY -= request;
31  FIRM_INVESTMENT += request;
32  //}
34  return 0; /* Returning zero means the agent is not removed */
35 }
36 
37 
38 
39 /*
40  * \fn: int equityfund_credit_collect_firm_shares()
41  * \brief: Within this implementation the equity fund receives all of net income
42  * to be distributed equally to households.
43  */
45 {
46  double producers = 0;
47  double constructors = 0;
48 
50 
51  if (PRINT_DEBUG_MODE) {
52  printf("Equity Fund receives Firm shares. \n");
53  }
54 
56  constructors += firm_net_profit_message->net_income;
57  } else {
58  producers += firm_net_profit_message->net_income;
59  }
61 
62  SHARE_FIRMS += producers;
63  SHARE_CONSTRUCTION_FIRMS += constructors;
64  LIQUIDITY += producers + constructors;
65 
66  return 0; /* Returning zero means the agent is not removed */
67 }
68 
69 
70 /*
71  * \fn: int equityfund_credit_collect_bank_shares()
72  * \brief: Within this implementation the equity fund receives all of net income
73  * to be distributed equally to households.
74  */
76 {
77  double shares = 0;
78 
80  if (PRINT_DEBUG_MODE) {
81  printf("Equity Fund receives Bank shares. \n");
82  }
85 
86  SHARE_BANKS += shares;
87  LIQUIDITY += shares;
88 
89  return 0; /* Returning zero means the agent is not removed */
90 }
91 
92 /*
93  * \fn: int equityfund_credit_distribute_shares()
94  * \brief:Equity fund sends out shares to households.
95  */
97 {
98  double per_share = 0;
99 
100  //DIVIDENDS_PAID = DIVIDENDS_RECIEVED - DIVIDENDS_RETAINED;
101 
102  if (LIQUIDITY <= 0 ) {
103  DIVIDENDS_PAID = 0;
104  add_household_share_message(per_share);
106  return 0;
107  }
108 
110 
111  if (N_SHARES > 0) {
112  per_share = DIVIDENDS_PAID / N_SHARES;
114  per_share -= per_share * CAPITAL_TAX_RATE;
115  }
116  else{
117  per_share = 0;
118  DIVIDENDS_PAID = 0;
119  }
120 
121  add_household_share_message(per_share);
123  if (PRINT_DEBUG_MODE) {
124  printf("Equity Fund: Shares %d, Dividends Paid = %f, Per Share = %f \n", N_SHARES, DIVIDENDS_PAID, per_share);
125  }
126 
127  return 0; /* Returning zero means the agent is not removed */
128 }
129 
130 /*
131  * \fn: int eqyuityfund_credit_compute_income_statement()
132  * \brief: fund computes the income statement.
133  */
135 {
138  /* DIVIDENDS_PAID is computed while shares are sent to fund.
139  */
140 
141  if (DATA_COLLECTION_MODE) {
142  char * filename;
143  FILE * file1;
144  filename = malloc(100*sizeof(char));
145  filename[0]=0;
146  strcpy(filename, "./outputs/data/EquityFund_snapshot.txt");
147 
148  file1 = fopen(filename,"a");
149  fprintf(file1,"%d %f %f %f %f %f %f %f\n",IT_NO, DIVIDENDS_RECIEVED, DIVIDENDS_PAID, SHARE_FIRMS, SHARE_CONSTRUCTION_FIRMS, SHARE_BANKS, DIVIDENDS_RETAINED, LIQUIDITY);
150  fclose(file1);
151  free(filename);
152  }
153 
154  SHARE_CONSTRUCTION_FIRMS = 0;
155  SHARE_FIRMS = 0;
156  SHARE_BANKS = 0;
157  FIRM_INVESTMENT = 0;
158 
159  return 0; /* Returning zero means the agent is not removed */
160 }
161 
162 
163 /*
164  * \fn: int equityfund_credit_do_balance_sheet()
165  * \brief: Equity Fund does the balance sheet accounting.
166  */
168 {
169  EQUITY = LIQUIDITY ;
171  return 0; /* Returning zero means the agent is not removed */
172 }
173 
174 
175 /*
176  * \fn: int equityfund_credit_check_tax_rate()
177  * \brief: Received from the government.
178  */
180 {
181 
185 
186  return 0; /* Returning zero means the agent is not removed */
187 }
188