1 - Numerical Method Inc.

Quantitative Trading Strategy based on
Time Series Technical Analysis
Group Member:
Zhao Xia Jun
Lorraine Wang
Lu Xiao
Zhang Le Yu
What’s new from the paper
Michel Fliess. Cédric Join
Time Series Technical Analysis via New Fast
Estimation Methods: A Preliminary Study in
Mathematical Finance.
(2008, Coventry, United Kingdom.)
What’s new from the paper



New fast estimation methods are applied to “Model-free”
setting
Via repeated identifications of low order linear difference
equations on sliding short time windows
Applying signal processing technique on finance
What’s new from our project

As the paper did not discuss any trading strategy, we
come up with all the strategies by ourselves based on the
techniques from the paper.
Tools and Packages


Matlab 2010
Signal Processing Toolbox

This toolbox is included in Matlab starting from version 2010
Data





Data: EUR/USD & GBP/USD & AUD/JPY Exchange Rates
Source:: eSignal software
Frequency: One Hour Interval
In-Sample: Major analysis are done with data from 2009
quarter 4 to 2010 quarter 1.
Out-of-Sample: The strategies are back tested on the
following 1 year data, i.e. 2010 quarter 2 to 2011 quarter
1.
Inputs, outputs and measurement





Trading decisions are made at the end of each hour.
Decision related inputs are only close price of that hour
(as well as past prices).
The most important measurement of performance is the
cumulative value of 1 dollar after 1 year.
Sharpe Ratio, maximum drawdown, and percentage
correct are also output.
Assume no leverage, no transaction cost, and the deposit
for a short position is its price.
Briefly about our work



Although the paper applies signal processing techniques
on finance, it provides no trading strategies.
We aim to focus on these new techniques and develop
strategies that may work under indicators from the new
techniques.
We may use all the techniques, or part of, mentioned in
the paper, in our strategies.
Strategies



Use filtering technique only (1 strategy)
Use filtering and z-transform (2 strategies)
Use moving average on error terms (1 strategy)
Strategy 1: Filtered Price Indicator
1.475
1.47
1.465
1.46
1.455
1.45
1.445
1.44
1.435
1.43
1740



1760
1780
1800
1820
1840
1860
1880
Blue line: market prices
Green line: filtered prices
Strategy 1 is to base trading decisions on the difference
between blue and green lines at each period.
1900
Strategy 1: Filtered Price Indicator
1.445
1.44
1.435
1.43
1.425
1850

1850 1855
1860
1860
1870
1865
1880
18901870
1900
1875
We should use information up to each period. As the
filtered price would be different if we provide it with
future prices. (see period 1874)
1910
1
Strategy 1: Filtered Price Indicator


The author of the paper believes the average of the
difference (errors) between filtered prices and market
prices approaches to zero. So a large departure of market
price and filtered price is unlikely.
A simple strategy:



Buy if filtered price (of this period) is much higher than close
price (of this period);
Sell if filtered price (of this period) is much lower than close
price (of this period).
Refer to “qt_Strategy_FilteredPriceIndicator.m”
Strategy 1: Filtered Price Indicator

Result:
Strategy: Filtered Price. Security No:1
1.3
1.2
1.1
1
0.9
0
1000
2000
3000
4000
5000
6000
7000
Strategy 1: Filtered Price Indicator
Strategy: Filtered Price. Security No:2
1.2
1.1
1
0.9
0.8
0
1000
2000
3000
4000
5000
6000
7000
Strategy 1: Filtered Price Indicator
Strategy: Filtered Price. Security No:3
1.3
1.2
1.1
1
0.9
0
1000
2000
3000
4000
5000
6000
7000
Strategy 2: Simple Prediction

The paper uses z-transform and non-linear system to get
coefficients of the equation on filtered prices:

When applying these coefficients on the market prices,
we can get predictions of future prices.
Refer to: “qt_GetSinglePrediction.m”

Strategy 2: Simple Prediction
1.48
1.475
1.47
1.465
1.46
1.455
350



400
450
Blue line: Market Prices;
Green line: Filtered Prices
Red line: Forecasted one-period-after price
500
Strategy 2: Simple Prediction

Buy when current price is lower than predicted future price
 Volume depends on the prediction length (i.e. number of
prediction made)





E.g. volume=1 when prediction length=1, i.e. predict only for next time
bar
E.g. volume=2 when prediction length=2 and both predicted prices for
next 2 time bars are above current price
Sell when current price is higher than predicted future price
Close the open position when the prediction shows a change of
price direction
Refer to: “qt_Strategy_SimplePrediction.m”
Strategy 2: Simple Prediction

Result
Strategy: Prediction. Security No:1
1.05
1
0.95
0.9
0.85
0
1000
2000
3000
4000
5000
6000
7000
Strategy 2: Simple Prediction
Strategy: Prediction. Security No:2
1.3
1.2
1.1
1
0.9
0
1000
2000
3000
4000
5000
6000
7000
Strategy 2: Simple Prediction
Strategy: Prediction. Security No:3
1.2
1.1
1
0.9
0
1000
2000
3000
4000
5000
6000
7000
Strategy 3: Simple Mean Reverting



The difference between market price and filtered price is
believed to be around zero. So we can play mean reversion on
the spread of filtered price and market price.
However, this spread is not tradable.
We develop our strategy in this way:




If the spread is too large, consider it an opportunity first;
Examine whether the change in filtered price would likely offset the
significance of the spread;
If not so, enter into new position;
We can achieve it with prediction coefficients (same as we used in
strategy 2).
Strategy 3: Simple Mean Reverting



There will be at most 4 threshold in this strategy. Running
optimization for these threshold is extremely time-consuming.
We did only for EUR/USD pair and apply the same thresholds on
the other two pairs
Refer to “qt_Strategy_SimpleMeanReverting.m”
Strategy 3: Simple Mean Reverting

Result:
Strategy: Mean Reversion. Security No:1
1.2
1.1
1
0.9
0
1000
2000
3000
4000
5000
6000
7000
Strategy 3: Simple Mean Reverting
Strategy: Mean Reversion. Security No:2
1.4
1.2
1
0.8
0
1000
2000
3000
4000
5000
6000
7000
Strategy 3: Simple Mean Reverting
Strategy: Mean Reversion. Security No:3
1.1
1.05
1
0.95
0.9
0
1000
2000
3000
4000
5000
6000
7000
Strategy 4: Moving Average


Moving averaging is the main beautiful result of the paper;
It is suggested by the author of the paper that moving
average of errors goes to zero in time:
ν t + ν t + 1 + ⋯ + ν(t + N)
MAν,N (t) =
N+1
Limn→∞ MA = 0
Strategy 4: Moving Average

In the paper, on daily USD/EUR series, with window size of
100, this model can achieve >80% accuracy in trend
prediction.
Strategy
Strategy
Moving Average
by moving4:
average

However, in our work, moving average doesn't go to zero
always.
3
x 10
-4
MvAvg - EUR/USD
2.5
2
Moving Average
1.5
1
0.5
0
-0.5
-1
-1.5
-2

0
200
400
600
Window Size
800
1000
moving average of error terms under different window sizes at 20091201
1200
Strategy
Strategy
Moving Average
by moving4:
average

At the same time, the prediction power of moving
average seems to be "only better than bet" in our halfyear sample
Strategy
Strategy
Moving Average
by moving4:
average
53.5%
53.0%
52.5%
Accuracy
52.0%
51.5%
1-day prediction
51.0%
3-day prediction
50.5%
5-day prediction
50.0%
49.5%
49.0%
48.5%
2

4
8
12
20
Window Size
50
300
1000
Forecast Accuracy – if moving average can predict future price
(based on AUD/JPY data from 2009Q4 to 2010Q1)
Strategy
Strategy
Moving Average
by moving4:
average
60.0%
59.0%
58.0%
57.0%
56.0%
Accuracy
55.0%
54.0%
53.0%
1-day prediction
52.0%
3-day prediction
51.0%
5-day prediction
50.0%
49.0%
48.0%
47.0%
46.0%
2

4
8
12
20
Window Size
50
300
1000
Forecast Accuracy – if moving average can predict future
filtered price (based on AUD/JPY data from 2009Q4 to
2010Q1)
Strategy 4: Moving Average

1865
Even the result of the paper can be remade here, it only
captures the difference of price and trend. This spread is
not tradable. (even the spread narrows as expected, the
direction of market price may vary.
1855
1870
1860
1875
1865
1870
1875
Strategy 4: Moving Average



We develop a similar strategy
Simple moving average equally considers new information
and n-period past information. The entry of new price and
the leave of past information cause same important pulse
in moving average.
To avoid complex weighted average, we choose to use
two moving average indicators, so that recent information
become more important and the leave of one single past
price will not affect the indicator too much.
Strategy 4: Moving Average



Buy if both two moving average are below zero
Sell if both two moving average are above zero
Refer to “qt_Strategy_MvAvg.m”
Strategy 4: Moving Average

Result
Strategy: Moving Average. Security No:1
1.6
1.4
1.2
1
0.8
0
1000
2000
3000
4000
5000
6000
1 year account value EUR/USD (2010Q2 to 2011Q1) window1 = 4; window2 = 8
7000
Strategy 4: Moving Average
Strategy: Moving Average. Security No:2
1.6
1.4
1.2
1
0.8
0
1000
2000
3000
4000
5000
6000
1 year account value AUD/JPY (2010Q2 to 2011Q1) window1 = 4; window2 = 8
7000
Strategy 4: Moving Average
Strategy: Moving Average. Security No:3
1.2
1.1
1
0.9
0
1000
2000
3000
4000
5000
6000
7000
1 year account value GBP/USD (2010Q2 to 2011Q1) window1 = 4; window2 = 8
Strategy 4: Moving Average – Optimized
Parameters


Next consider there exists an optimal position to every
moving average value.
Inspired by the result of mean-reverting example in class,
we assume the optimal position is −𝑎 𝑀𝑉1 ∗ 𝑀𝑉2 +
𝑏 ∗ |𝑀𝑉1 + 𝑀𝑉2|



MV1 and MV2 stand for two value of moving average
Visit this expression only if both moving average are negative
(positive)
The optimal position is positive related to the size of moving
average, but if it’s too large, the position would also decrease
Strategy 4: Moving Average – Optimized
Parameters




Fix a=1 in above expression. We run optimization for four
parameters: window size of MV1, window size of MV2,
order multiplier in FIR, and b in last expression.
Optimization run on 2009Q4 to 2010Q1 data;
Performance result plot for 2010Q2 to 2011Q1.
Due to great amount of computation needed, we run for
EUR/USD only at this moment.
Strategy 4: Moving Average – Optimized
Parameters
Strategy: Moving Average with Optimized Parameters. Security No:1
2
1.5
1
0.5
0
1000
2000
3000
4000
5000
6000
7000
1 year account value EUR/USD (2010Q2 to 2011Q1) window1=4; window2
=40; p=0.75; b=8
Strategy 4: Moving Average – Optimized
Parameters
Strategy: Moving Average with Optimized Parameters. Security No:2
2.5
2
1.5
1
0.5
0
1000
2000
3000
4000
5000
6000
7000
1 year account value AUD/JPY (2010Q2 to 2011Q1) window1=4; window2
=40; p=0.75; b=8
Strategy 4: Moving Average – Optimized
Parameters
Strategy: Moving Average with Optimized Parameters. Security No:3
2
1.5
1
0.5
0
1000
2000
3000
4000
5000
6000
7000
1 year account value GBP/USD (2010Q2 to 2011Q1) window1=4; window2
=40; p=0.75; b=8
Summary

Mathematics


Achievement



In this project, we successfully replicated all the mathematical
terms described in the paper, including filtered price, z
transformation and moving average errors.
We developed 4 strategies by applying the mathematical terms
as trading indicators.
Impressive return was achieved especially with Strategy 4:
moving average of the error terms
Further work


Leverage, commission and slippage can be included in the
trading model
Optimization can be applied on many trading parameters