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
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
*/
12
int
equityfund_credit_invest_illiquids
()
13
{
14
double
request;
15
int
firm_id;
16
17
START_FUND_REQUEST_MESSAGE_LOOP
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
//}
33
FINISH_FUND_REQUEST_MESSAGE_LOOP
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
*/
44
int
equityfund_credit_collect_firm_shares
()
45
{
46
double
producers = 0;
47
double
constructors = 0;
48
49
START_FIRM_NET_PROFIT_MESSAGE_LOOP
50
51
if
(
PRINT_DEBUG_MODE
) {
52
printf(
"Equity Fund receives Firm shares. \n"
);
53
}
54
55
if
(
firm_net_profit_message
->
isconstructor
== 1) {
56
constructors +=
firm_net_profit_message
->
net_income
;
57
}
else
{
58
producers +=
firm_net_profit_message
->
net_income
;
59
}
60
FINISH_FIRM_NET_PROFIT_MESSAGE_LOOP
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
*/
75
int
equityfund_credit_collect_bank_shares
()
76
{
77
double
shares = 0;
78
79
START_BANK_NET_PROFIT_MESSAGE_LOOP
80
if
(
PRINT_DEBUG_MODE
) {
81
printf(
"Equity Fund receives Bank shares. \n"
);
82
}
83
shares +=
bank_net_profit_message
->
net_income
;
84
FINISH_BANK_NET_PROFIT_MESSAGE_LOOP
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
*/
96
int
equityfund_credit_distribute_shares
()
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);
105
add_capital_tax_message
(
DIVIDENDS_PAID
*
CAPITAL_TAX_RATE
);
106
return
0;
107
}
108
109
DIVIDENDS_PAID
=
LIQUIDITY
;
110
111
if
(
N_SHARES
> 0) {
112
per_share =
DIVIDENDS_PAID
/
N_SHARES
;
113
LIQUIDITY
-=
DIVIDENDS_PAID
;
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);
122
add_capital_tax_message
(
DIVIDENDS_PAID
*
CAPITAL_TAX_RATE
);
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
*/
134
int
equityfund_credit_compute_income_statement
()
135
{
136
DIVIDENDS_RECIEVED
=
SHARE_BANKS
+
SHARE_FIRMS
+
SHARE_CONSTRUCTION_FIRMS
;
137
DIVIDENDS_RETAINED
=
DIVIDENDS_RECIEVED
-
DIVIDENDS_PAID
;
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
*/
167
int
equityfund_credit_do_balance_sheet
()
168
{
169
EQUITY
=
LIQUIDITY
;
170
add_fund_centralbank_update_deposit_message
(
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
*/
179
int
equityfund_credit_check_tax_rate
()
180
{
181
182
START_CAPITAL_TAX_RATE_MESSAGE_LOOP
183
CAPITAL_TAX_RATE
=
capital_tax_rate_message
->
value
;
184
FINISH_CAPITAL_TAX_RATE_MESSAGE_LOOP
185
186
return
0;
/* Returning zero means the agent is not removed */
187
}
188
Generated on Tue Apr 8 2014 13:25:19 for ICEACE Model: Closed Economy by
1.8.3.1