numerical software, market data and extreme events robert tong
DESCRIPTION
Numerical Software, Market Data and Extreme Events Robert Tong. Outline. Market data Pre-processing Software components Extreme events Example: wavelet analysis of FX spot prices Implications for software design. Market data. Tick – as transactions occur, - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/1.jpg)
Results Matter. Trust NAG.
Numerical Algorithms GroupMathematics and technology for optimized performance
Numerical Software, Market Dataand Extreme Events
Robert Tong
![Page 2: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/2.jpg)
2
Outline
• Market data
• Pre-processing
• Software components
• Extreme events
• Example: wavelet analysis of FX spot prices
• Implications for software design
![Page 3: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/3.jpg)
3
Market data• Tick – as transactions occur,
high frequency, irregular in time
quote/price with time stamp
• Sample tick data at regular times –
minute, hour, day, … – low-high price
• Bid-ask pairs – FX spot market
• Time series – construct from sampled and processed data
![Page 4: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/4.jpg)
4
FX spot market prices - USD-CHF• ticks (e.g. see www.dailyfx.com)
• minutes
• hours
From: www.dailyfx.com/charts
![Page 5: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/5.jpg)
5
Data cleaning
Required to remove errors in data – • inputting errors• test ticks to check system response• repeated ticks• copying and re-sending of ticks• scaling errors
How can false values be reliably identified and rejected ?• what assumptions must be imposed?• elimination of outliers based on an assumed probability
distribution
![Page 6: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/6.jpg)
6
Pre-processing
• Tick data irregular in time – construct homogeneous
time series by interpolation: linear, repeated value• Bid-ask spread – use relative spread• Remove seasonality• Account for holidays
Must not introduce spurious structures to data
![Page 7: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/7.jpg)
7
Software components
Mathematical models
Software components
Data cleaning AnalysisPre-processing
filtering interpolation waveletstransformation
![Page 8: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/8.jpg)
8
Implementation issues
Algorithm design –– Stability– Accuracy– Exception handling– Portability– Error indicators– Documentation
These are independent of the problem being solved
![Page 9: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/9.jpg)
9
Extreme events
• Weather – storm• Warfare – explosion• Markets – crash
Software –How should it respond to the unpredictable?
What is the role of software when its modelling assumptions break down?
![Page 10: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/10.jpg)
10
An illustration – another type of bubble
Underwater explosions are used to destroy ships –
the initial shock is expected and often not as damaging as the later gas bubble collapse.
Left: raw data from sensitive, but un-calibrated pressure gauge
Right: calibrated gauge uses averaging to produce smooth curve
Use of averaging obscures critical event in this case.
![Page 11: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/11.jpg)
11
Example: wavelet analysis of FX spot prices
• Wavelet transforms provide localisation in time and frequency for analysis of financial time series.
• This is achieved by scaling and translation of wavelet basis.
• Decompose time series, by convolution with dilated and translated mother wavelet, or filter,
• Discrete (DWT) Orthogonal Filter pair:
H – high pass, G – low pass
followed by down-sampling
),(tx)(t h
![Page 12: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/12.jpg)
12
Wavelet filtersFamily of filters by scaling
Daubechies D(4) wavelet
filters result from sampling a continuous function
![Page 13: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/13.jpg)
13
Multi-Resolution AnalysisDiscrete Wavelet Transform (DWT)
d1
d2
x(t)
Hx | 2
Gx | 2
Hs1 | 2
Gs1 | 2
Hs2 | 2
Gs2 | 2
![Page 14: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/14.jpg)
14
DWT implementation
Orthogonal wavelet transform uses • filters defined by sequences: ,• satisfying: ,
,
• This allows for a number of variants in implementation
numerical output from different software providers
is not identical
}{ nh }{ ng
02 jnn
nhh 12 n
nh
nn
n hg 1)1( n
jnn gh 02
![Page 15: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/15.jpg)
15
Discrete Wavelet Transform – Multi-Resolution Analysis
For input data , length ,
produces representation in terms of ‘detail’ and ‘smooth’ wavelet coefficients of length
Uses• Data compression – discard coefficients• De-noising
Disadvantages• Difficult to relate coefficients to position in original input• Not translation invariant – shifting starting position
produces different coefficients
}{ ix JN 2
N
![Page 16: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/16.jpg)
16
Maximal Overlap Wavelet Transform (MODWT)(Stationary Wavelet Transform)
• Convolution: wavelet filters as in DWT• No down-sampling• MRA produces N coefficients at each level• Requires more storage and computation• Not orthonormal
Advantages • Translation invariant• Can relate to time scale of original data• Does not require length(x) = J2
![Page 17: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/17.jpg)
17
Choice of wavelet filter
• Short
can introduce ‘blocking’ or other features which
obscure analysis of data• Long
increases number of coefficients affected by ends
of data set• Basis Pursuit
seeks to optimise choice of wavelet at each level
but requires more computation
![Page 18: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/18.jpg)
18
FX: USD, GBP, EUR – NZD12 noon buying rates, Jan – Jul 2007
![Page 19: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/19.jpg)
19
FX: JPY, USD, GBP, EUR – NZD12 noon buying rates, Jan – Jul 2007
(from www.x-rates.com)
![Page 20: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/20.jpg)
20
JPY-NZD, LA(8), MODWT(includes boundary effects)
x(t)
d1
d2
d3
d4
![Page 21: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/21.jpg)
21
JPY-NZD, LA(8) MODWT (includes boundary effects)
x(t)
d5
d6
s6
![Page 22: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/22.jpg)
22
Boundary conditions – end extension
• Wavelet transform applies circular convolution to data• What happens at the ends of the data set?• End extension techniques –
periodic
reflection – whole/half-point
pad with zeros• Boundary effects contaminate wavelet coefficients
software should indicate where output is
influenced by end extension
![Page 23: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/23.jpg)
23
End extension
Periodic Whole-point reflection
![Page 24: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/24.jpg)
24
USD-NZD, Haar, MODWT
Periodic end extension
Level 1 detail coefficients Level 2 detail coefficients
![Page 25: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/25.jpg)
25
USD-NZD, Haar, MODWT(end effects removed)
x(t)
d1
d2
d3
![Page 26: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/26.jpg)
26
USD-NZD, Haar MODWT (end effects removed)
x(t)
d4
d5
d6
s6
![Page 27: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/27.jpg)
27
Wavelet analysis for prediction
• Extrapolation from present to near future is useful
• Apply wavelet filters to for
avoiding boundary effect
• Select wavelet scales to identify trend and stochastic parts of data set
• Use wavelet coefficients to compute prediction(see Renaud et al., 2002)
)(tx presenttt
![Page 28: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/28.jpg)
28
Implications for software development
• Reproducibility is desirable – algorithms precisely defined to allow independent implementations
to produce identical results
• Edge effects – contaminate ends of transform for finite signals – software must indicate coefficients affected
• Smoothing/averaging –software should indicate when underlying assumptions likely to be invalid
• Pre-processing – ensure that structure is not introduced by interpolation to give
homogeneous data set
![Page 29: Numerical Software, Market Data and Extreme Events Robert Tong](https://reader036.vdocument.in/reader036/viewer/2022062517/56812d6c550346895d928035/html5/thumbnails/29.jpg)
29
Implications for software development
• For extreme events –
must not obscure or remove data relevant to critical events by averaging, smoothing, filtering.