market-price-dynamics

market-price-dynamics preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Tags

colorful 

Tagged by Muhammad Taha Siddiqui 10 months ago

finances, economics 

Tagged by Edgar Kouajiep Kouega 11 months ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.3.0 • Viewed 255 times • Downloaded 6 times • Run 0 times
Download the 'market-price-dynamics' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

globals [current-price previous-price return
         current-number-asks current-number-bids order-balance order-book-balance] ; declare of global variables
breed [persons person] ; declare agent
persons-own [talk? bid? ask? volume] ; declare individual properties of the agent

to setup
  clear-all
  setup-variables ; set up the global variables used for computation
  setup-persons ; set up the agents
  reset-ticks
end 

to go
  if (ticks > 15000) [stop]
  cancel-orders ; reset the decisions
  make-decision ; create the market speakers and set their decisions
  execute-orders ; execute the orders of the speakers to compute market features
  tick
end 

to setup-variables
   set current-price initial-price
   set previous-price initial-price
   set current-number-bids 0
   set current-number-asks 0
   set return [] ;
   set order-book-balance [0];
end 

to setup-persons
  create-persons number-agents ; create a given number of persons
  ask persons [
    setxy random-xcor random-ycor
    set color green
    set shape "person"
    set talk? False
    set bid? False
    set ask? False
  ]
end 

to make-decision
  ; only a hand of people can intervene in the market
  ask n-of number-speakers persons [
  ifelse random-float 1 <= 0.5 [set talk? False] [set talk? True] ; some of them can decide to actually interve or not
  if talk? [
    set volume 1 + random (max-order-size - 1) ; only when an agent wants to participate, the agent defines the volume he wants to bid or ask
    ifelse random-float 1 <= 0.5
      [set bid? False
       set ask? True
       set color yellow] ; when an agent wants to sell ie speak on the supply side, color him in yellow
      [set bid? True
       set ask? False
       set color red] ; when an agent wants to buy ie speak on the demand side, color him in red
   ]
  ]
end 

to execute-orders
  set current-number-bids sum [volume] of persons with [bid? = True] ; compute the total of bids
  set current-number-asks sum [volume] of persons with [ask? = True] ; compute the total of asks
  set order-balance current-number-bids  - current-number-asks ; compute the spread
  set order-book-balance lput order-balance order-book-balance ; monitor all the values of spread

  set previous-price current-price
  set current-price previous-price * exp(order-balance * granularity)

  let current-return ln(current-price) - ln(previous-price) ; get the return of the stock
  set return lput current-return return  ; monitor all its values during the simulation
end 

to cancel-orders
  ask persons [
    set color green
    set talk? False
    set bid? False
    set ask? False
  ]
end 

There is only one version of this model, created 11 months ago by Edgar Kouajiep Kouega.

Attached files

File Type Description Last updated
market-price-dynamics.png preview Preview for 'market-price-dynamics' 11 months ago, by Edgar Kouajiep Kouega Download

This model does not have any ancestors.

This model does not have any descendants.