Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial...

38
Introduction LeBaron’s Model Research Direction/Conclusion Artificial Agent-Based Stock Markets Sherif Ragab Department of Computer Science The American University in Cairo October 21, 2008 Artificial Agent-Based Stock Markets

Transcript of Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial...

Page 1: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Artificial Agent-Based Stock Markets

Sherif Ragab

Department of Computer ScienceThe American University in Cairo

October 21, 2008

Artificial Agent-Based Stock Markets

Page 2: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Outline

Introduction

LeBaron’s Model

Research Direction/Conclusion

Artificial Agent-Based Stock Markets

Page 3: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Outline

Introduction

LeBaron’s Model

Research Direction/Conclusion

Artificial Agent-Based Stock Markets

Page 4: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Outline

Introduction

LeBaron’s Model

Research Direction/Conclusion

Artificial Agent-Based Stock Markets

Page 5: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Objective & Motivation

I Objective: To successfully imitate real markets, in terms of1. Statistical Properties.2. Behavior.

I Motivation:1. Fundamental insight into how markets work.2. Prediction of behavior.3. Experimentation.

Artificial Agent-Based Stock Markets

Page 6: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Objective & Motivation

I Objective: To successfully imitate real markets, in terms of1. Statistical Properties.2. Behavior.

I Motivation:1. Fundamental insight into how markets work.2. Prediction of behavior.3. Experimentation.

Artificial Agent-Based Stock Markets

Page 7: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Real Markets

I Traders engage in buying and selling of a good or service.

I How are prices determined?1. Demand: How badly do people want it?2. Supply: How available is it?

Artificial Agent-Based Stock Markets

Page 8: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Real Markets

I Traders engage in buying and selling of a good or service.

I How are prices determined?1. Demand: How badly do people want it?2. Supply: How available is it?

Artificial Agent-Based Stock Markets

Page 9: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Real Markets

I Traders engage in buying and selling of a good or service.

I How are prices determined?1. Demand: How badly do people want it?2. Supply: How available is it?

Artificial Agent-Based Stock Markets

Page 10: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Supply & Demand

pe

qe

price

quantity

demand supply

pe = equilibrium priceqe = equilibrium quantity

Artificial Agent-Based Stock Markets

Page 11: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Supply & Demand

pe

qe

price

quantity

demand supply

pe = equilibrium priceqe = equilibrium quantity

Artificial Agent-Based Stock Markets

Page 12: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Supply & Demand

pe

qe

pe'

qe'

price

quantity

demand supply

pe = equilibrium priceqe = equilibrium quantity

Artificial Agent-Based Stock Markets

Page 13: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Constant Supply

pe

qe

price

quantity

demand

constantsupply

pe = equilibrium priceqe = equilibrium quantity

Artificial Agent-Based Stock Markets

Page 14: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Constant Supply

pe

qe

price

quantity

demand

constantsupply

pe'

pe = equilibrium priceqe = equilibrium quantity

Artificial Agent-Based Stock Markets

Page 15: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Market Structure

I Only one stock.

I n artificial agentssi −→ stock holdings of agent ici −→ cash of agent iwi −→ total wealth of agent ip −→ current price

wi = si · p + ci

Total number of stocks (∑

i∈A si ) is constant.

Artificial Agent-Based Stock Markets

Page 16: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Market Structure

I Only one stock.

I n artificial agentssi −→ stock holdings of agent ici −→ cash of agent iwi −→ total wealth of agent ip −→ current price

wi = si · p + ci

Total number of stocks (∑

i∈A si ) is constant.

Artificial Agent-Based Stock Markets

Page 17: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Artificial Trading Agents

I Represented by a demand function.

Di(p, ~z) =αi(p, ~z) · wi

p(1)

where: ~z = information vectorI Aggregate Demand:

N∑i=0

Di(p, ~z) = S (2)

where: N = number of agents, S = total supply of stocks

Artificial Agent-Based Stock Markets

Page 18: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Artificial Trading Agents

I Represented by a demand function.

Di(p, ~z) =αi(p, ~z) · wi

p(1)

where: ~z = information vectorI Aggregate Demand:

N∑i=0

Di(p, ~z) = S (2)

where: N = number of agents, S = total supply of stocks

Artificial Agent-Based Stock Markets

Page 19: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Information Set (~z) / and the NN (α)

I ~z is a the output of 6 functions:z0 = rt = ln(pnew−pold

pold) return

z1 = rt−1 return 1 time-step agoz2 = rt−2 return 2 time-steps agoz3 = ln(r · p/d) dividend-price ratioz4 = ln(p/m1) moving price-average 1z5 = ln(p/m2) moving price-average 2

I Features for the NN!I NN is described by a weight vector w

Artificial Agent-Based Stock Markets

Page 20: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Information Set (~z) / and the NN (α)

I ~z is a the output of 6 functions:z0 = rt = ln(pnew−pold

pold) return

z1 = rt−1 return 1 time-step agoz2 = rt−2 return 2 time-steps agoz3 = ln(r · p/d) dividend-price ratioz4 = ln(p/m1) moving price-average 1z5 = ln(p/m2) moving price-average 2

I Features for the NN!I NN is described by a weight vector w

Artificial Agent-Based Stock Markets

Page 21: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Information Set (~z) / and the NN (α)

I ~z is a the output of 6 functions:z0 = rt = ln(pnew−pold

pold) return

z1 = rt−1 return 1 time-step agoz2 = rt−2 return 2 time-steps agoz3 = ln(r · p/d) dividend-price ratioz4 = ln(p/m1) moving price-average 1z5 = ln(p/m2) moving price-average 2

I Features for the NN!I NN is described by a weight vector w

Artificial Agent-Based Stock Markets

Page 22: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Neural Network Structurez0

��

z1

��

z6

��+

w10

��

w00oo +

w11

��

w01oo . . . +

w16

��

w06oo

tanh

w20

))SSSSSSSSSSSSSSSSS tanh

w21

��

tanh

w26

ssggggggggggggggggggggggggg

w3 // P

��λx → ex

1+ex

��α

Artificial Agent-Based Stock Markets

Page 23: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Evolving the Agents

I Agents’ fitness determined through past performanceI Crossover: combine weights from agents to replace

another.I Mutation: randomly change weights with probability

determined by fitness

Artificial Agent-Based Stock Markets

Page 24: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Evolving the Agents

I Agents’ fitness determined through past performanceI Crossover: combine weights from agents to replace

another.I Mutation: randomly change weights with probability

determined by fitness

Artificial Agent-Based Stock Markets

Page 25: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Evolving the Agents

I Agents’ fitness determined through past performanceI Crossover: combine weights from agents to replace

another.I Mutation: randomly change weights with probability

determined by fitness

Artificial Agent-Based Stock Markets

Page 26: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Results

-

6price

time

-

6volume

time

Artificial Agent-Based Stock Markets

Page 27: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Interpreting price series

“Realism” of price-series is determined by applying statisticalmeasures to returns (price changes) and to volume.

I Mean.I Standard deviation.I Kurtosis.I Skewedness.I others.

Artificial Agent-Based Stock Markets

Page 28: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Interpreting price series

“Realism” of price-series is determined by applying statisticalmeasures to returns (price changes) and to volume.

I Mean.I Standard deviation.I Kurtosis.I Skewedness.I others.

Artificial Agent-Based Stock Markets

Page 29: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Interpreting price series

“Realism” of price-series is determined by applying statisticalmeasures to returns (price changes) and to volume.

I Mean.I Standard deviation.I Kurtosis.I Skewedness.I others.

Artificial Agent-Based Stock Markets

Page 30: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Interpreting price series

“Realism” of price-series is determined by applying statisticalmeasures to returns (price changes) and to volume.

I Mean.I Standard deviation.I Kurtosis.I Skewedness.I others.

Artificial Agent-Based Stock Markets

Page 31: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Modifying Current Models

Much space for improvement on AI side.Possible examples:

I Introduce imitation (replace GA with PSO).I Change market structure (e.g. more than one stock).

Artificial Agent-Based Stock Markets

Page 32: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Modifying Current Models

Much space for improvement on AI side.Possible examples:

I Introduce imitation (replace GA with PSO).I Change market structure (e.g. more than one stock).

Artificial Agent-Based Stock Markets

Page 33: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Modifying Current Models

Much space for improvement on AI side.Possible examples:

I Introduce imitation (replace GA with PSO).I Change market structure (e.g. more than one stock).

Artificial Agent-Based Stock Markets

Page 34: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Creating a New Model

I Modeling different types of markets.I Must be tractable.I Must be realistic.

Artificial Agent-Based Stock Markets

Page 35: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Creating a New Model

I Modeling different types of markets.I Must be tractable.I Must be realistic.

Artificial Agent-Based Stock Markets

Page 36: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

Creating a New Model

I Modeling different types of markets.I Must be tractable.I Must be realistic.

Artificial Agent-Based Stock Markets

Page 37: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

References

1. Blake LeBaron, “Empirical Regularities From Interacting Long- and Short-Memory Investors in anAgent-Based Stock Market.” IEEE Transactions on Evolutionary Computation, Vol. 5, No. 5, October 2001

2. N. F. Johnson, D. Lampert, P. Jeffries, M. L. Hart, and S. Howison, “Application of multi-agent games to theprediction of financial time-series.” Physica A, 299:222

3. Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving traders and the business school with genetic programming:A new architecture of the agent-based artificial stock market.” Journal of Economic Dynamics and Control,Volume 25, Issues 3-4, March 2001, Pages 363-393

4. Blake LeBarona and Ryuichi Yamamoto, “Long-memory in an order-driven market .” Physica A: StatisticalMechanics and its Applications, Volume 383, Issue 1, 1 September 2007, Pages 85-89

Artificial Agent-Based Stock Markets

Page 38: Artificial Agent-Based Stock Marketsrafea/CSCE590/Fall08/Ragab/pres.pdf · prediction of financial time-series.” Physica A, 299:222 3.Shu-Heng Chen and Chia-Hsuan Yeh, “Evolving

IntroductionLeBaron’s Model

Research Direction/Conclusion

The End

Questions?

Artificial Agent-Based Stock Markets