Interbank Contagion

Interbank Contagion preview image

1 collaborator

Default-person Amy Costa (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.1.0 • Viewed 235 times • Downloaded 18 times • Run 0 times
Download the 'Interbank Contagion' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own [assets pmt BOL]
links-own [SOD]

;;;;;;;;;;;;;;;;;;;
;; INITIAL SETUP ;;
;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  create-turtles 100 [set color green set shape "circle"]
  layout-circle turtles 15
  MakeLinks
  InitiateVariables
  reset-ticks
end 

to MakeLinks
  ; Asks turtles to create out-links to other turtles.
  ; The number of out-links created is specified by the user.
  ; The direction of the link goes to from borrower to lender.
  ask turtles [
   while [count my-out-links <  number-of-links] [
     create-link-to (one-of other turtles with [not out-link-neighbor? myself])
   ]
  ] 
end 

to InitiateVariables
  ; This sets initial values for pmt, assets, and BOL.
  ask turtles [
   ask in-link-neighbors [
     set pmt random-exponential 100
   ]
   set assets (sum [pmt] of in-link-neighbors)
   set BOL (pmt * count my-out-links)
  ]
end 

;;;;;;;;;;;;;;;;;;;
;; GO PROCEDURES ;;
;;;;;;;;;;;;;;;;;;;

to go
  UpdateVariables
  Fail
  tick
end 

to UpdateVariables
  ask turtles [
    ; If a turtle has any borrowers, it collects their payments,
    ; then adds those payments to its assets, minus what it must pay to another.
    ; If it does not, it simply saves the leftovers from making its own payment.
    ; (Recall that in-link-neighbors are borrowers, out-link-neighbors are lenders.)
    let new-assets (sum [pmt] of in-link-neighbors)
    set assets (assets + new-assets - (pmt * count my-out-links))
      
    ; Updates BOL.
    set BOL (pmt * count my-out-links)
    
    ; Links calculate SOD.
    ask my-in-links [
        ifelse ([new-assets] of end2) != 0 [
          set SOD ([pmt] of end1 / [new-assets] of end2)
        ] [set SOD 0]
  ]
  ]
end 

to Fail
  ; Turtles drop out if they are unable to pay their debts.
  ; Their borrowers are asked to link to another lender.
  ask turtles [
    if (assets - pmt) < 0 [
      ask in-link-neighbors [
        create-link-to (one-of other turtles with [not out-link-neighbor? myself])
        ]
      die
      ]
    ]
end 

There is only one version of this model, created almost 4 years ago by Amy Costa.

Attached files

File Type Description Last updated
Interbank Contagion.png preview Preview for 'Interbank Contagion' almost 4 years ago, by Amy Costa Download

This model does not have any ancestors.

This model does not have any descendants.