-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mak_h_ro_0.ml3
1515 lines (1311 loc) · 70 KB
/
Mak_h_ro_0.ml3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Firm(
//Goods market
price : real := 1, //initial minimum price
targetProduction : real,
demand : real,
inventory : real := 50,
liquidity : real := 100,
turnover : real,
equity : real := 100,
debt : real,
wage : real := 2,
profitAfterTax : real,
consumptionUnit : real, //real consumption (in homogeneous good units)
consumption : real, //nominal consumption
//auxiliary variables
supply_nom : real, //nominal supply
inventory_lag : real := 50,
inventory_lag_Min : real := 50,
turnover_lag_1 : real,
turnover_lag_2 : real,
turnover_lag_3 : real,
//validation
supplyQuarterly : real,
supply_nom_lag : real,
investmentQuarterly : real,
consumptionQuarterly : real,
//Investment market
investment : real := 10, //investment amount in investment strategy
investmentConsumeUnit : real, //real investment sales (in homogeneous good units)
investmentConsume : real, //nominal investment sales
investmentAmount : real := 10, //investment amount consumed
investmentTurnover : real := 1,
investmentCosts : real,
//Credit market
depositProfit : real,
//auxiliary variables
creditSum : real, //for counter-cyclical buffer
creditSum_lag : real, //for counter-cyclical buffer
//Validation
investmentPeriod : real,
countBankruptcy : real,
investmentPool : real := 10,
interest : real,
interest_lag : real,
id : int
)
Household(
wealth : real := 2
)
Bank(
//Credit market
equity : real := 10,
liquidity : real := 10,
margin : real := 0.01,
creditDemandLeverage : real,
creditDemandSolvency : real,
riskLevel : real := 1,
//Interbank market
depositMargin : real := 0.0001,
interbankMargin : real := 0.01,
depositDemand : real,
reservesDemand : real,
basisMoney : real := 100,
reserveRequirement : real := 105,
centralLoan : real,
interbankVolume : real,
centralCosts : real,
interbankCosts : real,
interbankProfit : real,
//auxiliary variable
centralCosts_lag : real,
//Validation
profit : real,
countBankruptcy : real,
creditDefault : real,
paymentWages : real,
paymentWages_lag : real,
depositInterest_lag : real,
id : int
)
singleton Government(
debt : real,
liquidity : real,
//Validation
bailoutCheck : real
)
singleton CentralBank(
keyRate : real := 0.01,
basisMoney : real,
lendingFacility : real,
priceInflation : real,
demandInflation : real,
inflationBasis : real := 2,
//auxiliary variables
inflation_lag_4 : real := 2,
inflation_lag_3 : real := 2,
inflation_lag_2 : real := 2,
inflation_lag_1 : real := 2,
gdp : real,
gdp_lag : real,
creditGDP : real,
creditGDP_lag_1 : real,
creditGDP_lag_2 : real,
creditGDP_lag_3 : real,
creditGDP_lag_4 : real,
interbankVolume : real
)
//auxiliary agent
CreditLine(
loanLiability : real,
coupon : real,
interest : real
)
//auxiliary agent
singleton Mercury(
)
//Interlinkages
//Real economy
employer:Firm[1]<->[n]Household:employees
//Credit market
creditor:Bank[1]<->[n]CreditLine:receivables
debtor:Firm[1]<->[n]CreditLine:liabilities
//Interbank market
depositInstituteFirm:Bank[1]<->[n]Firm:depositorFirm //Firm bank account
depositInstituteHH:Bank[1]<->[n]Household:depositorHH //Household bank account
//agent size
n_F : int := 48 //Firms
n_H : int := 480 //Households
n_B : int := 12 //Banks
n_G : int := 1 //Government - Singleton
n_C : int := 1 //CentralBank - Singleton
n_CL : int := 1 //CreditLine - auxiliary agent
n_M : int := 1 //Mercury - Singleton - auxiliary agent
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//PARAMETER
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Goods market | households, firms, government
productivityBase : real //firm productivity factor
fullEmployment : real //Non-Accelerating Inflation Rate of Unemployment (NAIRU)
gamma_y : real //production change sensitivity
gamma_p : real //price change sensitivity
inventoryTarget : real //relative inventory target
zeta_h : real //sensitivity of employee hiring process
zeta_f : real //sensitivity of employee firing process
insolvencyRatio : real //maximum debt ratio
minEquityRatio : real //minimum equity ratio to have sufficient collateral for external borrowing
minEmployees : int //minimum employee size when a firm goes bankrupt
avgPrice : real //controls average (avg) price path
delta : real //global parameter
tax : real //government tax
benefit : real //unemployment benefit
//Investment cycle | firms
gamma_inv : real //investment change sensitivity
investmentDuration : real //investment loan duration
minInvestCycle : int //maximum investment frequency (in periods)
//Credit market | banks, firms, government
gamma_m : real //loan interest margin sensitivity (bank strategy)
gamma_r : real //risk level sensitivity (bank strategy)
loanDuration : real //global loan duration
ratioSolvency : real //due to Basel III - Tier-1 capital + conservation buffer
ratioLeverage : real //due to Basel III
creditTarget : real //buffer (10% from total credit creation potential)
probabilityDefault : real //set to 0.5 since expected Cashflow - debtService should be maximum = 0
inflationTarget : real //due to European Central Bank [2022]
naturalInterest : real //global interest level within Taylor rule
//Interbank market | banks, Central Bank
gamma_i : real //interbank interest change sensitivity
facilityRange : real //interest rate corridor (standing facility of Central Bank)
interbankFrequency : real //interaction frequency
fractionalReserve : real //minimum reserve requirement due to European Central Bank [2022]
//Deposit market | banks
gamma_d : real //deposit interest change sensitivity
depositBuffer : real //interest spread between lending facility and deposit interest margin
accountFluctuationHH : real //deposit change probability hurdle
hhAccountChange : real //change bank account for better conditions every 12 periods
firmAccountChange : real //change bank account for better conditions approximately every decade
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//REAL ECONOMY
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//GOODS MARKET
///////////////////////////////////////////////////////////////////////////////
//Strategy change
Firm
| true
@ ego.strategyChangeRate()
-> ego.setStrategy()
Firm.strategyChangeRate() : real :=
if ego.inventory / ego.inventoryTarget() < 1 then (1 - ego.inventory / ego.inventoryTarget()) + 1
else ego.inventory / ego.inventoryTarget()
Firm.inventoryTarget() : real :=
max((ego.averageProductionCapacity() * productivityBase - ego.production()) * inventoryTarget,1)
//////////////////////////////////////////////////////
//PRODUCTION AND FIRM STRATEGY | goods supply
/////////////////////////////////////////////////////
Firm.production() : real := ego.employees.size() * productivityBase
//Inventory update
Firm
| true
@ ego.production()
-> ego.inventory += 1
//Relation of supply and demand
Firm.demandEqualsProduction() : bool := !ego.demandGreaterThanProduction() && !ego.demandLessThanProduction()
Firm.demandGreaterThanProduction() : bool := ego.inventory / ego.inventoryTarget() <= 1
Firm.demandLessThanProduction() : bool := ego.inventory / ego.inventoryTarget() > 1
/* Behavior of firms to react on demand, which depend on price and production and vice versa.
Imitates reality due to the tendency to reach equilibrium with rarely success. */
Firm.setStrategy() ->
//demand = production && Mercury.fullyEmployed() -> no action = NAIRU
//demand > production
//full employment means higher price pressure due to limited production capacity
if (ego.demandGreaterThanProduction() && Mercury.fullyEmployed()) then
ego.price := ego.price + (gamma_p * random())
//price > average price
else if (ego.demandGreaterThanProduction() && ego.price > ?average && !Mercury.fullyEmployed()) then
ego.targetProduction := ego.production() * (1 + gamma_y * random())
//price < average
else if (ego.demandGreaterThanProduction() && ego.price <= ?average && !Mercury.fullyEmployed()) then
ego.price := ego.price + (gamma_p * random())
//demand < production
//price > average
else if (ego.demandLessThanProduction() && ego.price > ?average) then
ego.price := max(ego.price - (gamma_p * random()), ?minimumPrice)
//price < average price
else if (ego.demandLessThanProduction() && ego.price <= ?average) then
ego.targetProduction := ego.production() * (1 - gamma_y * random())
end
ego.demand := 0
where ?average := avgPrice
?minimumPrice := ego.minPrice()
//fix costs = wages; variable costs = external financing
Firm.minPrice() : real := ego.wage / productivityBase + ego.interest_lag / max(ego.production(), productivityBase)
//////////////////////////////////////////////////////
//HIRE AND FIRE | Labor market
//////////////////////////////////////////////////////
Firm //hire
| ego.laborDemand() > ego.employees.size() && ?unemployed.size() > 0
@ if ego.employees.size() = 0 then ego.laborDemand() else (ego.laborDemand() / ego.employees.size()) ^ zeta_h
-> if (?unemployed.size() > 0) then
ego.employees += [?unemployed.random()]
end
where ?unemployed := Household.all.filter(!alter.hasEmployer())
Firm //fire
| (ego.employees.size() > ego.laborDemand())
@ (ego.employees.size() / ego.laborDemand()) ^ zeta_f
-> ego.employees -= [ego.employees.random()]
Firm.laborDemand() : real := max(1, ceil((ego.targetProduction / productivityBase)))
//////////////////////////////////////////////////////
//CONSUMPTION | goods demand
//////////////////////////////////////////////////////
Household //attraction to price
| true
@ ego.wealth
-> if (?firms.size() > 0 && ego.wealth > ?firm.price) then
//transaction
ego.wealth -= ?firm.price
?firm.inventory -= 1
//accounting
?firm.turnover += ?firm.price
?firm.liquidity += ?firm.price
?firm.demand += 1
?firm.supply_nom += ?firm.price //nominal supply
?firm.supplyQuarterly += 1
?firm.consumption += ?firm.price
?firm.consumptionUnit += 1
?firm.consumptionQuarterly += ?firm.price
//payment system transaction
ego.depositInstituteHH.basisMoney -= ?firm.price * (1-delta)
?firm.depositInstituteFirm.basisMoney += ?firm.price * (1-delta)
//inflation measurement
CentralBank.demandInflation += 1
CentralBank.priceInflation += ?firm.price
end
where ?firms := Firm.all.filter(alter.inventory > 0)
?firm := ?firms.weightedRandom(Mercury.averagePrice() / alter.price)//^beta_price) // price sensitivity
//////////////////////////////////////////////////////
//BANKRUPTCY
//////////////////////////////////////////////////////
/* Solvency = outstanding debt/credits in relation to financial wealth (liquidity, equity, expected profits);
Insolvency ratio can be higher than 1. This assumption is appropriate since investments/capital are/is not posted
in the firms balance sheet. */
Firm
| ego.isBankrupt()
@ every 1
-> ego.postNonPerformingLoan()
Government.debt += ego.debt //debt depicts overdraft facility by banks
Government.bailoutCheck += ego.debt
ego.debt := 0
ego.employees := ego.employees.random(minEmployees) //firm keeps five employees due to calibration
//Validation
ego.countBankruptcy += 1
where ?unemployed := Household.all.filter(!alter.hasEmployer())
Firm.isBankrupt() : bool := ego.solvency() > insolvencyRatio
Firm.postNonPerformingLoan() ->
if ego.hasLoan() then
for each ?nonPerformingLoan in ego.liabilities
?nonPerformingLoan.creditor.equity -= ?nonPerformingLoan.loanLiability
?nonPerformingLoan.creditor.creditDefault += ?nonPerformingLoan.loanLiability //Validation
?nonPerformingLoan.die()
?nonPerformingLoan.creditor.receivables -= [?nonPerformingLoan]
ego.liabilities -= [?nonPerformingLoan]
end
end
////////////////////////////////////////////////////////////////////////////////
//INVESTMENT MARKET
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//INVESTMENT CYCLE
//////////////////////////////////////////////////////
Firm
| !ego.isBankrupt()
@ ego.investmentChangeRate()
-> //accounting
ego.investmentPool := 0
//investment cycle
ego.setInvestmentStrategy()
?financialNeed := ego.investment
?isInvestment := true
?duration := investmentDuration
ego.requestLoan(?financialNeed, ?isInvestment, ?duration)
//accounting
ego.investmentTurnover := 0
ego.investmentCosts := 0
/* Defines investment frequency
-> dependent on production capacity and solvency
-> production capacity -> average employee size within full employment sphere = Households / Firm
-> solvency -> higher solvency reduces investment rate and vice versa
-> investment rate depends on solvency corridor
-> as soon as liquidity Limit is higher than solvency threshold = invest (=expansionary investment) */
Firm.investmentChangeRate() : real :=
if ego.solvency() / ego.investmentTarget() >= 1 then (1 / (max(?procyclicalInvestmentBehavior,0.1) + ego.solvency()))
else 1 / max(?procyclicalInvestmentBehavior,0.1)
where ?procyclicalInvestmentBehavior :=
max(ego.averageProductionCapacity() * productivityBase - ego.production(), minInvestCycle)
Firm.investmentTarget() : real := max(insolvencyRatio - ego.couponInterest(),0.01) //0.01 = not to divide by zero
//Relation between interest and coupon -> indicator for interest pressure
Firm.couponInterest() : real :=
if ego.hasLoan() then
?lastInterest / max(?lastCoupon,0.001)
else 0
where ?lastInvestmentLoan := ego.liabilities.argmin(alter.age)
?lastInterest := ?lastInvestmentLoan.interest
?lastCoupon := ?lastInvestmentLoan.coupon
Firm.investmentReturn() : real := ego.investmentTurnover - ego.investmentCosts
/* Investment strategy
The higher the investment today the higher the profits in the future.
If production growth does not keep up with investment growth prices fall and investments decrease.
Investments are influenced by borrowing costs (key interest rate by Central Bank, loan interest margin,
loan capacity due to Basel III restrictions, liquidity, expected profit and
production capacity (productivity and full employment).
*/
Firm.positiveInvestmentExpectation() : bool := ego.investmentReturn() > 0
Firm.averageProductionCapacity() : real := Household.all.size() / Firm.all.size()
Firm.setInvestmentStrategy() ->
//positive outlook without liquidity limit
if (ego.positiveInvestmentExpectation() && ego.investment <= ego.liquidityLimit()) then
ego.investment := ego.investment * (1 + gamma_inv * random())
//positive outlook with liquidity limit
else if (ego.positiveInvestmentExpectation() && ego.investment > ego.liquidityLimit()) then
ego.investment := ego.liquidityLimit()
//negative outlook without liquidity limit
else if !ego.positiveInvestmentExpectation() then
ego.investment := ego.liquidityLimit()
end
//////////////////////////////////////////////////////
//INVESTMENT DEMAND
//////////////////////////////////////////////////////
Firm
| true
@ ego.investmentAmount
-> if (?firms.size() > 0 && ego.investmentAmount > ?firm.price) then
//firm accounting
?firm.investmentTurnover += ?firm.price
?firm.turnover += ?firm.price
?firm.liquidity += ?firm.price
?firm.investmentConsume += ?firm.price
?firm.investmentConsumeUnit += 1
?firm.inventory -= 1
?firm.supply_nom += ?firm.price //nominal supply
?firm.supplyQuarterly += 1
ego.investmentAmount -= ?firm.price
ego.investmentCosts += ?firm.price
//payment system transaction
ego.depositInstituteFirm.basisMoney -= ?firm.price * (1-delta)
?firm.depositInstituteFirm.basisMoney += ?firm.price * (1-delta)
//inflation measurement
CentralBank.demandInflation += 1
CentralBank.priceInflation += ?firm.price
end
where ?poolFirms := Firm.all - [ego]
?firms := ?poolFirms.filter(alter.inventory > 0)
?firm := ?firms.weightedRandom((Mercury.averagePrice() / alter.price))
//////////////////////////////////////////////////////
//ACCOUNTING
//////////////////////////////////////////////////////
Firm //Negative liquidity is balanced with bank borrowing; debt is redeemed with profit
| true
@ every 1
-> ego.payLoan()
ego.interest_lag := ego.interest
ego.interest := 0
?currentProfit := ego.turnover + (ego.inventory * ego.minPrice() - ego.inventory_lag_Min) + ego.depositProfit -
(ego.employees.size() * ego.wage + ego.interest_lag)
ego.allocateProfit(?currentProfit)
ego.payWages()
ego.inventory_lag := ego.inventory
ego.inventory_lag_Min := ego.inventory * ego.minPrice()
ego.turnover_lag_3 := ego.turnover_lag_2
ego.turnover_lag_2 := ego.turnover_lag_1
ego.turnover_lag_1 := ego.turnover
ego.turnover := 0
//validation
ego.investmentPeriod := 0
ego.investmentConsume := 1
ego.consumption := 1
ego.investmentConsumeUnit := 0
ego.consumptionUnit := 0
//General pecking order -> 1. liquidity, 2. debt, 3. equity
Firm.allocateProfit(?currentProfit : real) ->
//payTax
if ?currentProfit > 0 then
ego.liquidity -= ?currentProfit * tax
Government.liquidity += ?currentProfit * tax
?remainingProfit := ?currentProfit * (1 - tax)
ego.profitAfterTax := ?remainingProfit
//allocate
//1. liquidity -> already posted during consumption/investment
ego.liquidity -= ?remainingProfit * (1 - delta)
?remainingProfit -= ?remainingProfit * delta
//2. debt
if ego.debt > 0 then
ego.debt -= min(ego.debt, ?remainingProfit * delta)
?remainingProfit -= min(ego.debt, ?remainingProfit * delta)
end
//3. equity
ego.equity += ?remainingProfit
?remainingProfit := 0
else if ?currentProfit <= 0 then
//if negative profit = automatically substracted by liquidity
ego.profitAfterTax := ?currentProfit
end
Firm.payWages() -> for each ?employee in ego.employees
?employee.wealth += ego.wage * (1 - tax)
Government.liquidity += ego.wage * tax
//payment system transaction
ego.depositInstituteFirm.basisMoney -= ego.wage * (1 - tax) * (1-delta)
ego.depositInstituteFirm.paymentWages -= ego.wage * (1 - tax)
?employee.depositInstituteHH.basisMoney += ego.wage * (1 - tax) * (1-delta)
?employee.depositInstituteHH.paymentWages += ego.wage * (1 - tax)
end
ego.liquidity -= ego.employees.size() * ego.wage
//meet redemption rate per period
Firm.payLoan() -> for each ?creditLine in ego.liabilities
?creditLine.loanLiability -= ?creditLine.coupon + ?creditLine.interest
ego.liquidity -= ?creditLine.coupon + ?creditLine.interest
ego.interest += ?creditLine.interest
//pay interest to bank
?creditLine.creditor.liquidity += ?creditLine.interest * (1 - tax)
Government.liquidity += ?creditLine.interest * tax
//payment system transaction
ego.depositInstituteFirm.basisMoney -= ?creditLine.interest * (1 - tax) * (1-delta)
ego.depositInstituteFirm.paymentWages -= ?creditLine.interest * (1 - tax)
?creditLine.creditor.basisMoney += ?creditLine.interest * (1 - tax) * (1-delta)
?creditLine.creditor.paymentWages += ?creditLine.interest * (1 - tax)
//delete credit line
if ?creditLine.loanLiability <= 0 then
?creditLine.die()
?creditLine.creditor.receivables -= [?creditLine]
ego.liabilities -= [?creditLine]
end
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FINANCIAL SECTOR
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//CREDIT CREATION PROCESS | credit demand and supply
//////////////////////////////////////////////////////
//CREDIT DEMAND .-> ...via liquidity shortage (533 ff.) or investment behavior (338 ff.)
//Liquidity shortage
Firm //if sufficient surplus equity is available internal borrowing is conducted via credit request
| ego.financialNeed() > 0
@ instantly
-> ?financialNeed := ego.financialNeed()
?isInvestment := false
?duration := loanDuration
ego.requestLoan(?financialNeed, ?isInvestment, ?duration)
Firm.financialNeed() : real := max(0, ego.laborDemand() * ego.wage - ego.liquidity)
Firm.requestLoan(?financialNeed : real, ?isInvestment : bool, ?duration : real) ->
//split loan amount over several banks if loan amount cannot be supplied by one bank only
?candidates := Bank.all.filter(alter.creditCreationPotential()) //banks allowed to grant loan due to Basel III
?remainingLoanRequest := ?financialNeed
//check if equity can be invested -> pecking order = 1. internal funding, 2. external funding
if ?isInvestment then //liquidity shortage not financed with internal sources; equity needed for investment profits
ego.investLiquidity(?remainingLoanRequest)
ego.investEquity(?remainingLoanRequest)
end
//check if firm can supply credit -> otherwise credit rationing
while (?remainingLoanRequest > 0 && ?candidates.size() > 0) do
?bank := ?candidates.weightedRandom((Mercury.averageMargin() / alter.margin))
//measure credit demand according to law criteria (Basel III leverage/solvency) -> demand influences bank strategy
//even if bank cannot supply requested credit amount to firm, credit demand (leverage/solvency) is influential
?bank.creditDemandLeverage += ?remainingLoanRequest
?bank.creditDemandSolvency += ?remainingLoanRequest * ego.ecaiRating()
?candidates -= [?bank]
if ?bank.maximumLoanAmount(ego, ?remainingLoanRequest, ?duration) > 0 then
?creditAmount := ?bank.maximumLoanAmount(ego, ?remainingLoanRequest, ?duration)
ego.takeLoan(?creditAmount, ?bank, ?isInvestment, ?duration)
?remainingLoanRequest -= ?creditAmount
end
end
//no loan was granted
if ?remainingLoanRequest > 0 && ?isInvestment then
?financialNeed := 0 //no investment if insufficient creditworthiness
?remainingLoanRequest := 0
else if ?remainingLoanRequest > 0 && !?isInvestment then
//Firm uses overdraft facility at principal bank -> no interest charged due to simplification
ego.debt += ?remainingLoanRequest
ego.liquidity += ?remainingLoanRequest
?remainingLoanRequest := 0
?financialNeed := 0
end
//Invest liquidity surplus
Firm.investLiquidity(?remainingLoanRequest : real) ->
if ?liquiditySurplus > 0 then
ego.investmentPool += ?liquidityInvestment
ego.investmentQuarterly += ?liquidityInvestment
ego.investmentPeriod += ?liquidityInvestment
ego.investmentAmount += ?liquidityInvestment
ego.liquidity -= ?liquidityInvestment
?remainingLoanRequest -= ?liquidityInvestment
end
where ?liquiditySurplus := (ego.liquidity - ?expectedLiquidityOutflow) - max(ego.expectedCollateral() - ego.equity,1)
?liquidityInvestment := min(?liquiditySurplus,?remainingLoanRequest)
?expectedLiquidityOutflow := (ego.employees.size() * ego.wage + ego.coupon() + ego.interest()) * (1 + (1 - delta))
//(1-delta) = buffer
//Invest equity surplus
Firm.investEquity(?remainingLoanRequest : real) ->
if ?equitySurplus > 0 then
ego.investmentPool += ?equityInvestment
ego.investmentQuarterly += ?equityInvestment
ego.investmentPeriod += ?equityInvestment
ego.investmentAmount += ?equityInvestment
ego.equity -= ?equityInvestment
?remainingLoanRequest -= ?equityInvestment
end
where ?equitySurplus := (ego.equity - minEquityRatio * ego.creditAmount()) -
max((ego.expectedCollateral() - ego.liquidity),1)
?equityInvestment := min(?equitySurplus,?remainingLoanRequest)
Firm.expectedCollateral() : real := (?expectedDebtService * ((1 + ?pd) *
investmentDuration - ego.geometricParameter())) / ?pd
where ?expectedInvestment := min(ego.investment, ego.liquidityLimit())
?expectedDebtService := ?expectedInvestment * (Mercury.averageInterestOffer() + (Mercury.averageInterestOffer() *
?geometricSeries) / investmentDuration + 1) / investmentDuration
?geometricSeries := investmentDuration * (investmentDuration - 1) / 2
?pd := probabilityDefault //probability of default = 0.5
//maximum loan amount (defined by Basel III restrictions, collateral of firm and riskLevel of bank)
Bank.maximumLoanAmount(?firm : Firm, ?remainingLoanRequest : real, ?duration : real) : real :=
if min(ego.ecaiSolvency() / ?firm.ecaiRating(), ego.ecaiLeverage()) >
?firm.maximumLoan(ego, ?remainingLoanRequest, ?duration) then
?firm.maximumLoan(ego, ?remainingLoanRequest, ?duration)
else min(ego.ecaiSolvency() / ?firm.ecaiRating(),ego.ecaiLeverage())
/* define maximum loan amount of requesting Firm due to maximum available cash flow
(checks whether firm can meet credit coupon and interest liabilities) */
Firm.maximumLoan(?bank : Bank, ?remainingLoanRequest : real, ?duration : real) : real :=
if (?remainingLoanRequest <= ego.maximumLoanAmount(?bank, ?remainingLoanRequest, ?duration)) then
?remainingLoanRequest
else ego.maximumLoanAmount(?bank, ?remainingLoanRequest, ?duration)
//maximum loan amount that particular bank is willing to supply; bank picking = depends on margin; Firm.requestLoan()
Firm.maximumLoanAmount(?bank : Bank, ?remainingLoanRequest : real, ?duration : real) : real :=
((investmentDuration * ?grantedDebtService) / (?interest + (?interest * (investmentDuration *
(investmentDuration - 1) / 2) / investmentDuration + 1)))
where ?interest := ?bank.makeOffer()
?grantedDebtService := (ego.netPresentValue() + ego.probabilityDefault(?bank, ?remainingLoanRequest, ?duration) *
ego.defineCollateral(?bank, ?remainingLoanRequest, ?duration)) /
((1 + ego.probabilityDefault(?bank,?remainingLoanRequest,?duration)) * investmentDuration)
/* discounted value of loan in relation to borrowing costs
Net present value = capitalization factor via Keynes = present value in relation to opportunity costs of investment */
Firm.netPresentValue() : real :=
?expectedProfit * ego.geometricParameter()
where ?expectedProfit := max((ego.medianTurnover() + (ego.inventory * ego.minPrice() - ego.inventory_lag_Min) +
ego.depositProfit - ego.employees.size() * ego.wage - ego.interest_lag) * (1 - tax),1)
//Geometric series to calculate equally weighted redemption rate for investments = discounting parameter
Firm.geometricParameter() : real :=
(((1 + ?interestCost)^investmentDuration)-1) / (((1 + ?interestCost)^investmentDuration) * ?interestCost)
where ?interestCost := Mercury.averageInterestOffer()
//maximum amount of loan due to current net present value and average interest loan by banks
Firm.liquidityLimit() : real :=
((investmentDuration * ?granted_debtService) / (?interest + (?interest * (investmentDuration *
(investmentDuration - 1) / 2) / investmentDuration + 1)))
where ?interest := Mercury.averageInterestOffer()
?granted_debtService := ((ego.netPresentValue() + ?probabilityDefault * ego.collateralNeed()) /
((1 + ?probabilityDefault) * investmentDuration))
?probabilityDefault := probabilityDefault //0.5 because maximum possible -> debtService = expectedCashFlow
/* If collateral too low -> risk too high for bank ("blanco credit") -> maximum debt service cannot be used for credit;
Calculates needed collateral to get full possible debt service for loan redemption (included interest payments);
If firm has more collateral than needed to fulfill collateral criteria for bank then set collateral to this optimum;
Within this model: collateral is re-used since no investment assets are posted */
Firm.defineCollateral(?bank : Bank, ?remainingLoanRequest : real, ?duration : real) : real :=
if ego.collateral() * ?bank.riskLevel > ?collateralOptimum then ?collateralOptimum
else ego.collateral() * ?bank.riskLevel
//calculates needed collateral in order to get full possible debt service into loan redemption
where ?collateralOptimum := max(ego.expectedCashFlow(),1) *
((1 + ego.probabilityDefault(?bank, ?remainingLoanRequest, ?duration) * investmentDuration -
ego.geometricParameter())) / ego.probabilityDefault(?bank, ?remainingLoanRequest, ?duration)
//Average collateral needed in order to invest liquidity limit
Firm.collateralNeed() : real := if (ego.collateral() * Mercury.averageBankRiskLevel() > ego.collateralOptimum()) then
ego.collateralOptimum()
else ego.collateral() * Mercury.averageBankRiskLevel()
Firm.collateral() : real := ego.equity + ego.liquidity
Mercury.averageBankRiskLevel() : real := Bank.all.sum(alter.riskLevel) / Bank.all.size()
//calculates needed collateral in order to get full possible debt service into loan redemption
Firm.collateralOptimum() : real := (max(ego.expectedCashFlow(),1) * ((1 + ?probabilityDefault) * investmentDuration -
ego.geometricParameter())) / ?probabilityDefault
where ?probabilityDefault := probabilityDefault //0.5 = maximum possible debtService
//probability of default = the higher pd the lower the probability and vice versa
Firm.probabilityDefault(?bank : Bank, ?remainingLoanRequest : real, ?duration : real) : real :=
max(1 / (1 + exp((ego.expectedCashFlow() - ego.riskLevel(?bank) * ?debtService) / ?debtService)), probabilityDefault)
where ?debtService := ?coupon + ?interest
?coupon := ?remainingLoanRequest / ?duration
?interest := ?bank.interestRateRequest(?remainingLoanRequest, ?duration)
/* revert banks risk level due to risk logic reversion = higher risk comes along with lower debtService weight
reversion is needed, because risk level also influence collateral weight. */
Firm.riskLevel(?bank : Bank) : real := if ?bank.riskLevel > 1 then (1 - (?bank.riskLevel - 1)) else
(1 + (1 - ?bank.riskLevel))
//Expected cash flow should not be negative. Low cash flow leads to credit rationing anyway.
Firm.expectedCashFlow() : real := max((ego.medianTurnover() + ego.depositProfit -
(ego.employees.size() * ego.wage + ego.interest())) * (1-tax),0) - ego.coupon()
//Define median value of last three turnover. A median excludes extreme values in comparison to an average.
Firm.medianTurnover() : real := //max(min(a,b), min(max(a,b),c))
max(min(ego.turnover_lag_1, ego.turnover_lag_2), min(max(ego.turnover_lag_1, ego.turnover_lag_2), ego.turnover_lag_3))
//Loan process with one bank that can grant a loan within restrictions (Basel III, interest rate, firm solvency)
Firm.takeLoan(?creditAmount : real, ?bank : Bank, ?isInvestment : bool, ?duration : real) ->
//adapt demand to get only surplus demand
?bank.creditDemandLeverage -= ?creditAmount
?bank.creditDemandSolvency -= ?creditAmount * ego.ecaiRating()
//generate new auxiliary gent -> CreditLine
?CreditLine := new CreditLine()
?CreditLine.coupon := ?creditAmount / ?duration //redemption amount per period
?CreditLine.interest := ?bank.interestRate(?creditAmount, ?duration) //average interest costs per period
?CreditLine.loanLiability := ?creditAmount + (?bank.interestRate(?creditAmount, ?duration) * ?duration)
//connect bank and firm with new CreditLine
?CreditLine.creditor := ?bank
?CreditLine.debtor := ego
ego.creditSum += ?creditAmount
//loan transfer
ego.liquidity += ?creditAmount
if ?isInvestment then
ego.liquidity -= ?creditAmount
ego.investmentPool += ?creditAmount
ego.investmentAmount += ?creditAmount
ego.investmentQuarterly += ?creditAmount
ego.investmentPeriod += ?creditAmount
end
//payment system transaction
if ?bank.depositorFirm != [ego] then
?bank.basisMoney += ?creditAmount * (1-delta)
ego.depositInstituteFirm.basisMoney -= ?creditAmount * (1-delta)
end
//interest part for bank profit per period
Bank.interestRateRequest(?remainingLoanRequest : real, ?duration : real) : real :=
((?remainingLoanRequest * ego.makeOffer()) + (ego.makeOffer() * (?remainingLoanRequest / ?duration) *
(?duration * (?duration - 1) / 2))) / ?duration
//interest part for bank profit per period
Bank.interestRate(?creditAmount : real, ?duration : real) : real :=
((?creditAmount * ego.makeOffer()) + (ego.makeOffer() * (?creditAmount / ?duration) *
(?duration * (?duration - 1) / 2))) / ?duration
//The interbank rate is modeled separately. Margin is added on marginal lending facility
Bank.makeOffer() : real := CentralBank.keyRate + facilityRange + ego.margin
/* SOLVENCY
-> Risk position due to Article 112 CRR (BASEL III) -> 0.2, 0.5, 1, 1.5
-> Solvency rate distribution > 0.75, 0.75 =< x > 0.375, 0.375 =< x > 0
-> Relation between liabilities and assets */
Firm.solvency(): real := if ego.hasLoan() then
max(ego.debt + ego.liabilities.sum(alter.loanLiability), 1) / ego.totalAssets()
else max(ego.debt, 1) / ego.totalAssets()
Firm.totalAssets() : real := if ?totalAssets = 0 then 1 else ?totalAssets
where ?totalAssets := max(ego.liquidity,0) + max(ego.equity,1) + ego.expectedCashFlow()
Firm.hasLoan() : bool := if ego.liabilities != [] then true else false
//RATING (ECAI = External Credit Assessment Institution)
Firm.ecaiRating() : real := if (ego.solvency() > 1) then 1.5
else if (ego.solvency() > 0.75 && ego.solvency() <= 1) then 1
else if (ego.solvency() > 0.375 && ego.solvency() <= 0.75) then 0.5
else if (ego.solvency() <= 0.375) then 0.2
else 1
//////////////////////////////////////////////////////
//BANK STRATEGY | including Basel III restriction
//////////////////////////////////////////////////////
Bank
| true
@ ego.strategyChangeRate()
-> ego.setStrategy()
Bank.strategyChangeRate() : real := if ego.creditDemandRelation() < 1 then (1 - ego.creditDemandRelation()) + 1
else min(ego.creditDemandRelation(),2)
//define relation between current credit potential and target credit potential
Bank.creditDemandRelation() : real :=
if ego.solvencyCriticalDemand() < ego.leverageCriticalDemand() then
max(ego.ecaiSolvency() - ego.creditDemandSolvency,1) / ego.solvencyTarget()
else max(ego.ecaiLeverage() - ego.creditDemandLeverage,1) / ego.leverageTarget()
//calculate credit target/maximum credit potential + surplus demand - buffer (10% from total credit creation potential)
Bank.solvencyTarget() : real := ego.equity / ratioSolvency * creditTarget
Bank.leverageTarget() : real := ego.equity / ratioLeverage * creditTarget
Bank.equityNeed() : real := if ego.solvencyCriticalDemand() < ego.leverageCriticalDemand() then
(ego.creditDemandSolvency - (ego.ecaiSolvency() - ego.equity / ratioSolvency * creditTarget))
* ratioSolvency
else (ego.creditDemandLeverage - (ego.ecaiLeverage() - ego.equity / ratioLeverage * creditTarget))
* ratioLeverage
/* Current credit potential amount due to most important Basel III restrictions;
-> Depends on solvency of firms, profit/liquidity/solvency situation of banks */
Bank.solvencyCriticalDemand() : real := max(ego.ecaiSolvency(), 1) / max(ego.creditDemandSolvency,1)
Bank.leverageCriticalDemand() : real := max(ego.ecaiLeverage(), 1) / max(ego.creditDemandLeverage,1)
/* remaining credit creation potential due to Basel III restrictions:
-> equity in relation to total credit amount weighted by firm solvency (Firm.ecaiRating()) = min 7%
-> equity in relation to total balance sheet amount = min 3% */
Bank.ecaiSolvency() : real := ego.equity / (ratioSolvency + CentralBank.counterCyclicalBuffer()) - ego.creditECAI()
Bank.ecaiLeverage() : real := ego.equity / ratioLeverage - ?totalAssets
where ?totalAssets := ego.creditAmount() + ego.liquidity
Bank.creditCreationPotential() : bool :=
if min(ego.ecaiSolvency(), ego.ecaiLeverage()) > (ego.creditAmount() * creditTarget) &&
!Mercury.interbankCrash() then true else false
Bank.creditTarget() : real := max(Mercury.creditDemand(),1) / Bank.all.size()
Bank.creditRelation() : real := max(ego.creditAmount(),1) / (ego.creditTarget() * (1 - creditTarget))
Mercury.creditDemand() : real := CreditLine.all.sum(alter.loanLiability)
//Credit creation potential - relation of credit supply and demand
Bank.demandEqualsCreation() : bool := !ego.demandGreaterThanCreation() && !ego.demandLessThanCreation() &&
ego.creditCreationPotential()
Bank.demandGreaterThanCreation() : bool := ego.creditRelation() > 1 && ego.creditCreationPotential()
Bank.demandLessThanCreation() : bool := ego.creditRelation() < 1 && ego.creditCreationPotential()
//Bank credit strategy
Bank.setStrategy() -> if !ego.creditCreationPotential() then
ego.equity += ?availableLiquidity * (1 - creditTarget)
ego.liquidity -= ?availableLiquidity * (1 - creditTarget)
//retention of available profits due to Liquidity Coverage Ratio
else if (ego.demandGreaterThanCreation() && ego.margin <= ?average &&
ego.creditCreationPotential()) then
ego.equity += min(?availableLiquidity, max(ego.equityNeed(), 1))
ego.liquidity -= min(?availableLiquidity, max(ego.equityNeed(), 1))
ego.margin := ego.margin + gamma_m * random()
else if (ego.demandGreaterThanCreation() && ego.margin <= ?average &&
!ego.creditCreationPotential()) then
ego.equity += min(?availableLiquidity, max(ego.equityNeed(), 1))
ego.liquidity -= min(?availableLiquidity, max(ego.equityNeed(), 1))
else if (ego.demandGreaterThanCreation() && ego.margin > ?average) then
ego.equity += min(?availableLiquidity, max(ego.equityNeed(), 1))
ego.liquidity -= min(?availableLiquidity, max(ego.equityNeed(), 1))
ego.riskLevel := max(ego.riskLevel * (1 - gamma_r * random()), 0.5)
else if (ego.demandLessThanCreation() && ego.margin > ?average) then
ego.margin := max(ego.margin - gamma_m * random(), 0.001) //0.001 = minimum accepted rate
else if (ego.demandLessThanCreation() && ego.margin <= ?average) then
ego.riskLevel := min(ego.riskLevel * (1 + gamma_r * random()), 1.5)
end
ego.creditDemandLeverage := 0
ego.creditDemandSolvency := 0
where ?average := Mercury.averageMargin()
?availableLiquidity := max(ego.liquidity - ego.centralCosts_lag,0)
Firm.creditAmount() : real := if ego.hasLoan() then ego.liabilities.sum(alter.loanLiability) else 1
Firm.coupon() : real := if ego.hasLoan() then ego.liabilities.sum(alter.coupon) else 1
Firm.interest() : real := if ego.hasLoan() then ego.liabilities.sum(alter.interest) else 1
Bank.creditAmount() : real := if ego.hasReceivables() then ego.receivables.sum(alter.loanLiability) else 1
Bank.coupon() : real := if ego.hasReceivables() then ego.receivables.sum(alter.coupon) else 1
Bank.interest() : real := if ego.hasReceivables() then ego.receivables.sum(alter.interest) else 1
Bank.averageRisk() : real := ego.creditECAI() / ego.creditAmount()
Bank.solvency() : real := ego.equity / ego.creditECAI()
Bank.leverage() : real := ego.equity / ego.creditAmount() + ego.liquidity
Bank.equityRatio() : real := ego.equity / ego.creditAmount()
/* Solvency relation for risk exposure (credit amount);
Risk position due to Article 112 CRR (BASEL III) -> 0.2, 0.5, 1, 1.5 */
Bank.creditECAI() : real := if ego.hasReceivables() then
ego.receivables.sum(alter.loanLiability * alter.debtor.ecaiRating())
else 1
//////////////////////////////////////////////////////
//BANK BAILOUT
//////////////////////////////////////////////////////
Bank
| ego.isBankrupt()
@ instantly
-> if ego.equity <= 0 then
Government.debt += ego.equity * -1 + ?bailoutSum
Government.bailoutCheck += ego.equity * -1 + ?bailoutSum
ego.equity := ?bailoutSum
else if ego.liquidity <= 0 then
Government.debt += ego.liquidity * -1 + 1
Government.bailoutCheck += ego.liquidity * -1 + 1
ego.liquidity := 1 //Bank liquidity will not be negative (= no liquidity costs for banks)
end
ego.countBankruptcy += 1
where ?bailoutSum := max(?bailoutSolvency,?bailoutLeverage)
?bailoutSolvency := (1 + ego.creditECAI()) * ratioSolvency
?bailoutLeverage := (1 + ?totalAssets) * ratioLeverage
?totalAssets := ego.creditAmount() + ego.liquidity
//when loans have to be liquidated (NPL) value of collateral decrease promptly
Bank.isBankrupt() : bool := ego.equity < 0 || (ego.liquidity < 0)
////////////////////////////////////////////////////////////////////////////////
//MONETARY SYSTEM
///////////////////////////////////////////////////////////////////////////////
/* 1. Deposits flow between banks on central bank account which act as settlement institution
2. Deposits flow due to wage pay, firm investments, loans, bank account switches
3. It is assumed that banks do not have an active liquidity management. Deposit imbalances clear automatic over time.
4. Banks have to hold minimum reserves (basis money) at central banks account.
5. If outflow of deposits = reserve requirements change.
Banks need to take interbank loans in order to balance central bank account.
6. ReserveRequirement = ad hoc calculation.
Reserve period is not chosen, because no active bank liquidity management and ad hoc consumption. */
//////////////////////////////////////////////////////
//INTERBANK MARKET
//////////////////////////////////////////////////////
//Interbank strategy
Bank
| true
@ interbankFrequency
-> if ego.reservesNeed() > 0 then
?reservesNeed := ego.reservesNeed()
ego.requestInterbankLoan(?reservesNeed)
end
ego.setInterbankStrategy()
CentralBank.lendingFacility -= ego.centralLoan
ego.basisMoney -= ego.centralLoan
ego.centralLoan := 0
//Relation of reserve supply and demand
Bank.demandEqualsReserves() : bool := !ego.demandGreaterThanReserves() && !ego.demandLessThanReserves()
Bank.demandGreaterThanReserves() : bool := max(ego.reservesDemand, 1) / max(ego.reservesExcess(), 1) > 1
Bank.demandLessThanReserves() : bool := max(ego.reservesDemand, 1) / max(ego.reservesExcess(), 1) < 1
Bank.setInterbankStrategy() -> if ego.demandEqualsReserves() && ego.interbankMargin > ?average then
ego.interbankMargin := max(ego.interbankMargin - gamma_i * random(),
CentralBank.minInterbankRate())
else if ego.demandEqualsReserves() && ego.interbankMargin <= ?average then
ego.interbankMargin := min(ego.interbankMargin + gamma_i * random(),
CentralBank.maxInterbankRate())
else if ego.demandGreaterThanReserves() then
ego.interbankMargin := min(ego.interbankMargin + gamma_i * random(),
CentralBank.maxInterbankRate())
else if (ego.demandLessThanReserves()) then
ego.interbankMargin := max(ego.interbankMargin - gamma_i * random(),
CentralBank.minInterbankRate())
end
ego.reservesDemand := 0
where ?average := Bank.all.sum(alter.interbankMargin) / Bank.all.size()
/* defines interbank interest corridor set by Central Bank -> standing facilities 100 basis points
according to ECB strategy prior to financial crisis 2007/2008 facility range defines basis rate and
upper/lower bound interbank margin is not directly interlinked with key rate, because of simplicity */
CentralBank.minInterbankRate() : real := 0.0001
CentralBank.maxInterbankRate() : real := 2 * facilityRange
//combine key rate with interbank margin
Bank.keyInterRate() : real := if ego.interbankMargin > facilityRange then
CentralBank.keyRate + ego.interbankMargin
else CentralBank.keyRate - ego.interbankMargin
Bank
| true
@ every 2 //defines average deadline for holding reserves in balance according to ECB
-> ego.reserveRequirement := fractionalReserve * ego.deposits() //update reserve amount
/* expected liquidity outflow
-> wages
-> average consumption = investmentAmount / interbankFrequency
-> average loan = loan / depositor.size()
-> average firm deposit = deposits / depositor.size()
-> average household deposit = deposits / depositor.size() ego.depositorFirm.wage */
Bank.expectedReserveOutflow() : real := max(ego.paymentWages_lag,0) + ?consumption
where ?wages := (ego.depositorFirm.sum(alter.employees.size()) * 2) / max(ego.depositorFirm.size(),1) //average wages
?consumption := ?householdConsumption + ?firmConsumption
?firmConsumption := ego.depositorFirm.sum(alter.investmentAmount)
?householdConsumption := ego.depositorHH.sum(alter.wealth)
?depositSwitch := ?firmDeposits + ?householdDeposits
?firmDeposits := ego.depositsFirms() / max(ego.depositorFirm.size(),1)
?householdDeposits := ego.depositsHouseholds() / max(ego.depositorHH.size(),1)
//According to TARGET2, payments are covered by basis money
Bank
| ego.basisMoney < 0
@ interbankFrequency / 4
-> CentralBank.lendingFacility += ego.basisMoney * - 1
ego.centralLoan += ego.basisMoney * - 1
//TARGET2 intraday borrowing is free of charge
//Government.liquidity += (ego.basisMoney * - 1) * (CentralBank.keyRate + facilityRange) / interbankFrequency