Price, Personality and Market Equilibrium

Price, Personality and Market Equilibrium preview image

1 collaborator

Default-person Hossein Sabzian (Author)

Tags

behavioral finance 

Tagged by Hossein Sabzian about 4 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 330 times • Downloaded 16 times • Run 0 times
Download the 'Price, Personality and Market Equilibrium' 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 [
personality ;Type of personality including momentum & contrarian
stock-a-list ; It gets 1 one I buy it and 0 when I sell it.
]

globals [
stock-a-price-vector
selected-stock-a-price-vector
mean-of-price-vector
mean-of-selected-price-vector
initial-stock-holders
]

to setup
ca
   random-seed Experiment-seed

   ask patches [set pcolor white ]

   create-turtles number-of-traders [ ; number-of-persons is set by a slider
      setxy random-xcor random-ycor
      set shape "person"
      personalities-distribution  ;; momentum & contrarian
      set stock-a-list [0]        ; having no stock
      set color red               ; those who have not stock are red
                                    ]

   ask n-of ((percent-of-stock-a-holder / 100) * count turtles)  turtles [   ; percent-of-stock-a-holder is set by a slider
      set stock-a-list [1]        ; having stock
      set color blue              ; those who have  stock are blue
                                   ]

   set stock-a-price-vector (list Price-of-stock-a) ; Price-of-stock-a is set by an input box

   set initial-stock-holders count turtles with [ sum stock-a-list > 0 ]
reset-ticks
end 

to go

   If ticks = time-period [stop] ;; Time period is set by an input box

  ask turtles [ personalities-distribution ] ; type of personalities (momentum or contrarian) are set here by slider

   stock-a-price-updata

   if is-evaluation-period-completed?  [
   set mean-of-selected-price-vector (mean selected-stock-a-price-vector );;;;; take the mean of vector
   ask turtles [if mean-of-selected-price-vector = indicator [ifelse random-float 1 > 0.5 [sell-stock ] [buy-stock]] ]  ;;;;;; No change in stock price
   ask turtles [ if  mean-of-selected-price-vector > indicator [act-based-on-increase]  ]                               ;;;;;;; increase of stock price
   ask turtles [if mean-of-selected-price-vector <  indicator [act-based-on-decrease]  ]                                ;;;;;;; decrease of stock price
   ]

   ask turtles [ color-updating rt random 90 lt random 90 fd random-float 1]
tick
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Helper procedures


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Setup & go procedure

to personalities-distribution
 ifelse (random-float 1 <= percent-of-momentum-personality) [set personality "MOMENTUM" ][set personality "CONTRARIAN"] ; percent-of-momentum-strategist is set by a slider
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Go procedures

to stock-a-price-updata

set stock-a-price-vector (lput Price-of-stock-a stock-a-price-vector )   ;;; Updates the vector based on current price data
set mean-of-price-vector mean(stock-a-price-vector) ;;;; Mean of price vector
set selected-stock-a-price-vector stock-a-price-vector  ;;;; save the vector in a selected vector
end 

to-report is-evaluation-period-completed?

 while [length selected-stock-a-price-vector  > evaluation-period-length ] [
 set selected-stock-a-price-vector remove-item 0 selected-stock-a-price-vector         ;;; when the vector exceeds the evaluation period length, it trims it.
  ]
report length selected-stock-a-price-vector  = evaluation-period-length
end 

to-report indicator
 report item 0 selected-stock-a-price-vector   ;; the first element of vector used for comapring with the mean.
end 

to act-based-on-increase
  ifelse personality = "MOMENTUM" [buy-stock] [sell-stock]
end 

to act-based-on-decrease
   ifelse personality = "MOMENTUM" [sell-stock] [buy-stock]
end 

to sell-stock
if sum stock-a-list > 0 [
set stock-a-list lput -1 stock-a-list
ask one-of other turtles [set stock-a-list lput 1 stock-a-list  ]
                       ]
end 

to buy-stock
set stock-a-list lput 1 stock-a-list
ask one-of other turtles with [sum stock-a-list > 0] [set stock-a-list lput -1 stock-a-list]
end 

to color-updating
  ifelse sum stock-a-list > 0 [set color blue ] [ set color red]
end 

There is only one version of this model, created about 4 years ago by Hossein Sabzian.

Attached files

File Type Description Last updated
Price, Personality and Market Equilibrium.png preview Preview for 'Price, Personality and Market Equilibrium' about 4 years ago, by Hossein Sabzian Download

This model does not have any ancestors.

This model does not have any descendants.