This page was automatically generated by NetLogo 5.0.2.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.


In order for this to work, this file, your model file (fall-of-banks.nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz must all be in the same directory. (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz from the directory where you installed NetLogo.)

On some systems, you can test the applet locally on your computer before uploading it to a web server. It doesn't work on all systems, though, so if it doesn't work from your hard drive, please try uploading it to a web server.

You don't need to include everything in this file in your page. If you want, you can just take the HTML code beginning with <applet> and ending with </applet>, and paste it into any HTML file you want. It's even OK to put multiple <applet> tags on a single page.

If the NetLogoLite files and your model are in different directories, you must modify the archive= and value= lines in the HTML code to point to their actual locations. (For example, if you have multiple applets in different directories on the same web server, you may want to put a single copy of the NetLogoLite files in one central place and change the archive= lines of all the HTML files to point to that one central copy. This will save disk space for you and download time for your users.)

powered by NetLogo

view/download model file: fall-of-banks.nlogo

WHAT IS IT?

This model explains the effects of a “Ball-in” or “Bank crash” in a interconnected economy.

HOW IT WORKS

You can generate an economic systems, with random relationships between banks and companys. You can control the strong of this relationships and the size of economy, banks, and the bank in crise

HOW TO USE IT

Using the sliders, to control the strong of interconnexions between banks APALANCAMIENTO, you can control the size of bank who star the crises BANCO-QUIEBRA, and the sizes of other banks SIZE-OTHER-BANKS.

There are two sliders additionals, the slider RECOVEY show the recovery rate of banks that simulate the possibility that a bank in crises to improve their situations, the slider BANC-PANIC simulate the increasing possibility that a bank with relationship with a bank in crises to get in crises too.

The button BAL-IN simulate the effect of a bail in process (the bank is not able to pay the debts with the other banks and offer some solutions like give to them stock shares of himself), this is a risky operation and the others banks could absorb the loses or set in crises too.

The button BANK-CRASH simulate the crash of the bank who star the crises and the spread of this problem to other turtles (companys and other banks).

THINGS TO NOTICE

At the run of BANCK-CRASH, the other banks shrink in size and valor simulating the debt loses (the loans of the other banks to the bank who star the crisis can’t be payed), and the loses could star a crises in the banks too.

At the run of BAIL IN the other banks could star in crises, they could be payed by their loans to the bank who star the crises, but this pay is less valuable (stock shares are less valuable than the return of the loan), and this could star a crises too.

You can see not banking turtles (simulating no financieral companys, real state investments, …) that could star crises too in the two situations. The companys have loans wiht banks and need to renew the loans and the access to credit for improve their working process, when banks are in crises the no financieral turtles have problems to get new loans, and could star a crises too depending of the relative size of the banks who was in crises.

A mid term crises bring the company or the bank to bank-rupt and dissapear of economy (it will die).

You can see that the relative size of bank who star the crises, the financial leverage (APALANCAMIENTO) and the recovery rate of banks in crises could give more different outputs. But, when you try the model several times, in the best conditions (low financial leverage, the bank who star the crises are smaller than other banks, and big recovery rate) the crises could arrive to all the economy destroying all.

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

COPYRIGHT AND LICENSE

Copyright 2012 Jose Rodriguez

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available.

CODE

turtles-own
[
  infected?           ;; if true, the turtle is infectious
  dependence-of-1
  dependence-of-2
  dependence-of-3
  dependence-of-4
  dependence-of-5
  dependence-of-6
  dependence-of-7
  dependence-total
  dependence-of-0
  dead
  dissapear? 
economic-valor
recovering?
intrinsic
crises
employment
home-savings
origin-employment
origin-savings
]

breed [bancs banc]
breed [empresas empresa]

globals
[
  size0
  size1
  size2
  size3
  size4
  total-economy
  total-size
  time
total-intrinsic
environment
total-employment
total-savings
original-employment
original-savings
]

to setup
  clear-all
  change-environment
  setup-nodes
  setup-spatially-clustered-network
  reset-ticks
end

to change-environment
  ;; loads an image as a background from the current directory the model was launched from
   set environment "bolsa.jpg"
   import-drawing environment
end

to setup-nodes
  set-default-shape turtles "circle"
  create-bancs 5
  [
    ; for visual reasons, we don't put any nodes *too* close to the edges
    setxy (random-xcor * 0.95) (random-ycor * 0.95)
    set size0 banco-quiebra
    set size1 size-other-banks
    set size2 size-other-banks
    set size3 size-other-banks
    set size4 size-other-banks
    set total-size size0 + size1 + size2 + size3 + size4
    ask turtle 1 [set color green set size size1 set shape "coin heads" set economic-valor size1 set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor] 
    ask turtle 2 [set color green set size size2 set shape "coin heads" set economic-valor size2 set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
    ask turtle 3 [set color green set size size3 set shape "coin heads" set economic-valor size3 set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
    ask turtle 0 [set color green set size size0 set shape "coin heads" set economic-valor size0 set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
    ask turtle 4 [set color green set size size4 set shape "coin heads" set economic-valor size4 set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
  ]
  ask turtle 1 [set dependence-of-0 random-float 1 * apalancamiento * (size0 / size1) set dependence-of-2  random-float 1  * apalancamiento  * size2 / size1  set dependence-of-3  random-float 1  * apalancamiento  * size3 / size1  set dependence-of-4  random-float 1  * apalancamiento  * size4 / size1]
  ask turtle 2 [set dependence-of-0  random-float 1 * apalancamiento  * (size0 / size2) set dependence-of-1  random-float 1  * apalancamiento  * size1 / size2  set dependence-of-3  random-float 1  * apalancamiento  * size3 / size2  set dependence-of-4  random-float 1  * apalancamiento  * size4 / size2]
  ask turtle 3 [set dependence-of-0  random-float 1 * apalancamiento  * (size0 / size3) set dependence-of-2  random-float 1  * apalancamiento  * size2 / size3  set dependence-of-1  random-float 1  * apalancamiento  * size1 / size3  set dependence-of-4  random-float 1  * apalancamiento  * size4 / size3]
  ask turtle 4 [set dependence-of-0  random-float 1 * apalancamiento  * (size0 / size4) set dependence-of-2  random-float 1  * apalancamiento  * size2 / size4  set dependence-of-1  random-float 1  * apalancamiento  * size1 / size4  set dependence-of-3  random-float 1  * apalancamiento  * size3 / size4]
  ask turtle 0 [set dependence-of-4  random-float 1 * apalancamiento  * (size4 / size0) set dependence-of-2  random-float 1  * apalancamiento  * size2 / size0  set dependence-of-1  random-float 1  * apalancamiento  * size1 / size0  set dependence-of-4  random-float 1  * apalancamiento  * size4 / size0]

  


  
  create-empresas size-other-banks * 1.5  [     setxy (random-xcor * 0.95) (random-ycor * 0.95) set dependence-of-0 random-float 1 * (size0 / total-size) set dependence-of-1 random-float 1 * (size1 / total-size) set dependence-of-2 random-float 1 * (size2 / total-size)  set dependence-of-3 random-float 1 * (size3 / total-size) set dependence-of-4 random-float 1 * (size4 / total-size) set economic-valor 1 set color green set shape "factory" set size 2  set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
  create-empresas size-other-banks * 1.5  [     setxy (random-xcor * 0.95) (random-ycor * 0.95) set dependence-of-0 random-float 1 * (size0 / total-size) set dependence-of-1 random-float 1 * (size1 / total-size) set dependence-of-2 random-float 1 * (size2 / total-size)  set dependence-of-3 random-float 1 * (size3 / total-size) set dependence-of-4 random-float 1 * (size4 / total-size) set economic-valor 1 set color green set shape "logs" set size 2  set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
  create-empresas size-other-banks * 1.5  [     setxy (random-xcor * 0.95) (random-ycor * 0.95) set dependence-of-0 random-float 1 * (size0 / total-size) set dependence-of-1 random-float 1 * (size1 / total-size) set dependence-of-2 random-float 1 * (size2 / total-size)  set dependence-of-3 random-float 1 * (size3 / total-size) set dependence-of-4 random-float 1 * (size4 / total-size) set economic-valor 1 set color green set shape "food" set size 2  set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]
  create-empresas size-other-banks * 1.5  [     setxy (random-xcor * 0.95) (random-ycor * 0.95) set dependence-of-0 random-float 1 * (size0 / total-size) set dependence-of-1 random-float 1 * (size1 / total-size) set dependence-of-2 random-float 1 * (size2 / total-size)  set dependence-of-3 random-float 1 * (size3 / total-size) set dependence-of-4 random-float 1 * (size4 / total-size) set economic-valor 1 set color green set shape "building institution" set size 2  set intrinsic economic-valor set employment economic-valor set origin-employment economic-valor]  
  create-empresas size-other-banks * 3  [      setxy (random-xcor * 0.95) (random-ycor * 0.95) set dependence-of-0 random-float 1 * (size0 / total-size) set dependence-of-1 random-float 1 * (size1 / total-size) set dependence-of-2 random-float 1 * (size2 / total-size)  set dependence-of-3 random-float 1 * (size3 / total-size) set dependence-of-4 random-float 1 * (size4 / total-size) set economic-valor 1 set color green set shape "house" set size 2  set intrinsic economic-valor set home-savings economic-valor set origin-savings economic-valor]

  ask turtles [set dependence-total dependence-of-0 + dependence-of-1 + dependence-of-2 + dependence-of-3 + dependence-of-4]
  
  set total-economy sum [economic-valor] of turtles
  set total-intrinsic sum [intrinsic] of turtles
  set total-employment sum [employment] of turtles
  set total-savings sum [home-savings] of turtles
  set original-employment sum [employment] of turtles
  set original-savings sum [home-savings] of turtles
  
  ask turtle 0 [set infected? true set color red set crises 1 set label "Crises focus" set economic-valor 0]
  set time 1
  
      
  ;; Layout turtles:
  layout-circle (sort bancs) 20
  repeat 15 [do-layout]
  repeat 55 [do-layout display]
  
end

to do-layout
    repeat 1 [layout-spring empresas links 0.2 4 0.9]
    repeat 1 [layout-spring bancs links 0.2 4 0.9]
end

to setup-spatially-clustered-network

end

to bank-bail-in
  if all? turtles [crises = 0]
    [ stop ]
  spread-virus
  do-virus-checks
  tick
end

to become-infected  ;; turtle procedure

end

to spread-virus
   ask bancs [if dead > 10 [hide-turtle set dissapear? true set color black set crises 0 set employment 0]]
   ask empresas [if dead > 10 [die]]
   ask turtles [if color = red [set dead dead + 1]]
   ask bancs  [if random-float 100 < recovey and infected? = true and dead < 10 [set color yellow set infected? false set economic-valor intrinsic / 2 set recovering? true] ]
   ask bancs  [if random-float 100 < recovey and recovering? = true and dead < 10  [set color green set recovering? false set economic-valor intrinsic set recovering? true set crises 0] ]
   if ([color] of turtle 0 = red and [dead] of turtle 0 < 3) [ask bancs [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-0 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 0 = yellow ) [ask empresas [if random-float 1 < dependence-of-0  [set color yellow set infected? false  set economic-valor intrinsic / 2 ]]]
   if ([color] of turtle 0 = green) [ask empresas [if random-float 1 < dependence-of-0  [set color green set infected? false set economic-valor intrinsic set crises 0]]]   
   if ([color] of turtle 1 = red and [dead] of turtle 1 < 3) [ask bancs [if random-float 1 < dependence-of-1 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-1 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 1 = yellow) [ask empresas [if random-float 1 < dependence-of-1  [set color yellow] set infected? false  set economic-valor intrinsic / 2 ]]
   if ([color] of turtle 1 = green) [ask empresas [if random-float 1 < dependence-of-1  [set color green set infected? false set economic-valor intrinsic set crises 0]]] 
   if ([color] of turtle 2 = red and [dead] of turtle 2 < 3) [ask bancs [if random-float 2 < dependence-of-2 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-2 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 2 = yellow) [ask empresas [if random-float 1 < dependence-of-2  [set color yellow set infected? false]  set economic-valor intrinsic / 2 ]]
   if ([color] of turtle 2 = green) [ask empresas [if random-float 1 < dependence-of-2  [set color green set infected? false set economic-valor intrinsic set crises 0]]] 
   if ([color] of turtle 3 = red and [dead] of turtle 2 < 3) [ask bancs [if random-float 3 < dependence-of-3 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-3 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 3 = yellow) [ask empresas [if random-float 1 < dependence-of-3  [set color yellow set infected? false  set economic-valor intrinsic / 2 ]]]
   if ([color] of turtle 3 = green) [ask empresas [if random-float 1 < dependence-of-3  [set color green set infected? false set economic-valor intrinsic set crises 0]]] 
   if ([color] of turtle 4 = red and [dead] of turtle 3 < 3) [ask bancs [if random-float 4 < dependence-of-4 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-4 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 4 = yellow) [ask empresas [if random-float 1 < dependence-of-4  [set color yellow set infected? false  set economic-valor intrinsic / 2 ]]]
   if ([color] of turtle 4 = green) [ask empresas [if random-float 1 < dependence-of-4  [set color green set infected? false set economic-valor intrinsic set crises 0]]] 
   set total-economy sum [economic-valor] of turtles
   set total-employment sum [employment] of turtles
   set total-savings sum [home-savings] of turtles
end


to bank-crash
    if all? turtles [crises = 0]
    [ stop ]
  bank-crash-1
  if time > 3 [ 
 
   ask bancs [if dead > 5 [hide-turtle set dissapear? true set color black set crises 0 set infected? false  set employment 0]]
   ask empresas [if dead > 10 [die]]
   ask turtles [if color = red [set dead dead + 1]]
   ask bancs  [if random-float 100 < recovey and infected? = true [set color yellow set infected? false set economic-valor intrinsic / 2 set recovering? true] ]
   ask bancs  [if random-float 100 < recovey and recovering? = true [set color green set recovering? false set economic-valor intrinsic set recovering? true set crises 0 set employment origin-employment] ]
   if ([color] of turtle 1 = red) [ask bancs [if random-float 1 < dependence-of-1 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-1 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 1 = yellow) [ask empresas [if random-float 1 < dependence-of-1  [set color yellow] set infected? false  set economic-valor intrinsic / 2 set employment origin-employment / 1.5]]
   if ([color] of turtle 1 = green) [ask empresas [if random-float 1 < dependence-of-1  [set color green set infected? false set economic-valor intrinsic set crises 0 set employment origin-employment / 1.5]]] 
   if ([color] of turtle 2 = red) [ask bancs [if random-float 2 < dependence-of-2 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-2 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 2 = yellow) [ask empresas [if random-float 1 < dependence-of-2  [set color yellow set infected? false]  set economic-valor intrinsic / 2 set employment origin-employment / 1.5]]
   if ([color] of turtle 2 = green) [ask empresas [if random-float 1 < dependence-of-2  [set color green set infected? false set economic-valor intrinsic set crises 0 set employment origin-employment / 1.5]]] 
   if ([color] of turtle 3 = red) [ask bancs [if random-float 3 < dependence-of-3 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-3 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 3 = yellow) [ask empresas [if random-float 1 < dependence-of-3  [set color yellow set infected? false  set economic-valor intrinsic / 2 set employment origin-employment / 1.5]]]
   if ([color] of turtle 3 = green) [ask empresas [if random-float 1 < dependence-of-3  [set color green set infected? false set economic-valor intrinsic set crises 0 set employment origin-employment / 1.5]]] 
   if ([color] of turtle 4 = red) [ask bancs [if random-float 4 < dependence-of-4 * (1 + banc-panic / 100) [set infected? true set color red set economic-valor 0 set crises 1]] ask empresas [if random-float 1 < dependence-of-4 [set infected? true set color red set economic-valor 0 set crises 1]]]
   if ([color] of turtle 4 = yellow) [ask empresas [if random-float 1 < dependence-of-4  [set color yellow set infected? false  set economic-valor intrinsic / 2 set employment origin-employment / 1.5]]]
   if ([color] of turtle 4 = green) [ask empresas [if random-float 1 < dependence-of-4  [set color green set infected? false set economic-valor intrinsic set crises 0 set employment origin-employment]]] 
   set total-economy sum [economic-valor] of turtles 
   set total-employment sum [employment] of turtles
   set total-savings sum [home-savings] of turtles
  ]
  set time time + 1
  tick
  
end

to bank-crash-1
   if time = 1 [
     
   ask turtle 0 [die]
   ask bancs [set size size - dependence-of-0 * size0 set intrinsic intrinsic - dependence-of-0 * size0 set economic-valor economic-valor - dependence-of-0 * size0]
   ]
   if time < 4
   [
   ask empresas [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [die]]
   ask turtle 1 [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [set infected? true set color red set crises 1 set economic-valor 0 ask empresas [if random-float 1 < dependence-of-1 * (1 + banc-panic / 100) [die]]] if random-float 0.5 < dependence-of-0 * (1 + banc-panic / 100) [set color yellow set recovering? true set economic-valor intrinsic / 2 set crises 1] ]
   ask turtle 2 [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [set infected? true set color red set crises 1 set economic-valor 0 ask empresas [if random-float 1 < dependence-of-2 * (1 + banc-panic / 100) [die]]] if random-float 0.5 < dependence-of-0 * (1 + banc-panic / 100) [set color yellow set recovering? true set economic-valor intrinsic / 2 set crises 1] ]
   ask turtle 3 [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [set infected? true set color red set crises 1 set economic-valor 0 ask empresas [if random-float 1 < dependence-of-3 * (1 + banc-panic / 100) [die]]] if random-float 0.5 < dependence-of-0 * (1 + banc-panic / 100) [set color yellow set recovering? true set economic-valor intrinsic / 2 set crises 1] ]
   ask turtle 4 [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [set infected? true set color red set crises 1 set economic-valor 0 ask empresas [if random-float 1 < dependence-of-4 * (1 + banc-panic / 100) [die]]] if random-float 0.5 < dependence-of-0 * (1 + banc-panic / 100) [set color yellow set recovering? true set economic-valor intrinsic / 2 set crises 1] ]
   set total-economy sum [economic-valor] of turtles
   ]
end

to do-test-0
 ask turtles [if random-float 1 < dependence-of-0 * (1 + banc-panic / 100) [set infected? true set color red]]
end

to do-virus-checks

end


; Copyright 2012 Jose Rodriguez.
; See Info tab for full copyright and license.