Top Banner
College of Computer and Information Science, Northeastern University July 3, 2022 1 Multifractal analysis and multiagent simulation for market crash prediction V. Romanov, V.Slepov, M. Badrina, A. Federyakov Russian Plekhanov Russian Plekhanov Academy of Economics Academy of Economics Computational Finance 2008 27 – 29 May 2008 Cadiz, Spain
35
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 1

Multifractal analysis and multiagent simulation for market crash prediction

V. Romanov, V.Slepov, M. Badrina, A. Federyakov

Russian PlekhanovRussian Plekhanov Academy of EconomicsAcademy of Economics

Computational Finance 200827 – 29 May 2008

Cadiz, Spain

Page 2: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 2

PREDICTION DIFFICULTIES

It is well known, that financial markets are essentially non-linear systems and financial time series are fractals.

That’s why prediction of crash situations at finance market is a very difficult task. It doesn’t allow us to use effectively such well-known methods as ARIMA or MACD in view of their sluggishness.

Multifractal and wavelets analysis methods are providing more deep insight into the nature of phenomena. Multiagent simulation makes it possible to explicate dynamic properties of the system.

Page 3: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 3

Examples of outputs market model

Non-linear oscillation The strange attractor

This output looks like head and shoulder pattern Artificial time series generation

Page 4: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 4

The Aims and Methodology

• As soon as our aim is predicting Crash situations we are trying at first to find out the best indicator which uses Multifractal analysis and wavelet analysis methodology.

• With this aim in mind we are testing different pre-processing kinds of original time series to discover the best indicator.

Page 5: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 5

Fractals

The term fractal was coined in 1975 by Benoît Mandelbrot, from the Latin fractus, meaning "broken" or "fractured".

(colloquial) a shape that is recursively constructed or self-similar, that is, a shape that appears similar at all scales of magnification.

(mathematics) a geometric object that has a Hausdorff dimension greater than its topological dimension.

Page 6: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 6

Mandelbrot Set

Mandelbrotset, rendered with Evercat's program.

Page 7: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 7

Dynamic systems fractals

Page 8: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 8

Dimension

What is fractal dimension?• There are different kinds:• Hausdorff dimension… how does the number of balls it

takes to cover the fractal scale with the size of the balls?• Box-counting dimension… how does the number of

boxes it takes to cover the fractal scale with the size of the boxes?

• Information dimension… how does the average information needed to identify an occupied box scale?

• Correlation dimension… calculated from the number of points used to generate the picture, and the number of pairs of points within a distance ε of each other.

• This list is not exhaustive!

Page 9: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 9

Hurst exponent

• In prediction financial market behavior a special role belongs to the study of Hurst exponent. The exponent Hurst evaluation and its changing gives an opportunity predict trend replacement in critical points. The Hurst exponent H is statistical measure used to classify time series.

• The larger this value is the stronger trend. Time series with large Hurst exponent can be predicted more accurately than those series with value close to 0.50. The Hurst exponent provides a measure for long term memory and fractality of time series.

Page 10: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 10

Hurst exponent for monofractals

Ttzzx ttt ,...,1,lnln 1

• Depending on the value of Heurst exponent the properties of the process are distinguished as follows:

• When H = 0.5, there is a process of random walks, which confirms the hypothesis EMH.

•When H > 0.5, the process has long-term memory and is persistent, that is it has a positive correlation for different time scales.

• When H < 0.5, time-series is anti-persistent with average switching from time to time.

11

1,),(

t

t

uu xxxxtx

),(min),(max)(11

txtxRtt

1

21)(

uu xxS

log)(

)(log SR

H

Page 11: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 11

Multifractal time series (1)

1))(()|)()((| qq tqctxttxE

,, ,, realQBQqBt

q

The process is multifractal if:

where c(q) – predictor, E – expectation operator,

scaling function, which expresses mutifractality properties of time series

In case of monofractal

1HqqFor scaling function estimation we will construct partition function

,,

/int

01

qtT

ititit zzqz

1/int,

qt tqctTqzE

Page 12: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 12

Multifractal time series (2)

Page 13: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 13

Time series partitioning

• Time series: {xt}; t [0, T].

• Compute: Z={zt}, zt= lnxt+1-lnxt; t [0,T];

• Divide interval [0, T] into N subintervals, 1 ≤ N ≤ Nmax.

• Each subinterval contains int (T/N)=A values Z;

• For each subinterval K; 1 ≤ K ≤ N current reading number lK; 1 ≤ lK ≤ A; t = (K-1) А+ lK

• As soon as we are looking for the best indicator of a coming default, we will use several variants of a preliminary processing.

Page 14: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 14

Time series preprocessing

• 1. The original time series itself: Z={zt};

• 2. Preprocessed time series Z1={ }, K=1,2,…N, where

• 3. Preprocessed time series where

• 4. Preprocessed time series Z3={ }

KlAK ZZK

10

A

lKlK

K

KZZ

AS

1

2

0

1

A

llK

K

Kz

AZ

10

1KZ

K

KlAK

S

ZZZ K

10

2

Page 15: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 15

Partition functions

N

K

q

AKKAN ZTZqZ1

)1(0)(00 |)(|),(

N

K

qKKN ZTZqZ

11

1 |)(|),(

N

K

qAKN ZKAZqZ

1

)1(222 |)(|),(

For each preprocessed time series compute partition function for different N and q values :

N

K

q

AKKAN ZZqZ1

)1(3)(33 ||),(

Page 16: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 16

Scaling functions (see main fractal property)

A

NAqZq

NN log

loglog),(log)(

00

A

NAqZq

NN log

loglog),(log)(

11

A

NAqZq

NN log

loglog),(log)(

22

A

NAqZq

NN log

loglog),(log)(

33

Page 17: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 17

Fractal dimension spectrum estimation

)])()([min(arg)]([minarg)( qqqqqf iiq

iq

I

1. Lipshitz – Hoelder exponent estimation:

, where i = 1, 2, 3, 4.

2. Fractal dimension spectrum estimation by Legendre transform:

qqqqqdq

d iiii

i

/)(/))1()((

Page 18: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 18

Fractal dimension spectrum width as crash indicator

• Multifractal may be composed of two or infinite number of monofractals with continuous varying α values. Width of α spectrum may be estimated as difference between maximum and minimum values of α:

• By carrying out Legendre transform we are trying using our program

by estimating Δ to find differences in its values before and after crash.

• Roughly speaking f() gives us number of time moments, for which degree of polynomial, needed for approximation f() equals (according to Lipshitz condition).

minmax

Page 19: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 19

Experimental results (multifractal analysis)

The method of multifractal analyses, described above, has been applied also for October 1987 USA financial crises, using Dow Jones index Fig. 1.

0,00000

500,00000

1000,00000

1500,00000

2000,00000

2500,00000

3000,00000

0 100 200 300 400 500 600 700 800

Figure 1: Dow Jones industrial average data for period 01.02.1985 – 31.12.87. Axis X contains serial numbers of readings.

Page 20: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 20

Fractal spectrum estimation

Figure 2: Fractal dimension spectrum F2 () for DJ

industrial average series for period 10.10.85-19.10.87.

Fractal dimension spectrum for 18.11.96-30.11.98 time

period (Russian default currency exchanging data)

Fractal dimension spectrum for 09.07.96-21.07.98 time period

(Russian default currency exchanging data)

Page 21: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 21

Multifractal spectrum width before and after crisis

F1

0

0,5

1

1,5

2

2,5

3

3,5

4

4,5

date

fra

cta

l s

pe

ctr

um

wid

th (

de

lta

)

level 0

level 0,6

level 0,8

Figure 3: Fractal dimension spectrum width F1 () changing before and after crises.

Page 22: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 22

Multifractal spectrum width before and after crisis (continued)

F2

0

0,5

1

1,5

2

2,5

3

date

fra

cta

l s

pe

ctr

um

wid

th (

de

lta

)

level 0

level 0,6

level 0,8

Figure 4: Fractal dimension spectrum width F2 () changing before and after crises.

Page 23: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 23

Wavelet analysis

• Wavelet A small wave

• Wavelet Transforms Convert a signal into a series of wavelets Provide a way for analyzing waveforms, bounded in both frequency

and duration An alternative approach to the short time Fourier transform to

overcome the resolution problem Similar to STFT: signal is multiplied with a function

• Multiresolution Analysis Analyze the signal at different frequencies with different resolutions Good time resolution and poor frequency resolution at high

frequencies Good frequency resolution and poor time resolution at low

frequencies More suitable for short duration of higher frequency; and longer

duration of lower frequency components

Constituent wavelets of different scales

Page 24: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 24

Wavelet analysis of multifractal time series

)(1

)(

tt

where ,(t)– function with zero

mean centered around zero with time scale and time

horizon .

Family of wavelet vectors is created from mother

function by displacement and scaling

,)()(),( , dtttxW

Page 25: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 25

Time series f(t) representation as linear combination of wavelet

functions

),()()( ,,,

0

00tttf kj

kkj

jjkj

kj

dtttf kjkj )()( ,, 00

dtttf kjkj )()( ,,

where jo – a constant, representing the highest level of resolution for which the most acute details are extracted .

Page 26: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 26

Experimental results (wavelet analysis)

14700

14720

14740

14760

14780

14800

14820

14840

14860

14880

14900

Figure 5: The plot of changing maximum values detail coefficients Daubichies -12 expansion.

-25

-20

-15

-10

-5

0

5

10

15

20

25

Figure 6: The plot of maximum differences.

Page 27: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 27

Financial market model FIMASIM

The main functional modules are:• FMSWorld, which contains virtual world classes and relationships,• FMSStandardRoles, which contains financial market classes, and

others.

Standard classes of the system are:• Trader (TFMTrader) • Broker (TFMSBroker) • Company (TFMCompany) • Market, stock exchange (TFMSMarket) • Strategy (TFMSStrategy) • Plan (TFMSPlan) • Order, transaction request (TFMSShareTransactionRequest) • Transaction (TFMSShareTransactiont)

Page 28: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 28

Virtual market program interface

Page 29: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 29

The experiments were made with aim to find out at which values of parameters the market instability arises.

Experiment 1:Overall parameters:• MARKET_MAKER_TRADER_COUNT = 2;• RANDOM_TRADER_COUNT = 0;• FUNDAMENTAL_TRADER_COUNT = 500;• • BROKER_COUNT = 5;• MARKET_COUNT = 1;• COMPANY_COUNT = 10;• CLASSIFICATORS_COUNT = 31;

Companies:• COMPANY_MAX_ASSETS = 50000000; //

50Mbyte• COMPANY_MIN_ASSETS = 1000000; //

1Mbyte Brokers:• MIN_BROKER_MARKET_ACCOUNT_MONEY

= 100000; // 100k.• MAX_BROKER_MARKET_ACCOUNT_MONEY

= 150000; // 300k.• BROKER_MONEY = 10000; // 10k.

Broker and market: • MAX_COMMISION_PLANS = 3;

 Market maker trader parameters: MIN_MM_TRADER_CHANGE_PERCENT = 0.1; MAX_MM_TRADER_CHANGE_PERCENT = 0.5;

Random Trader parameters: MIN_RANDOM_TRADER_PORTFOLIOS = 0; MAX_RANDOM_TRADER_PORTFOLIOS = 5;  MIN_RANDOM_TRADER_MONEY = 50; MAX_RANDOM_TRADER_MONEY = 2000;  MIN_RANDOM_TRADER_ACCOUNT_MONEY = 200; MAX_RANDOM_TRADER_ACCOUNT_MONEY = 1000; MIN_RANDOM_TRADER_PORTF_ITEM_PRICE = 20; MAX_RANDOM_TRADER_PORTF_ITEM_PRICE = 3000;   MIN_RANDOM_TRADER_RISK_AMOUNT = 0.01; MAX_RANDOM_TRADER_RISK_AMOUNT = 0.25;

Page 30: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 30

Program realization

Minimum, maximum and average price changes

Price time series

Real price and fundamental price

distributionsMinimum, maximum and average price

distributions

Page 31: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 31

Experiment 2:

Overall parameters:• MARKET_MAKER_TRADER_COUNT = 2;• RANDOM_TRADER_COUNT = 0;• FUNDAMENTAL_TRADER_COUNT = 500;

• BROKER_COUNT = 20;• MARKET_COUNT = 1;• COMPANY_COUNT = 10;• CLASSIFICATORS_COUNT = 31; Companies:• COMPANY_MAX_ASSETS = 15000; // 50Mbyte• COMPANY_MIN_ASSETS = 10000; // 1Mbyte Brokers:• MIN_BROKER_MARKET_ACCOUNT_MONEY =

100000; // 100k.• MAX_BROKER_MARKET_ACCOUNT_MONEY =

150000; // 300k.• BROKER_MONEY = 10000; // 10k.

Broker and market:• MAX_COMMISION_PLANS = 5;

Market maker trader parameters: MIN_MM_TRADER_CHANGE_PERCENT = 0.5; MAX_MM_TRADER_CHANGE_PERCENT = 0.7;

Random Trader parameters: MIN_RANDOM_TRADER_PORTFOLIOS = 0; MAX_RANDOM_TRADER_PORTFOLIOS = 3;  MIN_RANDOM_TRADER_MONEY = 10; MAX_RANDOM_TRADER_MONEY = 200000;

MIN_RANDOM_TRADER_ACCOUNT_MONEY = 200; MAX_RANDOM_TRADER_ACCOUNT_MONEY = 1000;

MIN_RANDOM_TRADER_PORTF_ITEM_PRICE = 20; MAX_RANDOM_TRADER_PORTF_ITEM_PRICE = 3000;

MIN_RANDOM_TRADER_RISK_AMOUNT = 0.01; MAX_RANDOM_TRADER_RISK_AMOUNT = 0.5;

Page 32: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 32

Price time series. Experiment 2

Page 33: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 33

Experiment 3:

Overall parameters:FUNDAMENTAL_TRADER_ MARKET_MAKER_TRADER_COUNT = 2; RANDOM_TRADER_COUNT = 250;COUNT = 250;

BROKER_COUNT = 5; MARKET_COUNT = 1; COMPANY_COUNT = 10; CLASSIFICATORS_COUNT = 31;

Companies: COMPANY_MAX_ASSETS = 50000000; // 50Mbyte COMPANY_MIN_ASSETS = 1000000; // 1Mbyte Brokers:MIN_BROKER_MARKET_ACCOUNT_MONEY = 100000; // 100k. MAX_BROKER_MARKET_ACCOUNT_MONEY = 300000; // 300k. BROKER_MONEY = 10000; // 10k.

Broker and market: MAX_COMMISION_PLANS = 3;

Market maker trader parameters:

MIN_MM_TRADER_CHANGE_PERCENT = 0.1;

MAX_MM_TRADER_CHANGE_PERCENT = 0.5;

Random Trader parameters:

MIN_RANDOM_TRADER_PORTFOLIOS = 0;

MAX_RANDOM_TRADER_PORTFOLIOS = 2;

MIN_RANDOM_TRADER_MONEY = 500;

MAX_RANDOM_TRADER_MONEY = 5000;

MIN_RANDOM_TRADER_ACCOUNT_MONEY = 2000;

MAX_RANDOM_TRADER_ACCOUNT_MONEY = 7000;

MIN_RANDOM_TRADER_PORTF_ITEM_PRICE = 2000;

MAX_RANDOM_TRADER_PORTF_ITEM_PRICE = 4000;

MIN_RANDOM_TRADER_RISK_AMOUNT = 0.01;

MAX_RANDOM_TRADER_RISK_AMOUNT = 0.10;

Page 34: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 34

Price time series. Experiment 3

Page 35: Stock market trading simulator multiagent based-2009-Cadiz-Spain

College of Computer and Information Science, Northeastern UniversityApril 13, 2023 35

THANK YOU

ANY QUESTIONS?