Introduction to QuanTek

(Revised September 4, 2006)

 

by

 

Robert Murray, Ph.D.

Omicron Research Institute

 

(Copyright Ó 2006 Omicron Research Institute.  All rights reserved.)

 

Contents

  1. Stochastic Processes and Filtering
    1. Stochastic Processes
    2. Linear Prediction Filter
  2. Technical Indicators in QuanTek
    1. Price Projection
    2. Buy/Sell Signals
    3. Momentum Indicators
  3. Portfolio Optimization in QuanTek
    1. Optimal Portfolio
    2. Short-Term Trades Dialog
    3. Portfolio Report
  4. Statistical Tests in QuanTek
    1. Hybrid LP Filter
    2. Correlation Test – Filters
    3. Spectrum Periodogram
    4. Spectrum Wavelet
    5. Correlation – Returns
    6. Correlation – Auto & Cross
    7. Technical Indicators
    8. Correlation Test – Indicators
    9. Diagnostic Test
  5. Graphs and Displays in QuanTek
    1. Main Graph
    2. Splitter Windows
    3. Harmonic Oscillator Splitter Window
    4. Momentum Indicators Splitter Window
    5. Trading Rules Splitter Window
  6. Other Features
  7. References

 


QuanTek is a stock (and indexes, mutual funds, futures, etc.) trading program designed for short-term traders and long-term investors.  The main purpose of QuanTek is to find correlation in the stock price data and then design technical indicators and Trading Rules to take advantage of this correlation.  In this way QuanTek makes use of the most state-of-the-art principles of Econometrics, as well as Digital Signal Processing, available at the present time.  QuanTek also incorporates a Portfolio Optimization routine, to compute the optimal portfolio to yield maximum returns with minimum risk.  This is a standard computation from Modern Portfolio Theory (slightly modified, actually).

 

QuanTek has many state-of-the-art features, but the most important feature of QuanTek is the capability to design a set of custom technical indicators, and then use the built-in correlation tests to actually test their effectiveness, by measuring the correlation of these indicators with future returns.  These indicators are adjusted for maximum correlation with the future returns, over a period of (normally) 2048 days, and then Trading Rules are derived from these indicators.  The technical indicators, in turn, rely on the Price Projection, which uses a custom Linear Prediction filter to make an estimate of future returns based on the correlation (if any) present in the past returns.  Also used in the construction of the technical indicators is a state-of-the-art Savitzky-Golay smoothing filter, which is a modern version of the familiar moving average smoothing.  This Savitzky-Golay smoothing filter has the advantage that it is acausal, so there is no time delay as in the conventional moving average.  (This requires, of course, that it be used in conjunction with the Linear Prediction filter.)  In this way it is easier to keep all the technical indicators in phase, which is an important feature of QuanTek.  You can adjust the time scale of smoothing, and the time lag or phase, to arrive at a wide variety of indicators.  You adjust the time lag for maximum correlation with one-day future returns, in order to assure the effectiveness of each indicator.  (This assumes that the correlation of the returns itself is persistent, unlike the traditional assumption that the mean of the returns or trend is persistent.  Since the correlation is measured over a period of 2048 days, we feel this is a reasonable assumption.)

 

At this point we would like to warn you that QuanTek is merely a tool to help you time your trades for increased returns with reduced risk.  It is still of utmost importance for each investor or trader to use his or her own judgment in all investment or trading decisions.  The ultimate responsibility for wise investing or trading rests with you, the investor or trader.  The QuanTek program can help you time your trades more accurately, but QuanTek cannot supply all the information you need to make fully informed trading decisions.  You should take into account the overall condition of the economy, as well as the health of various business sectors and the fundamental condition of each company you want to invest in.  It is only after these factors have been considered that you should engage in long-term investing or short-term trading in any particular company’s stock.  (This is also why QuanTek does not tell you which stocks to buy!)  Even after this, you should always let your own judgment be the final criterion for each and every investment or trading decision.  It is always unsafe to blindly trust the advice of any financial guru, broker, investment newsletter writer, as well as any software product, without subjecting it to your own critical examination and making the final judgment yourself!

 

Stochastic Processes and Filtering

In the usual approach to Technical Analysis [Edwards & Magee (1991)], one looks for certain patterns in the past stock prices, which indicate potential buy/sell points.  This is because these patterns in past prices are thought to be correlated with future up-trends or down-trends, either a change in trend from up to down or down to up, or a continuation of the current trend.  These standard technical indicators are probably so well known by now that they are largely ineffective, since everyone follows them, and in addition they were more effective 50 to 80 years ago, when the markets were much smaller and much less efficient than they are now.

 

The QuanTek program works a little differently from the usual Technical Analysis program.  QuanTek makes use of the state-of-the-art techniques of Signal Processing to construct new types of technical indicators.  These technical indicators are tested for correlation with future returns, and adjusted for the optimum correlation.  Then a set of Trading Rules is constructed directly from these indicators.  However, these technical indicators are constructed using the same basic principles as the standard indicators, but utilizing modern computer routines which would have been impossibly difficult to use by hand in the old days.  The technical indicators used by QuanTek essentially encompass all of the linear oscillator-type indicators that utilize past price data alone.

Stochastic Processes

Financial returns data constitute what is known as a stochastic process.  The simplest type of stochastic process is the familiar Random Walk.  It was first postulated over a century ago that stock prices follow a Random Walk.  It is still hotly debated even now whether this is in fact the case.  Many people, when performing a statistical analysis of stock data, are unable to discern any statistically significant difference between stock price series and a Random Walk.  My position is that the stock prices are not even a Random Walk.  A Random Walk (with drift) is a stationary stochastic process, meaning that the statistical properties do not change with time.  In particular, if the price series were a Random Walk, then it would have a constant drift velocity or secular trend.  In that case, the only sensible investment strategy would be buy & hold, to take advantage of this secular trend, which would always be constant.  This is really quite a strong prediction of future price action!  However, this is too good to be true, and evidently the constancy of this secular trend is too much to ask.  Instead, it appears that price returns data constitute a non-stationary stochastic process.  This means that the statistical properties vary with time, including the drift velocity or trend, and the correlation structure.  So in this case, the optimal strategy is one of active trading.  The purpose of the QuanTek program is to try to determine the optimum Trading Rules to take best advantage of this non-stationary correlation structure.

 

QuanTek has the capability to construct a variety of different technical indicators and measure the correlation between these and the future returns.  The typical length of the (daily) data set used is N = 1024 days, or about four years.  This means that there is a statistical uncertainty in the measurement of the correlation of about  or 3.125%.  However, even a correlation of this magnitude could give a very nice annual gain if it were real, depending on the average daily volatility of the price returns.  So this is the quandary:  Small correlations can yield substantial profits from short-term trading, but these small correlations are buried in the stochastic noise and are of the same order of magnitude as the noise.  This is the reason why researchers in the past have not been able to discern any (statistically significant) difference between stock returns data and random (white) noise.  Furthermore, the financial time series should be taken as a non-stationary stochastic process, so the correlation structure will be time dependent.  So the problem is how to extract useful non-stationary correlations from the stochastic noise and convert this correlation into profitable trading rules.  That is the problem that the QuanTek program would like to address.  However, this is difficult because, for daily price data, there really is not enough data to measure time-varying correlation.  The technique used in the QuanTek program is to model the presumed correlations by means of a Linear Prediction filter, assuming stationarity over the past 1024 days, then to use this filter to make a Price Projection and derive Trading Rules.  Whatever correlation exists must be due to inefficiencies caused by investor behavior, and presumably this behavior can be considered more or less constant over a four-year interval.  However, our goal for future versions of QuanTek is to find an adaptive filter that can handle the non-stationary time series.

 

It should be mentioned that in the case of stationary stochastic processes, the law of large numbers is used to prove theorems about the existence and uncertainty of correlations.  The correlation is only defined in the limit as the size N of the data set goes to infinity.  For a non-stationary stochastic process we do not have this luxury.  In fact, one major problem with financial time series is that the actual amount of data is rather sparse, so the statistical uncertainties are always large.  If the correlation changes over an interval of N days, then the statistical uncertainty in the correlation will be  and will never improve beyond that, no matter how long the data set is.  So how can we ever prove the existence of correlation and the effectiveness of Trading Rules?  Instead of the limit , which is usually used in the theory of stationary stochastic processes, we can in the present case substitute an average over a large portfolio of stocks.  The Linear Prediction filter is applied to the returns series of each individual stock, and it yields Trading Rules for that stock which give a certain return per year.  This return per year for an individual stock may be substantial, but the standard deviation of the return will also be substantial and will be of the same order of magnitude.  However, if we keep applying the Linear Prediction filter to the stock over a long period of time, the returns should be proportional to time N, while the standard deviation of returns only increases like .  So eventually after a period of time, the average returns should become much greater than the uncertainty in returns.  We can likewise reduce the standard deviation, relative to the returns, still further by computing the Trading Rules for an entire portfolio of stocks.  The average return for the portfolio should remain roughly the same when the number of stocks is increased (for a given equity), while the standard deviation of returns (risk) for the portfolio should decrease like  for a portfolio of M stocks (assuming the stocks are uncorrelated).  More generally, it is given in terms of the variance-covariance matrix for the portfolio.  This is where the Portfolio Optimization routine in QuanTek comes in.  The return for the whole portfolio is maximized while the risk, or standard deviation of returns, is minimized, subject to the degree of risk tolerance that you select.  It is only by examining the whole portfolio return over a period of years that the effectiveness of the Linear Prediction filter and Trading Rules can be evaluated.

Linear Prediction Filter

The QuanTek program uses a custom Linear Prediction filter for its future Price Projection.  The way this works, in a nutshell, is as follows:  It is a well-known theorem, the Wiener-Khinchin Theorem [NR (1992)], that the power spectrum of a stationary stochastic process is the Fourier Transform of the autocorrelation sequence.  (We take the time series to be stationary over the 1024-day period, as an approximation.)  Then, starting with the spectrum of the process, it is always possible to compute the corresponding autocorrelation sequence, and given this autocorrelation sequence, the Linear Prediction filter coefficients can then be computed.  The spectrum of the process is measured using the Fast Fourier Transform (FFT) and displayed as a standard Periodogram Spectrum.  Alternatively, the spectrum can be measured using the Discrete Wavelet Transform (DWT) and displayed as the Wavelet Spectrum.  The spectrum contains all the information about the (second-order) correlation in the time series.  If the spectrum is completely flat and horizontal, then there is no correlation and the (returns) series is just “white noise”, and the (price) series is a Random Walk.  If the spectrum shows a peak at low frequencies, then this indicates positive correlation of returns or trend persistence.  If, however, the spectrum shows a dip at low frequencies, then this indicates negative correlation of returns or trend anti-persistence.  So, contrary to dogma, it is not always true that the trend is persistent (trending market).  Sometimes there is a return to the mean mechanism at work (trading market).  This illustrates that the correlation itself can change (slowly, we hope!) over time, and the time series is non-stationary.

 

Another aspect of the custom Linear Prediction filter is that it incorporates what we call a Fractional Difference filter.  This is a filter for fractionally integrated noise processes or so-called long memory processes [Brockwell & Davis (1991)].  The fractionally integrated noise process is characterized by a parameter, which we call the fractal dimension or fractional difference parameter d which ranges from –0.5 to +0.5.  The fractal dimensions in the range  characterize the long memory processes, which exhibit long-term trend persistence.  The fractal dimensions in the range  are sometimes called intermediate memory processes and exhibit short-term anti-persistence.  The long-memory processes are sometimes attributed to fractal statistics.  It is thought that stock data exhibit this type of long memory persistence [Peters (1991, 1994)].  (However, we are finding that this is only true part of the time.)

 

Technical Indicators in QuanTek

QuanTek contains two independent sets of technical indicators.  One is based on the Harmonic Oscillator indicators and yields the buy/sell signals and buy/sell points.  This set of indicators is easy and quick to compute, but is not tested directly.  The other set of indicators is the set of Momentum indicators and the resulting Trading Rules indicator.  The Momentum indicators are designed in the Technical Indicators dialog box, for each stock, and tested in the Correlation Test – Indicators dialog.  The effectiveness of these indicators in terms of their correlation with future returns is tested directly, but the design and testing of these indicators is computation-intensive. 

Price Projection

On the Main Graph is displayed the Price Projection, which is the output of the Linear Prediction filter.  In the present version of QuanTek, there are five different Linear Prediction filters that you can choose from, all of related design.  These filters are univariate, meaning that they only use price data from that particular stock, and are linear, meaning that they work only with linear functions of the past price data.  They also assume stationarity over the past 1024 days of data.  Some of the LP filters are based on the Periodogram spectrum and one of them is based on the Wavelet spectrum.  All these filters work by trying to compute the autocorrelation of the stock data returns from the spectrum, and using this computed autocorrelation to make a future prediction, assuming stationarity.  The hope is that, at least for the low-frequency part of the spectrum, long-term correlation exists which can be used for a plausible estimate of the expected return over time intervals up to 100 days.  The Price Projection is then used as part of the calculation of the Momentum indicators and Trading Rules indicator, as well as the Harmonic Oscillator indicators and the display on the Main Graph.  In fact, all of the indicators and displays in QuanTek are extended to a future projection by means of (one or another) Linear Prediction filter.

Buy/Sell Signals

The Harmonic Oscillator indicators consist of three indicators that are called Relative Price, Velocity, and Acceleration.  These three indicators consist of Savitzky-Golay smoothings of the past price data together with the future Price Projection, on a time scale given by the time horizon, and with no derivative, the first derivative, and the second derivative, respectively.  (The derivative is the rate of change, from Calculus.)  Since these are acausal smoothings from the Savitzky-Golay smoothing filter, the filter is zero-phase and there is no phase change at different frequencies, and all the features of the smoothings line up with the original data. 

 

The buy/sell signals are defined from the three Harmonic Oscillator indicators.  A buy signal is triggered if the Relative Price indicator is negative and below a certain level set by the Range control in the Trading and Portfolio Parameters dialog.  Also the Velocity and Acceleration indicators must both be positive.  These last two conditions restrict the range of buy signals to the quarter “cycle” (if the data were sinusoidal) following the minimum of the Relative Price indicator.  A sell signal is triggered if the Relative Price indicator is positive and above a certain level set by the Range control in the Trading and Portfolio Parameters dialog.  Also the Velocity and Acceleration indicators must both be negative.  These last two conditions restrict the range of sell signals to the quarter “cycle” (if the data were sinusoidal) following the maximum of the Relative Price indicator.  The setting of the Range control further restricts the range of the buy/sell signals.  The buy/sell signals are displayed on scale 4 of the Main Graph as green/red rectangles.

 

The buy/sell points consist of the first of a series of buy/sell signals.  Hence a buy point will occur when the Relative Price indicator is at a minimum (min), the Velocity indicator is crossing the zero line moving upward (Z+), and the Acceleration indicator is at a maximum (max).  A sell point will occur when the Relative Price indicator is at a maximum (max), the Velocity indicator is crossing the zero line moving downward (Z–), and the Acceleration indicator is at a minimum (min).  The buy/sell points are displayed on scale 2 of the Main Graph as green/red arrows.  They are also displayed on all of the splitter window displays as vertical green/red lines.  This enables you to line up all the technical indicators in the splitter windows, including the Momentum indicators and Trading Rules indicator, with features in the Main Graph.

Momentum Indicators

The Momentum indicators are computed by first computing a separate Price Projection for each day in the past, going back 1024 days.  This computation is CPU-intensive and takes one or two minutes.  After this is done, then a custom technical indicator can be defined by you, the trader, in the Technical Indicators dialog box.  You can define three separate indicators, and designate them the Momentum 0, Momentum 1, and Momentum 2 indicators.  You can take these to be of the Relative Price, Velocity, and Acceleration types, but this is optional.  Then, having defined a technical indicator, you can test it in the Correlation Test – Indicators dialog box, for correlation with future N-day returns, where N is the time horizon for trading.  You adjust the time lag so that the test shows a positive correlation peak under the ZERO line.  Then, switching back to the Technical Indicators dialog box, this time lag is transferred to the definition of the indicator, which can then be computed and saved.  These three Momentum indicators are displayed in the Momentum Indicators splitter window.  These three Momentum indicators are combined, with weights that you can set, to make the Trading Rules indicator.  The N-day forward average of the Trading Rules indicator is displayed in the bottom pane of the Trading Rules splitter window.

 

Above the Trading Rules indicator in the splitter window, is a display of the N-day (forward average) future returns.  The Correlation Test – Indicators has tested for correlation between the Momentum indicators (N-day forward average) and the N-day future returns.  Therefore, you should be able to see visually the degree of correlation between these two displays.  It will not be perfect, of course, but remember that even a small amount of correlation can lead to very significant gains in short-term trading.  Since the N-day future returns are an N-day forward moving average of the returns, they should lead the Velocity indicator by N/2 days.  So the buy point should be (approximately) N/2 days past the upward zero crossing (Z+) of the N-day future returns and (forward average) Trading Rules indicator, and likewise the sell point should be (approximately) N/2 days past the downward zero crossing (Z–) of the N-day future returns and (forward average) Trading Rules indicator.  So a buy/sell point for short-term trading should be indicated when the (forward average) Trading Rules indicator is near its positive/negative peak (max or min, respectively).  In this way, the (forward average) Trading Rules indicator can be used for independent short-term trading in each stock, independent of the Core Portfolio.  The relative position derived from the (forward average) Trading Rules indicator is also displayed in the Short-Term Trades dialog and the Portfolio Report.  Note also that the Trading Rules can be tested in a variety of simulated short-term trading strategies in the Diagnostic Test.

 

Portfolio Optimization in QuanTek

The Portfolio Optimization routine makes use of the standard Markowitz Model from Modern Portfolio Theory (MPT).  This calculation uses the variance-covariance matrix of all the stocks in the Stock Group, along with the expected returns computed from the Price Projection, to compute an optimal portfolio that maximizes returns and minimizes risk for the overall portfolio.  The result is what we call the Core Portfolio.  The idea is that you make your main long-term investment according to this Core Portfolio, and then supplement the returns by short-term trading using a relatively small fraction of the total equity.  This is the safest way to consistently make maximum returns with minimum risk.

 

You can also specify a simplified method called the Factor Model.  This method only computes the correlation between each stock and some market index that you specify, representing the hypothetical whole stock market.  This method has not been implemented yet and will be implemented in a future version of QuanTek, where the Capital Asset Pricing Model (CAPM) will also be implemented, along with a multivariate GARCH model for the Price Projection.

Optimal Portfolio

The Portfolio Optimization routine computes the variance-covariance matrix of all the stocks in the Stock Group, consisting of all the stocks (not indexes or averages) in a particular folder that have the “Trade this stock?” checkbox checked.  The variance and covariance are based on the average volatility and correlation of the returns between all the stocks.  The variance (actually, standard deviation, the square root of variance) of returns of an individual stock is a measure of its risk.  The other quantity that goes into the calculation is the expected return, which is estimated from the 512-day smoothing of the future Price Projection (together with the past data, of course).  Then a calculation is done to maximize returns for the portfolio as a whole, and at the same time minimize risk.  This calculation is called the Markowitz Model.  This results in an optimal portfolio in which the recommended positions optimize the ratio of return/risk.  This calculation depends on a parameter called the Risk Tolerance (opposite of risk aversion), which you set in the Trading and Portfolio Parameters dialog box.  The other parameter you need to set is the desired Margin Leverage, which sets the overall ratio of the value of the portfolio to the equity of the portfolio.  The results of this calculation are displayed in the Short-Term Trades dialog and in the Portfolio Report.

 

Note: This calculation is not perfect.  Sometimes, if you have a very low priced stock, or other very volatile stock, in the Stock Group, with a very large expected return, this can skew the whole portfolio calculation and result in most of the portfolio being allocated to this stock.  However, such low-priced or volatile stocks are extremely risky, as can be seen in the logarithmic graph, as the price becomes less than $1.00.  We suggest you set the “Trade this stock?” checkbox to “off” and do not include such risky assets in the optimal portfolio at all.  You can still do short-term trading in these stocks, but such risky, volatile assets should not be included in the Core Portfolio.

Short-Term Trades Dialog

The Short-Term Trades dialog is a modeless dialog box, which can be seen from anywhere in the QuanTek program just by right-clicking the mouse.  It displays all the most important trading information for the whole Stock Group of stocks together in one place, to make it easier to see upcoming trades at a glance.  In the main list box of this dialog, each stock is displayed on one line.  (You can open each stock data file by double clicking on this line.)  The line of information starts with the stock symbol and number of shares currently held.  Then the output from the Portfolio Optimization routine is shown, which consists of the recommended number of shares in the Core Portfolio and the percentage of the total equity in the Core Portfolio for each security.  Then the expected annualized return is shown, based on the Price Projection and 512-day smoothing on the Main Graph.  Next is shown a buy/sell/hold recommendation for the upcoming day, at a certain price.  The buy/sell recommendation corresponds to an upcoming buy/sell signal, which can also be viewed on scale 4 of the Main Graph for each stock.  The price is the recommended price for the buy/sell signal.  If there is no buy or sell signal, then the recommendation is for a hold, and the price listed is just the N-day smoothed price.  The last number displayed is the N-day trading position for the next day, for that stock, where N is the trading time horizon.  This is just the (relative) value of the N-day forward average Trading Rules indicator, with ±100% corresponding to a margin leverage of 100% relative to the equity allocated for short-term trading in that particular stock.

 

On the right-hand side of the Short-Term Trades dialog, there is a list box containing a column of prices on the left and a column of percentages on the right.  In the center (vertically) of the list box, corresponding to ZERO percent, the price listed is the estimated closing price for the next trading day.  This estimate is based on the estimate of the next-day return from the Linear Prediction filter.  By clicking on one of the prices in the list box (representing the current intra-day price), it is brought to the center, and then the percentage price difference between the estimated closing price and the intra-day price can be read from the right-hand column.  Each trader can then base his/her day-trading position on this percentage price difference.  This is the most versatile way we could think of to accommodate a wide range of day-trading strategies.  (Note: We don’t emphasize day-trading because the Price Projection seems to work best over time horizons of 5 days or longer, using daily data.)

Portfolio Report

The Portfolio Report contains all of the information in the Short-Term Trades dialog, and more besides.  You can create a Portfolio Report just by clicking the toolbar button.  Then the portfolio information is acquired from the header files of all the securities in the selected folder, or Stock Group, and the report is then compiled.

 

The first part of the Portfolio Report consists of a list of all the securities in the Stock Group, together with information such as the N-day, Expected, and Long-Term Return, and the Standard Deviation.  This is just the information that goes into the Optimal Portfolio calculation.  Next is a section consisting of a list of all the securities actually owned in the portfolio, together with the number of shares, market value, last price, and so on.  Then is a list of the overall portfolio quantities of interest, such as the equity, long and short market value, cash balance, and buying power.  After that is a section listing the Optimal Portfolio calculation, listing the Core Position, Percent of Equity (of the Core Position), then the Buy/Sell/Hold recommendation from the buy/sell signals, and finally the N-day Position from the Trading Rules.  Finally, the Optimal Portfolio calculation yields the Portfolio Margin Leverage (assuming the Margin Leverage setting is 100%), the Portfolio Expected Return, and the Portfolio Standard Deviation.  This calculation then gives you an estimate of the overall long-term performance of the Optimal Portfolio.

 

Statistical Tests in QuanTek

When you first open the QuanTek program, you are presented with a Greeting dialog box that has four large icon buttons on it.  These four buttons correspond to the statistical tests described below, so you can go directly to one of the four tests if you wish.  The same four buttons are available on the toolbar of the Main Window, when no stock data files are open.

 

It should be noted that in addition to being a statistical test of the predictive capability of the Linear Prediction filters, the Hybrid LP Filter dialog (the first button on the Greeting dialog) is used to select the LP filter individually for each security data file.

Hybrid LP Filter

This dialog box opens in response to the first button of the Greeting dialog.  It is used to select the Linear Prediction filter for each security data file, and also to test the effectiveness of these filters for any selected data file (in conjunction with the Correlation Test – Filters dialog).  At present there are five different types of LP filter to choose from.  These are all standard Linear Prediction filters that assume stationarity of the returns data over the past 1024 days.  They differ in the way the covariance matrix and the LP coefficients are calculated.  The first filter selection uses the Discrete Wavelet Transform (DWT) to compute a spectrum, time averaged in each octave, for the returns.  From this DWT spectrum the LP coefficients are then computed.  This method seems to be the best way to average out the stochastic noise while preserving whatever “signal” is present, which seems to be mainly at the low-frequency end of the spectrum.  The second type of filter uses the Fast Fourier Transform (FFT) to compute the spectrum, and from this the LP coefficients.  The third filter type computes the covariance matrix directly from the sample autocovariance sequence.  The fourth and fifth filter types are essentially the same and are variations of the standard Levinson-Durbin algorithm.

 

You can test any of the filter choices for any selection of a security data file.  In general, each security might have a different choice for the optimum filter.  There are two parameters to set in addition to the filter type.  The first is the Order of Approximation, which selects an N’th order approximation by Chebyshev polynomials of the measured spectrum for the filter spectrum.  This is mainly of use for the FFT filter.  In fact, the N’th order approximation is essentially equivalent to using a sequence of LP coefficients of length N.  The second parameter is the Fractal Dimension, also called the fractional difference parameter.  This parameter controls the low-frequency end of the filter spectrum, and models the returns series as a long-memory process.  This parameter must be set by hand for low approximation orders, and it is adjusted for optimum results in the Correlation Test – Filters.  There are also two spectrum displays in the dialog.  The top display is the standard DWT spectrum of the returns, while the bottom display is the filter spectrum, making use of the Maximum Entropy Method of computing the filter spectrum from the LP coefficients.  The goal is to model the filter spectrum after the actual spectrum, while at the same time trying to capture the “signal” while averaging out the stochastic noise.  In general, this involves getting the low-frequency end of the filter spectrum right, which is why the Fractal Dimension control is so important.  After setting and testing the filter parameters, you can then save these parameters for each security data file.  This filter selection will then be used for the Price Projection and all technical indicators for this security.

Correlation Test – Filters

The Correlation Test – Filters dialog displays the correlation between the Price Projection from the Linear Prediction filter and the future returns, as a function of the time lag.  In this dialog, you can shift the phase, or time lag, of the Price Projection so as to achieve a peak correlation.  For the value of the correlation which falls under the “ZERO” mark, the dialog displays the numerical value of the correlation, the volatility of the returns, and then computes and displays a theoretical return which would result from an idealized trading strategy, with this value of the correlation.  From this you can get an idea of the potential returns that can be realized if this indicated correlation is real.  Also shown is a band indicating the range or standard error of the measured correlation, based on the number of data points used. 

 

There is a list box for changing the time horizon, which is the number of days of daily returns over which the correlation is computed.  The correlation between the future returns over this time horizon is computed with a simple average of the corresponding number of future days of the Price Projection.  There is also a spin button that you can use to set the time lag.  This merely moves the Price Projection by shifting it left or right.  By moving the peak correlation under the ZERO line, you can then measure the correlation and theoretical gain.

 

The Correlation Test – Filters dialog box also computes some numerical quantities of interest.  First, the actual value of the correlation under the ZERO line is displayed.  The standard error is displayed, which depends on the number of data points.  The average N-day volatility for the stock data returns is displayed.  From these numbers, a theoretical estimate of the annual simple and compound gain is computed, using the formula: daily correlation times daily volatility times 256 for simple returns.  This gives you an idea of the theoretical gains possible with a given degree of correlation, given the volatility of the returns for that stock.  There is also a set of radio buttons to change the vertical scale of the graph, but the scale is changed automatically anyway, so you usually don’t need to do it yourself.  Finally, the correlation can be re-computed using any of three methods, namely the Pearson’s R, which is the normal method, and the two robust methods, which are Spearman Rank-Order and Kendall’s Tau.  (However, note that the actual gains to be obtained in trading are related to the Pearson’s R method of correlation, not to the others.)

 

The Correlation Test – Filters dialog is useful for determining to what extent the Linear Prediction filters are actually working.  If the Linear Prediction filter is doing its job, you should see a nice positive correlation peak on and just to the right of the ZERO line, corresponding to the future Price Projection of the filter.  By examining the performance of the Price Projection of the Linear Prediction filter, you can use this information to help choose the type of filter and the Momentum indicators that are likely to give optimum performance.

Spectrum Periodogram

This is the second dialog box that is available from the Greeting dialog, or from the toolbar of the Main Window.  This dialog box incorporates the standard Periodogram test of Time Series Analysis.  The Periodogram is a method for measuring the spectrum of a time series, in this case stock returns data.  A description of this test can be found in many standard textbooks, such as Brockwell & Davis (1991).  The Periodogram Method is basically a Fast Fourier transform (FFT) of the stock returns data (squared), and displays the squared amplitude of each frequency component, in steps of the lowest frequency, up to the Nyquist frequency (with period 2 days).  For comparison, a second method of spectrum estimation, called the Maximum Entropy Method, is also displayed.  This method relies on the Linear Prediction filter.  The LP filter coefficients are computed from the returns data, then the ME method estimates the spectrum from these coefficients.  It can be seen that the results are pretty similar in both cases.

 

According to the standard theory of the Periodogram, it must be smoothed on some time scale.  If it is left unsmoothed, the standard error of each Fourier component is roughly 100% of the amplitude of the component.  After smoothing on a time scale of N days, the standard error of the smoothed Fourier component is roughly .  The default smoothing is set at 6 days, but you can change to a wide range of smoothing time intervals using a list box.  Please consult a standard text on Time Series Analysis for an explanation of the necessity for smoothing the Periodogram.

 

There are many peaks and valleys in the observed spectrum, but unfortunately it is not possible to show conclusively that these are any different from a random result.  To demonstrate this, the Periodogram can be viewed using only random Gaussian data, generated by a random-number generator.  To view the random data, click the Random button.  Each time you click this button, a new set of random data is generated, and displayed in the two windows.  The stock returns are displayed in dark red, while the Gaussian data are displayed in blue.  Clicking the same button, which now reads Restore, returns to the same stock data.  So you can repeatedly compare the stock data Periodogram with that of the random Gaussian data, with a new set of random data each time, just by repeatedly clicking this same button.  It can be seen that the random Gaussian data also displays the same type of peaks and valleys, so it can be concluded that, whatever correlations are present in the stock data, they are usually buried in stochastic noise.

 

Also included in this dialog box are two standard statistical tests.  The Kolmogorov-Smirnov test [NR (1992)] compares the spectral distribution of the Periodogram to a constant distribution.  It then computes the confidence level that the spectrum is different from a constant distribution.  This can be interpreted as the probability that the spectrum was not obtained from a random Gaussian distribution by random chance alone.  It will be observed that, using the random Gaussian data, this confidence level ranges from 0% to 100%, and is distributed roughly equally over this range.  This is what you would expect from a purely random result.  The Fisher’s test [Brockwell & Davis (1991)] computes the confidence level for a periodic component in the spectrum.  This is used to determine the probability that an observed cycle in the data is not obtained from a random Gaussian distribution by random chance alone.  It will likewise be seen that, using the random Gaussian data, this confidence level also ranges from 0% to 100%, and is also distributed roughly equally over this range.  It would be interesting to run these two tests over a collection of stock data files, and observe whether or not the distribution of the confidence levels of the two tests is still constant from 0% to 100%.

Spectrum Wavelet

This is the third dialog box that is available from the Greeting dialog, or from the toolbar of the Main Window.  This dialog box uses an alternative method of measuring the spectrum based on the Discrete Wavelet Transform (DWT).  Unlike the Fourier basis, which are “infinite” sine waves, but have a single, precise frequency, the wavelets are waves that are localized in both time and frequency, but not infinitely sharp in either.  When decomposed in the wavelet basis, the wavelet coefficients of the stock returns, which are the amplitudes of each wavelet basis component making up the waveform of the returns, are functions of both frequency and time.  More precisely, the frequency spectrum is divided up into octaves, which are multiples of two in frequency.  So the lower end of the spectrum has more divisions into octaves than the higher end.  This is appropriate, since we are mainly interested in the low frequency end of the spectrum anyway, as this is what determines the long-term trend of the prices.  To compute the wavelet spectrum, therefore, the returns time series is decomposed into its wavelet coefficients, and then these are squared to give the power spectrum.  Finally, this power spectrum is averaged over time within each frequency octave.  The result is displayed in a graph, which shows the power spectrum in each octave.  There are only 9 octaves in all, as opposed to 512 frequency components in the case of the Periodogram.  This may be viewed as an alternative method of smoothing the Periodogram, and thereby (hopefully) eliminating some of the stochastic noise.

 

When you first open the Spectrum Wavelet dialog, the yellow bars you see are the one-standard error bars for each octave.  Notice that the error bars are much larger for the low frequency octaves, because there are correspondingly fewer data points in these octaves.  When you select a stock, the wavelet spectrum is displayed.  The top graph shows this spectrum, averaged over all 2048 days of data, whereas the bottom graph shows a different type of wavelet spectrum called the Maximal Overlap Discrete Wavelet Transform (MODWT), which is time averaged over only the latest N days.  You can set this number of days N to any value from 1 to 2048.  The 2048-day averaged version is the one used in the Wavelet Linear Prediction filter.  The result in this filter is that the Price Projection is much straighter than for the case of the filters derived from the Periodogram.  However, the long-term trends seem to agree pretty well between the two methods.  It is still an open question whether some of the short-term structure that is eliminated in the Wavelet method is really just stochastic noise, or whether there may be some short-term correlation present as well.

 

The Spectrum Wavelet dialog contains two versions of the Chi-Square test.  The first test measures the confidence level that the time-averaged wavelet spectrum is not random.  This test usually gives a result that the spectrum is close to random, since there are only 9 “bins”.  On the other hand, the second Chi-Square test measures the confidence level that the full wavelet spectrum is not random.  This test is also expressed in terms of standard deviations away from the center of the (Gaussian) probability distribution, which is another way of expressing the confidence level.  This almost always gives an amazing number of standard deviations away from randomness for the full wavelet spectrum.  So either there is some correlation that is being averaged over in the time average after all, or else this result may be explained by the fact that the returns themselves do not obey a Gaussian distribution, but instead have “fat tails”.  We are still investigating this question, but it is a very interesting result nonetheless.

Correlation – Returns

This is the fourth dialog box that is available from the Greeting dialog, or from the toolbar of the Main Window.  It displays a scatter graph, showing the correlation between the returns of two different stocks.  You choose the two stocks using the Data 1 and Data 2 buttons, which both open an Open File dialog.  When both stocks (or indexes) are selected, the scatter graph appears, and the correlation is listed according to three different methods on the right side.  The three methods are Pearson’s R, which is the normal method, and the two robust methods, which are Spearman Rank-Order and Kendall’s Tau. 

 

The Correlation – Returns dialog is useful by itself for measuring the correlation of returns between two stocks, or indexes.  But in conjunction with the Correlation – Auto & Cross dialog it is even more useful.

Correlation – Auto & Cross

If you click the Correlation button in the Correlation – Returns dialog, the Correlation – Auto & Cross dialog box is displayed, which contains a set of bar graphs of the correlation between the two stocks, as a function of time lag.  The time lag is just the time difference, in days, between the returns that are compared in the correlation test.  One graph for positive time lags and one graph for negative time lags are displayed.  If you choose the same stock for both of the two stocks, then you can view the autocorrelation of the returns of that stock.  In that case, the two bar graphs for positive and negative lags will be the same.  If you change the time scale for the correlation to N days, then the correlation between N-day returns is computed.  In this case, the bars of the bar graphs become N pixels wide rather than just one pixel wide.

 

This Correlation – Auto & Cross dialog is useful for comparing the degree of correlation between different stocks for the purpose of portfolio selection.  It is also useful for general studies of the correlation structure of the stock returns data.  For example, when studying the autocorrelation of daily returns, if you look closely you can see that the autocorrelation for the first three days of lag is almost always negative.  Often you can also spot what look like cycles in the correlation structure, with periods in the intermediate-term range of, say, one to several months.

Technical Indicators

The Technical Indicators dialog box enables you to build a technical indicator, which is then tested for correlation with future returns in the Correlation Test – Indicators dialog.  You can also build the three Momentum indicators, which are displayed in the three panes of the Momentum Indicators splitter window.  The weighted sum of these three Momentum indicators then make up the Trading Rules indicator, which is displayed in the bottom pane of the Trading Rules splitter window.  Slider bars in the Trading and Portfolio Parameters dialog box set the weights for the sum of the three Momentum indicators.

 

The technical indicators are various kinds of oscillators formed from the past price history of the stock (including the Price Projection, which is also derived from the past history), using various types of smoothing.  The smoothing is obtained from a Savitzky-Golay digital smoothing filter.  This is a type of smoothing filter, of which the most elementary example is the ordinary simple Moving Average, but it goes far beyond the simple MA.  In fact, the simple MA is the “zero order” realization of this filter, but in QuanTek we use a fourth-order filter instead.  For this reason, the (causal) filter exhibits almost no lag, unlike the simple (or exponential) MA.  This SG filter can be used either as an acausal filter or as a causal filter, but in QuanTek only the acausal filter is used, because this is a zero-phase filter with no (frequency dependent) time lag.  You can choose any one of a wide range of smoothing time scales for the technical indicator, and also the time lag, which adjusts the phase.  In addition, you can choose three types of indicators, which we call the Relative Price, Velocity, and Acceleration.  The Relative Price is just the smoothed price data (relative to a longer time scale smoothing).  The Velocity is the smoothed first derivative of the price data.  Finally, the Acceleration is the smoothed second derivative of the price data.  Taking the derivatives (rates of change, from Calculus) of the price data is easy using the Savitzky-Golay smoothing filter.  You can choose one time scale (and time lag) of smoothing, or the difference between any two time scales (and time lags) of smoothing to form your technical indicator.  From all these choices, a tremendous variety of different types of oscillators may be formed.  These are in essence all the linear oscillator-type technical indicators that can be formed from past price data alone.

Correlation Test – Indicators

After defining a technical indicator in the Technical Indicators dialog box, you may select the Correlation Test – Indicators, which displays the correlation between the technical indicator and the future returns, as a function of the time lag.  In this dialog, you can shift the phase, or time lag, of the technical indicator so as to achieve a peak correlation.  For the value of the correlation which falls under the “ZERO” mark, the dialog displays the numerical value of the correlation, the volatility of the returns, and then computes and displays a theoretical return which would result from an idealized trading strategy, with this value of the correlation.  From this you can get an idea of the potential returns that can be realized if this indicated correlation is real.  Also shown is a band indicating the range or standard error of the measured correlation, based on the number of data points used. 

 

There is a list box for changing the time horizon, which is the number of days of daily returns over which the correlation is computed.  The correlation is computed of the future returns over this time horizon with a simple average of the corresponding number of future days of the technical indicator.  There is also a spin button that you can use to set the time lag.  This merely adjusts the phase of the technical indicator by shifting it left or right.  The goal is to determine the amount of time lag, or phase shift, necessary to bring the (positive) peak of the correlation graph under the ZERO line in the middle of the graph.  This then corresponds to the maximum degree of correlation between the technical indicator and the future returns.  Then the technical indicator fits the definition of a Momentum indicator, which means that the technical indicator is maximally correlated with the N-day future returns. 

 

The Correlation Test – Indicators dialog box also computes some numerical quantities of interest.  First, the actual value of the correlation under the ZERO line is displayed.  The standard error is displayed, which depends on the number of data points.  The average N-day volatility for the stock data returns is displayed.  From these numbers, a theoretical estimate of the annual simple and compound gain is computed, using the formula: daily correlation times daily volatility times 256 for simple returns.  This gives you an idea of the theoretical gains possible with a given degree of correlation, given the volatility of the returns for that stock.  There is also a set of radio buttons to change the vertical scale of the graph, but the scale is changed automatically anyway, so you usually don’t need to do it yourself.  Finally, the correlation can be re-computed using any of three methods, namely the Pearson’s R, which is the normal method, and the two robust methods, which are Spearman Rank-Order and Kendall’s Tau.  (However, note that the actual gains to be obtained in trading are related to the Pearson’s R method of correlation, not to the others.)

Diagnostic Test

Within each stock data file, there is a back-testing routine called the Diagnostic Test.  This may be used to test the Trading Rules under a variety of simulated trading scenarios.  At present there are six tests available.  Each of these tests is for a 1-day time horizon only, so the position is varied each day based on the 1-day Trading Rules.  (For an N-day time horizon, the N-day holding period is simulated by taking an N-day backward moving average of the Trading Rules.)  Please see the Help file for a detailed description of the various tests.  In summary, the Diagnostic Test provides a realistic simulation of the Trading Rules in a variety of scenarios, and an independent verification of the theoretical gain from correlation computed in the Correlation Test – Indicators dialog.

 

Graphs and Displays in QuanTek

QuanTek has a variety of graphs and displays.  There is a Main Graph, which displays all the stock price data in a scrollable display.  The Main Graph comes in four different scales, each of which displays a different aspect of the data.  Also noteworthy is the Price Projection on the Main Graph, which shows the output of the Linear Prediction filter.  This filter attempts to estimate the future price action, based upon any correlation in the past price returns that might exist.  There are also three splitter windows, each with three panes, which display the various technical indicators.

Main Graph

The Main Graph is designed to give a panoramic view of the entire data set, and is easy to interpret and easily scrollable.  The price axis moves automatically to keep the display centered, when you scroll along the time axis, or you can scroll along the price axis manually if necessary.  There are four scales of the graph, each of which displays different information.  The display is available in either a black or white background.  There is also a tooltip, which lists the date and price at any point where the mouse cursor is located.  The Main Graph also displays buy/sell signals, buy/sell points, and a long-term smoothing curve, short-term smoothing curve, long-term trend line, and the highest scale is a Candlestick chart.  In connection with the long-term smoothing curves and trend lines, a set of Bollinger Bands are displayed, corresponding to one- and two-standard deviations of the average absolute deviation of the prices from the long-term curves.  The relative (logarithmic) volume is also displayed along the bottom of the graph.  Also, the Price Projection is displayed in blue, after the most recent past data on the graph.  This display shows the output of the Linear Prediction filter.  There is an error bar for each future projected price, to display an approximate one-standard-deviation range for the future price.  This range is approximately proportional to , where n is the number of days in the future for the projected price.  (This corresponds to the standard deviation of the Random Walk process.)

Splitter Windows

There are three splitter windows, each with three panes.  These three splitter windows display a compatible set of nine technical indicators, showing buy/sell points as vertical green/red lines in each window.  The present time is displayed as a vertical yellow line.  To the past of this line, the past data are smoothed, and buy/sell points are displayed with the benefit of hindsight.  To the future of this line, the future Price Projection is displayed (based on past data), and future estimated buy/sell points are also shown.  This Price Projection (of the indicators) is based on the Linear Prediction filter. 

Harmonic Oscillator Splitter Window

The panes of this splitter window are called Relative Price, Velocity, and Acceleration.  These three indicators display a smoothed difference of prices between a short-term and longer-term smoothing, a smoothed first derivative or returns, and a smoothed second derivative or rate of change of returns, respectively.  Using acausal Savitzky-Golay smoothing, so that there is no lag or phase shift, the buy/sell points should line up with the minima/maxima (min/max) of the Relative Price, the positive/negative zero-crossing (Z+/Z–) of the Velocity, and the maxima/minima (max/min) of the Acceleration, respectively.  The buy/sell points derived from the Harmonic Oscillator indicators are shown in all the splitter windows and the Main Graph.

Momentum Indicators Splitter Window

The three panes of this splitter window contain the Momentum 0, Momentum 1, and Momentum 2 technical indicators.  These three technical indicators are defined by you using the Technical Indicators dialog box, and tested in the Correlation Test – Indicators dialog.  You find technical indicators, which show a positive correlation with future returns, and adjust the phase or time lag of the indicators so that the measured correlation is maximum.  These indicators (actually their N-day forward average) are then displayed in this splitter window, and the peaks and valleys of all three indicators should (approximately) line up.  The positive zero crossing of the indicators should be ahead of the buy points, and the negative zero crossing should be ahead of the sell points, by N/2 days (approximately), where N is the time horizon.  The (N-day forward moving average) Momentum Indicators are supposed to represent an estimate of the N-day future returns.  (Hence the Momentum indicators before taking the N-day forward moving average should be in phase with the Velocity indicator.)  Hence the optimum N-day Trading Rules may be taken to be proportional to the value of the Momentum indicators at the N-day buy/sell points, assuming a holding period or time horizon of N days.

Trading Rules Splitter Window

Using the Trading Rules Parameters dialog for each stock, you form a weighted sum of the three Momentum indicators to form the Trading Rules indicator.  Adjusting the three slider bars corresponding to the three Momentum indicators forms the weighted sum.  Then this (N-day forward moving average) Trading Rules indicator is displayed in the bottom pane of the Trading Rules splitter window.  Since you have chosen the three Momentum indicators for maximum correlation with N-day future returns (in the Correlation Test – Indicators dialog), the Trading Rules indicator should also have maximum correlation with N-day future returns.  To check for this visually, the N-day future returns are displayed just above the (N-day forward moving average) Trading Rules indicator in the middle pane of the splitter window.  These are obtained by taking an N-day forward moving average of the daily returns.  As a result of this, the N-day future returns and (N-day forward moving average) Trading Rules indicator should be approximately N/2 days ahead of the Velocity indicator.  This means that the buy point should occur N/2 days after the positive zero crossing, and the sell point should occur N/2 days after the negative zero crossing, of the Trading Rules indicator and N-day future returns.

 

In the upper pane is shown the N-day future volatility, which is the forward N-day moving average of the high-low daily volatility.  This will be used in a future version of QuanTek, which will implement a GARCH multivariate Price Projection and the Capital Asset Pricing Model (CAPM).

 

Other Features

These are the most important features of QuanTek.  There are many other features as well.  The actual prices are displayed in list form in the Stock Data window.  The list of stocks, indexes, and other types of files in the currently active Stock Group are shown to the left side of the Main Window in the Portfolio dialog bar.  Double clicking on any one of these entries is a quick way to open that data file.  You can also create up to 15 separate portfolios within each Stock Group, consisting of separate positions in each stock and total equity.  These may be selected from the Portfolio menu.  You can also parse ASCII data files and save data to ASCII files in a variety of formats.  The parse script to be used may be defined in the Parse menu.  You can also switch between black and white background for all graphs and displays.  The black is on by default.

 

All of the features of QuanTek are described in much greater detail in the Help file.

 

References

Bouchaud, Jean-Philippe & Potters, Marc 

Theory of Financial Risks: From Statistical Physics to Risk Management,  Cambridge University Press (2000)

 

Brockwell, Peter J. & Davis, Richard A.

            Time Series: Theopry and Methods, 2nd ed., Springer (1991)

 

Colby, R. & Meyers, T. Encyclopedia of Technical Market Indicators,

McGraw-Hill (1988)

 

Edwards, Robert D. & Magee, John Technical Analysis of Stock Trends,

John Magee Inc. (1992)

 

Johnson, M. The Random Walk and Beyond, John Wiley & Sons (1988)

 

Malkiel, Burton G. A Random Walk Down Wall Street, W. W. Norton & Co. (1999)

 

Mantegna, Rosario N. & Stanley, Eugene H.

An Introduction to Econophysics: Correlations and Complexity in Finance,

Cambridge University Press (2000)

 

Natenberg, S. Option Volatility & Pricing, McGraw-Hill (1994)

 

Percival, Donald B. & Walden, Andrew T.

            Wavelet Methods for Time Series Analysis, Cambridge University Press (2000)

 

Peters, E.  “Fractal Structure in the Capital Markets”,

Financial Analysts Journal, July/August 1989

 

Peters, E. Chaos and Order in the Capital Markets, 

New York: John Wiley & Sons (1991)

 

Peters, E. Fractal Market Analysis,  New York: John Wiley & Sons (1994)

 

Press, William H., Vettering, William T., Teukolsky, Saul A., & Flannery, Brian P.,

            Numerical Recipes in C, 2nd ed. [NR], Cambridge University Press (1992)

 

Pring, Martin J. Technical Analysis Explained, 3rd ed., McGraw-Hill, Inc. (1991)

 

Sharpe, W.F.; Alexander, G.J.; Bailey, J.V. Investments, 5th ed., Prentice Hall (1995)

 

Sherry, Clifford J. The Mathematics of Technical Analysis, Probus Publishing Co. (1992)

 

Vaga, T.  “The Coherent Market Hypothesis”,

Financial Analysts Journal, December/January 1991

 

Vaga, T. Profiting From Chaos,  McGraw-Hill (1994)