A Basic Peer-Influence Model for Simulating Trader Decisions
Summary
The document presents an unfinished R simulation of traders whose buy, sell, or neutral decisions are updated using sampled decisions from other traders. Initial actions are assigned probabilistically, each trader observes a subset of peers, and the simulated price changes according to the net number of buyers and sellers multiplied by a fixed increment. The author asks how to improve the model and its implementation.
The example illustrates a simple social-influence mechanism and a price impact rule, but it offers no simulation results, calibration, or validation against observed markets. The code also leaves important modeling choices open, including how information is sampled, how decision probabilities evolve, and whether price changes should depend on order size or market conditions. It is a conceptual starting point rather than evidence that peer imitation predicts market behavior.
Key ideas
- The model assigns traders buy, sell, or neutral actions and then updates them using peers’ actions.
- Each trader samples a subset of other traders to inform a new decision.
- Price changes by a fixed amount according to the balance of simulated buyers and sellers.
- The post does not report results or validate the model against real trading behavior.
Tags
Full text
# Simulation of Traders
# Simulation of Traders
I am writing a simulation of how traders will behave in an emergent market. The idea is to see how traders can use information from other traders to make a decisions as to whether they will buy, sell, or stay out of a market. Here is my code so far:
```
f1 <- function(n,m,priceinitial,delta,mean, sd, ninterval){
traders <- vector(mode="character", length=n)
traderscurrent <- vector(mode="character", length=n)
price <- vector(mode="numeric")
pricecurrent <- vector(mode="numeric")
for(nint in 1:ninterval)
{
L = floor(rnorm(1,mean,sd))
print(L)
x3 <- runif(2,0,1)
v <- c(0, min(x3), max(x3))
for(i in 1:n)
{
traders[i] <- runif(1,0,1)
if(findInterval(traders[i],v) == sample(c(1,3),1))
{
traders[i] <- "B"
}
else if(findInterval(traders[i],v) == 2)
{
traders[i] <- "N"
}
else {
traders[i] <- "S"
}
}
print(table(traders))
for(step in 1:L)
{
for(i in 1:n)
{
b <- sample(traders[-i], m)
#print(b)
#table(b)
traderscurrent[i] <- sample(b,1)
}
print(table(traderscurrent))
pricecurrent[step] = priceinitial+length(which(traderscurrent == "B"))*delta-length(which(traderscurrent == "S"))*delta
priceinitial = pricecurrent[step]
traders <- traderscurrent
#print(nint)
#print(step)
}
price <- c(price,pricecurrent)
#price <- price[-step]
plot(price)
}
print(price)
#plot(price)
}
```
Basically we start off with $n$ traders who can look at $m < n$ others traders to make their decision. The ` priceinitial ` is updated by ` delta ` depending on the actions of the traders. Does anyone have any suggestions on how to improve this code/simulation?
Note: This simulation is written in R.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.