Turtle Paper

  • Upload
    p3xdnr

  • View
    225

  • Download
    0

Embed Size (px)

Citation preview

  • 8/3/2019 Turtle Paper

    1/21

    From Autocorrelations to Trends: Profitable Ideas for High-Frequency

    FX Trades

    Abstract:

    This article discusses the stochastic non-stationary attributes of high-frequency data within a non-

    technical heuristic framework. This is done in the context of high-frequency financial time series data

    exhibiting stochastic non-stationarity characteristics. The article then discusses the need and means to

    turn non-stationary financial time series data into a mean-reverting stationary series within the context

    of a profitable algorithmic quantitative trading model. Finally it provides a comprehensive description of

    the creation of such a profitable model using one-minute frequency FX data. The out-of-sample results

    of the model are presented with the accompanying trade statistics.

  • 8/3/2019 Turtle Paper

    2/21

    Responding to a Transforming Market

    As volatility continues to rise amidst unprecedented market instability, todays Commodity Trading

    Advisors (CTA) can no longer rely on low-frequency trading methodologies that draw on day-old data.

    Each new bail-out plan, bank failure and unemployment report that is released throws traders into a

    whirlwind of chaotic activity as volumes of shares drag indices to new lows before rapidly seesawingupward, often in the course of a few hours, let alone a whole day.

    To profit in this environment, todays CTAs need strategies that are equipped to respond to industry

    events and their ensuing market changes in real-time as they happen, instead of 24 hours later.

    While high-frequency trading was once relegated to large hedge funds with hefty technology budgets

    and staff, recent years have seen the emergence of numerous high-frequency solutions that have

    brought this style of quantitative trading within reach of much smaller funds and institutions. As the

    global recession continues to rage, it is the ideal time for CTAs to augment low-frequency strategies by

    entering the arena of high-frequency trading.

    Yet as the market continues to balance on top of a shaky foundation, even many traditional high-

    frequency strategies can lead anxious traders astray. Stalwart trend following models such as the Turtle

    Trader no longer can guarantee profits or quickly respond to rapidly changing market conditions.

    However, by building on top of successful quantitative ideologies such as the Turtle, traders can revamp

    existing high-frequency models to gain control of their trades and restore profitability.

    In this paper, we will use the quantitative trading platform Alphacet Discovery to explore the

    fundamental differences between high and low-frequency trading to demonstrate how CTAs can

    increase profits by developing a new type of quantitative model. Specifically, we will focus on how

    traders can employ functional transformations on raw data series to remove autocorrelations and

    decrease the randomness of market data.

    Taking Control of High Frequency Data

    High frequency trading environments for data processing that generate profitable signals pose

    challenges to quantitative traders that differ from those associated with low-frequency environments.

    While traditional quantitative techniques are employed to develop low-frequency (one day and above)

    models that formulate pattern recognition and trend following rules for pure speculative trading based

    on market inefficiencies, these models fall apart in high-frequency settings (intra-day and as low as sub-

    second) at the same pace at which data streams in these settings.

    For example, traditional technical rule-based ideas involving calculations of averages by employing

    EMAs, SMAs and a number of such variants fail to perform as expected and in fact display patterns that

    contradict the expected behavior of the results of trades employing such settings. These breakdowns of

    expected results are consistently noticed across the breadth of ideas in various degrees of intensity. The

    breakdown to which we are referring includes both cases of exploding profits and extremely steep

  • 8/3/2019 Turtle Paper

    3/21

    losses, affording to the traders an inability to measure risks and incorporate those risks into their trading

    algorithms.

    The major reason, well acknowledged in technical literature, for this contradictory behavior of

    traditional algorithms is the intense autocorrelations that high-frequency data have been observed to

    exhibit across asset classes. In the FX world, for example, traders have noticed that a succession of bidand ask quotes that tend to follow each other result in the presence of negative-autocorrelation in the

    associated high frequency data. These autocorrelation patterns that creep into the system more

    because of market-microstructure issues as opposed to temporary inefficiencies in the low-frequency

    world, are primarily responsible for the failure of traditional quantitative rule-based trading algorithms

    in high-frequency environments.

    One scientific way of turning high-frequency time series with auto-correlations into profitable trading

    signals involves transformations of these stochastically trending, non-stationary series (or otherwise

    series with complex multi-lag autocorrelations) into a stationary series with a consistent mean-reverting

    behavior. Econometrically, stationarity is defined as the invariance of distributional properties of time

    series data to shifts in time origin. This translates to statistically tractable moments of the probabilistic

    distributions of data in a time series.

    Functional transformations of non-stationary financial time series data into a stationary series are very

    often carried out by researchers to turn the original non-stationary series into a series that exhibits,

    what is technically termed, covariance stationarity. Since most of the financial time series data can be

    placed within a Gaussian framework with assumptions of normality, the first-order and second-order

    moments of the distribution of the data Mean and Standard Deviation can be used to

    calculate/describe the higher order moments.

    Technically speaking, this pertains to the assumption, and also the observance, of convergence ofquadratic variation (loosely speaking, the volatility) of this data. This empirical quality of financial time

    data betrays itself to the notion of stationarity that, when visually represented and examined, swings

    consistently around a constant mean, exhibiting what is popularly termed as a mean-reverting behavior.

    This kind of mean-reversion with swings in either direction serves as a very intuitive and graphical

    description of covariance-stationarity.

    In the quantitative trading world, mean-reverting series betray themselves to transformations that

    accord a high degree of predictability to the researcher. The average swings, or an away-move from the

    mean, as well as the average time taken for a stationary time series to take a round trip around the

    mean are calculations that become invaluable to a quantitative researcher, especially in the algorithmic-trading world. A long/short strategy then would only entail the researcher to quantify either the average

    round-trip time or the average swing on either side of a constant mean or both, in order to construct an

    algorithm that would programmatically employ a profitable long-short strategy.

    Also, since the quantification of the above mentioned parameters is subject to minor variations and not

    strictly predictable, a layer of machine-learning algorithms over multiple assumptions of the parameters

  • 8/3/2019 Turtle Paper

    4/21

    to optimize on the signals by a dynamical identification of the regimes within which the various hues of

    the parameters become active.

    A New Model for a New Environment

    Here we employ a simple framework on high-frequency (one-minute) EURJPY FX data to explore the

    practical implications of the above described procedures. The exercise first turns the high-frequency

    non-stationary series into a stationary series by removing both the stochastic and time-drifts. This is

    achieved by employing a popular mean-reverting trading strategy called the Turtle-Soup-reversal (see

    appendix) to produce a mean-reverting equity curve with some time-drift.

    In the next stage, this time-drift is removed by employing a slow/fast exponential moving average (EMA)

    calculation. Finally, the resulting stationary equity curve is turned into a profitable equity curve by

    exploiting a tractable mathematical slope exhibited by the curve. Two such signals are fed into a neural

    network, a linear perceptron optimizing on the profitability of the signals, to produce secular profitable

    equity curves over a three-month period. The model is then tested out-of-sample over three more

    three-month periods to showcase the consistency of the methodology.

    The strategy is constructed as shown in Figure 1 below with the flow from top to bottom following the

    methodology described in the previous section. Also, the timeframe and the frequency selected to

    conduct the initial test are displayed in Figure 2.

    Figure 1

    Figure 2

  • 8/3/2019 Turtle Paper

    5/21

    In Figure 1 above:

    Box S1 has the selected time series data for this experiment (EURJPY FX pair) Box I2 Turtle-Soup-Reversal contains a pre-programmed Turtle-Soup-Reversal algorithm (see

    appendix) that is employed on the raw FX time series to produce the first stage of a stationary

    equity curve Box I3 has an instance of a pre-programmed EMA-50 (50 minutes in our case) and another

    instance of EMA-100(100 minutes here)

    Box R4 contains a rule (it subtracts the EMA-100 of the EURJPY data from its EMA-50) thatconducts the second stage of the conversion to stationarity by removing the time-drift from the

    equity curve produced by the Turtle-Soup-Reversal algorithm from the previous stage

    Boxes I5 Slope-SMA-100 and I6-Slope-SMA-50 are the two instances of the slopecalculations on the stationary equity curve from the previous stage that produce secular

    profitable curves. These signals are in turn fed into a Perceptron-Profit-Linear neural network

    (Box C7) for the final set of optimized Long/Short signals

    The stochastic non-stationarity of the raw data representing the one-minute frequency EURJPY FX pair

    for dates between 01/02/2008 and 04/15/2008 can be visually seen from its graph in the figure below.

    Figure 3

  • 8/3/2019 Turtle Paper

    6/21

    The intention of processing this data further by employing a traditional mean-reversal system (Turtle-

    Soup-Reversal) is to work around the above visually-noticeable stochasticity in the data time series.

    The Turtle-Soup-Reversal works on a strategy level on its own and produces buy-sell signals that would

    in a traditional low-frequency environment be expected to produce secular (positive or negative) equity

    curves. But, in the context of a highly non-stationary high-frequency series dominated by stochastictrends over time trends (low-frequency data series exhibit both stochastic and time trends, but in low-

    frequency environments generally time trends dominate stochastic trends) the same algorithm is

    expected to produce a mean-reverting equity curve (a zero-sum bet if you may).

    The buy-sell signals produced by the Turtle-Soup-Reversal strategy are binary +1 and -1 signals that

    prompt the algorithm to go long and go short at these occurrences of +1s and -1s respectively. Capturing

    signals as unit vectors or pure directional suggestions, untainted by their scalar potential (expected

    profits/profit%, expected losses/loss% etc), and letting the algorithm (Turtle-Soup-Reversal in our case)

    do its job of interpreting the signals in conjunction with the coded scalar constants/routines (trade

    management rules etc) gives the algorithmic trader a very powerful technical hold on these signals,

    enabling him/her to reprocess these signals in very intuitive and innovative ways, as we attempt to show

    in the next layer of the strategy.

    The results of the application of the Turtle-Soup-Reversal algorithm on the raw series can be seen in

    Figure 4 below

    Figure 4

  • 8/3/2019 Turtle Paper

    7/21

    The figure above clearly illustrates how the desired results were achieved. The above equity curve starts

    at 0 and ends at 0 thus fulfilling the first stage of removal of stationarity. But, a clear time-trend can also

    be discerned from the figure that is preventing the strategy from making any 0-crossings (mean-

    reversion turns) throughout the time period. Technically, this means that the mean returns from the

    strategy did not stay constant and exhibited a drift away from a constant (0 mean in our case) for half

    the time and a similar drift towards the constant for the second half of the period.

    The next stage of the strategy tries to remove this drift-in-mean exhibited by the above curve. The

    secular convex nature of the drift (visually speaking imagine a bow-like smooth curve starting at 0 at the

    first period and smoothly passing through the equity curve to the last period and reaching 0 again) is the

    main motivation if choosing a EMA crossover like framework to negate this convex drift exhibited by the

    curve (EMAs by construction weigh the lagged periods according to their distance from the

    contemporaneous point thus helping in working around such drifts).

    Taking up from where we left off previously in our discussion regarding the reprocessing of the +1 and

    -1 signals that the Turtle-Soup-Reversal routine produces, we try and achieve the above mentioned

    objective of removing the drift-in-mean from the Turtle-Soup-Reversal stage of the strategy by an

    intuitive functional transformation of the signals to capture what we call directional intensity of the

    Turtle-Soup-Reversal algorithm. Since the Turtle-Soup-Reversal produces +1s and -1s as signals, and the

    fact that acting upon these signals instantaneously produced an equity curve with a drift-in-mean, we

    device a simple scheme involving a slow/fast averages system (very familiar to technical traders), that

    acts upon the Turtle-Soup-Reversal system, and executes buys and sells at opportune moments

    prompted by a calculation involving the directional intensity of the Turtle-Soup-Reversal algorithm.

    The directional intensity of the signals is estimated by calculating the average directional suggestion and

    intensity prevailing in a time window. This is done by summing up the +1s and -1s produced by the

    Turtle-Soup-Reversal algorithm and dividing this by the length of two designated time-windows (a

    slow long window and a fast short window) individually. These individual calculations reveal the bias

    within the system prevailing for the chosen window length for each of the averages. An equal number of

    +1s and -1s in the window return a zero value. But if the +1s exceed the -1s and vice versa, the sign of

    the average (+ or -) reveals the directional bias (more long signals than sort in the window if the

    calculation is > 0 and vice versa) and its value reveals its intensity (+15 VS +0.75 as an extreme example

    reveals a big difference between number of long signals and short signals in the window etc). Now, if

    this system takes cues from the fast average (shorter window average) crossing the slow average

    (longer window average), with crossing from below treated as a Long signal, and from above as a

    Short signal (a very typical crossover system again very familiar to technical traders), it would be

    treating the short-term (slow moving averages) directional intensity as the leading indicator and the

    long-term (fast moving averages) directional intensity as the reference indicator to remove the drift

    bias from the equity curve produced by the Turtle-Soup-Reversal algorithm form the previous step. We

    construct such a system by employing a EMA-100 and EMA-50 system in the rule R4 within the strategy.

    The chart below displays a crossing that we discussed above of the system making for a very compelling

    visual demonstration of the idea.

  • 8/3/2019 Turtle Paper

    8/21

    Figure 5 below displays the +1 and -1 signals of the Turtle-Soup-Reversal strategy as the vertical bars

    above and below the zero-line (x-axis) and the tracking EMA-100 and EMA-50 calculations can be seen

    oscillating around the zero-line.

    Figure 5

  • 8/3/2019 Turtle Paper

    9/21

    Figure 6 below has a closer look at a particular snapshot of the system where two -1 short signals from

    the Turtle-Soup-Reversal algorithm are not acted upon and, in fact, the EMA-50 crossover of the EMA-

    100 from below occurs right after these signals resulting in a Long signal generated by the system. This

    is a very dramatic representation of the directional intensity system that we discussed above.

    Figure 6

  • 8/3/2019 Turtle Paper

    10/21

    As mentioned before, the rule R4 in the strategy achieves this objective of generating signals by acting

    upon the directional intensity of the Turtle-Soup-Reversal algorithm, by employing slow and fast moving

    averages in the form of EMA-100 and EMA-50 respectively and removes the time drift from the equity

    curve generated by the Turtle-Soup-Reversal system. This can be seen from the equity curve of the EMA

    crossover system (Rule R4) displayed in Figure 7 below.

    Figure 7

    The one noticeable technical feature of stationary time series are the increasing and decreasing slopes

    culminating inflexion points. This translates to the increasing profits topping out at peaks and taking aroute downward a similar slope, this time giving away the profits and entering negative territory and

    bottoming out at points roughly corresponding top the profit peaks. This behavior when consistent, like

    in the equity curve produced by our rule R4, can be exploited by tracking the mathematical slope of a

    smoothened average of the equity curve. Such a system is interpreted to produce long trades for

    positive slopes and short trades for negative slopes makes it possible to turn-around a stationary 0-sum

  • 8/3/2019 Turtle Paper

    11/21

    equity curve into a secular curve with an upward trending bias (buying when rising and selling when

    falling should on an average produce an upward trending curve.

    We employ a Slope-SMA-100 (that tracks the slope of the smoothened 100-period simple moving

    average of the stationary equity curve) and also a similar 50 period system in the form of a Slope-SMA-

    50 that does the same on a 50-period basis (Periods translate to minutes in our strategy).

    We also try optimizing on the profitability of both the Slope-SMA systems by employing a Perceptron-

    Profit-Linear neural network system (see appendix) that dynamically weights the two SMA systems to

    stabilize the profitability of the strategy, i.e., it continuously learns a linear combination of the two

    systems it takes as input that maximizes profit.

    The following graphs in Figure 8 and Figure 9 display the equity curves for the two Slope-SMA systems.

    Figure 8 Slope-SMA-100

  • 8/3/2019 Turtle Paper

    12/21

    Figure 9 Slope-SMA-50

    As we see, the Slope-SMA-50 systems performance was not as good as that of the Slope-SMA-100

    system.

    We now check on the optimized equity curve produced by the Perceptron-Profit-Linear neural network

    system to see for any improvements over the individual SMA systems. The Perceptrons equity curve is

    displayed below in Figure 8.

  • 8/3/2019 Turtle Paper

    13/21

    Figure 10

    The secular upward trend of the equity curve produced by the final leg of the strategy gets us to the

    point where we would want to check the out-of-sample results of the strategy over a sufficiently long-

    period. For this leg of the exercise we chose to run the strategy over progressive three-month windows(with the same 1-minute frequency) starting the next day to the last day of the research-sample leg. This

    translates to data choices displayed below.

    The final results for the above three out-of-sample periods are shown in Figure 11, Figure 12 and Figure

    13 below.

  • 8/3/2019 Turtle Paper

    14/21

    Figure 11: Period 1; 04/16/2008 to 07/15/2008: negative 5% returns.

    Figure 12: Period 2; 07/16/2008 to 10/15/2008: Positive 13% returns.

  • 8/3/2019 Turtle Paper

    15/21

    Figure 13: Period 3; 10/16/2008 to 01/15/2009: Positive 21% returns.

    The first and the last periods returned healthy positive returns (13% and 22% respectively) more than

    negating the negative returns in period 2 (-5%). This showcases how we managed to induce an overall

    positive bias within the results of the final optimized leg of the strategy as we had set out to achieve

    initially.

  • 8/3/2019 Turtle Paper

    16/21

    Finally we present some statistics related to the trades from the research period and the three out-of-

    sample periods in the Figures 14, 15, 16 and 17 respectively.

    Figure 14 Research Period: 01/02/2008 to 04/15/2008

  • 8/3/2019 Turtle Paper

    17/21

    Figure 15; Out-of-Sample Period 1: 04/16/2008 to 07/15/2008

  • 8/3/2019 Turtle Paper

    18/21

    Figure 16; Out-of-Sample Period 2: 07/16/2008 to 10/15/2008

  • 8/3/2019 Turtle Paper

    19/21

    Figure 17; Out-of-Sample Period 3: 10/16/2008 to 01/15/2009

  • 8/3/2019 Turtle Paper

    20/21

    Final Analysis: The advent of technology and availability of powerful technical systems in recent

    times facilitates the marriage of complex modeling philosophies with rapid prototyping techniques. We

    discussed in detail one such idea in his article within a rapid prototyping environment offered by a new-

    age strategy development tool. The explorative R&D exercise that we undertook showcases a very

    atypical approach to researching and developing trading algorithms that stands in stark contrast to the

    traditional approach facilitated by black boxes and code-intensive systems. Though the advantages of

    coding ground up cant be discounted, the advantages of brain-storming and exploring innovative ideas

    in a pre-built trade-specific infrastructure is too compelling to be ignored. A case in point is what we

    achieved in this article; bringing disparate systems - in the form of Turtle-Soup-Reversal algorithm, well-

    known EMA crossover systems and ideas from high-frequency statistical systems - together within an

    all-inclusive technical-tool that facilitated this in an intuitive code-less visual model-building

    environment, and putting together a trading system that showed promise in terms of deployment as a

    model as well as a system for future R&D.

    For questions or to schedule an in depth demonstration or request additional strategy examples, please

    [email protected]

    mailto:[email protected]:[email protected]:[email protected]:[email protected]
  • 8/3/2019 Turtle Paper

    21/21

    Appendix

    Turtle Soup Reversal system:

    FOR BUYS (SELLS ARE REVERSED)

    1. Present period must make a new 20-period low; the lower the better;

    2. The previous 20-period low must have occurred at least four trading sessions prior. This is very

    important;

    3. After the market falls below the prior 20-period low, place an entry buy stop five to ten-ticks above

    the previous 20-period low. This buy stop is good for today only;

    4. If the buy stop is filled, immediately place an initial good-till-cancelled sell stop-loss one tick under

    present periods low;

    5. As the position becomes profitable, use a trailing stop to prevent giving back profits. Some of these

    trades will last two to three hours and some will last a few days. Due to the volatility and the noise at

    these 20-period high and low points, each market behaves differently;

    6. Re-entry Rule: If you are stopped out on either period one or period two of the trade, you may re-

    enter on a buy-stop at your original entry price level (period one and period two only). By doing this,

    you should increase your profitability by a small amount;

    Perceptron-Profit-Linear-LBTF

    Perceptrons are pattern-recognition machines analogous to human neurons. They are capable oflearning by means of a feedback system that reinforces right answers and discourages wrong ones.

    Standard linear perceptrons move iteratively using gradient descent towards the best linear least

    squares fit returned by linear regression. Ordinarily, perceptrons are run on a training data set an then

    the weightings for the input variables are locked down for out of sample testing and live trading,

    perhaps being retrained and updated periodically. But here Weight updating is continuously calculated

    on an ongoing basis producing a dynamic linear combination of the input variables (series).

    Perceptrons can be very interesting tools for financial time series modeling because they can be

    sensitive to recent data and over-compensate or under-compensate due to recent data points - this

    behavior makes them useful for modeling similar over-reactivity or under-reactivity among marketparticipants.

    Perceptrons learn a linear equation of the inputs (say X1, X2) of the form w0 + w1X1 + w2X2.

    The w0 is associated with a Buy and Hold (constant 1.0).