Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
19/05/2014 Course outline Financial Time Series Analysis • • • • • • • • • • • • Patrick McSharry [email protected] www.mcsharry.net Trinity Term 2014 Mathematical Institute University of Oxford 1. Data analysis, probability, correlations, visualisation techniques 2. Time series analysis, random walk, autoregression, moving average 3. Technical analysis, trend following, mean reversion 4. Nonlinear time series analysis 5. Nonlinear modelling, regime switching, neural networks 6. Parameter estimation, model selection, forecast evaluation 7. Volatility forecasting, GARCH, leverage effect 8. Risk analysis, value at risk, quantile regression 9. Energy consumption, demand forecasting 10. Ensemble prediction, wind power generation 11. Weather derivatives, index-based insurance 12. Quantitative trading strategies, algorithmic trading Copyright © 2014 Patrick McSharry Lecture 3 Overview • Moving averages • Exponentially weighted moving averages • Technical analysis – Head and shoulders – Relative Strength Index – Moving Average Convergence / Divergence – Oscillators – Bollinger bands – Japanese candlesticks – Elliott waves • Fundamental analysis Major stock market crashes • “Black Tuesday,” October 29, 1929, and “Black Monday,” October 19, 1987 occurred on the same annual lunar calendar date, 7-28. • Additionally, the other similar points in the comparisons of those two years, the spring lows, summer highs and autumn failure highs all occurred within one day on the lunar calendar. • The figure shows those years in a chart aligned with the lunar calendar, where similar lunar dates are juxtaposed above each other. The panics are marked with arrows. The other similar features are denoted with dashed lines. • The chart also includes Hong Kong’s Hang Seng index for the panic year 1997 Lunar panics • Christopher Carolan (1998), demonstrated the correlation between the lunar calendar and the stock market panics of 1929 and1987. • “The annual lunar model for panics points to the 27th and 28th days of the lunar month as the dark days, yet that is only true in the autumn season, the 6th or 7th lunar month.” • “When there is no full moon between October 3 and 19 inclusive, the Dow has been up 1.5% in October since 1915. In those years with a full moon between those dates, the Dow’s average change is a loss of 1.9%.” Largest daily crashes A scan of daily data of the Dow Jones Industrial Average from 1915, the Hang Seng index from 1980, The Japanese Nikkei index from 1950, and the German DAX index from 1960 for the 10 largest, single-day percentage drops is shown. Seven of those ten declines were days associated with one of the three panics. Two of the others, the Spring 1989 declines in the Hong Kong market, were tied to a fundamental news event, the Tiananmen crisis in China. The final entry is from the German market during the “mini-crash” of October 1989, an October event similar to the others, but smaller in magnitude 1 19/05/2014 Moving averages Exponentially weighted moving averages • A moving average may be viewed as a convolution or a low-pass filter. • A simple moving average of the last n observations is given by: n • EWMA employs exponentially decreasing weights to discount the influence of old observations: • By smoothing the time series, it can remove the effects of seasonality. • Note that it gives equal weight to both new and old observations • The EWMA may also be expressed via the number of time periods n using the smoothing factor, α=1/n, giving: ⎛ 1 ⎞ ⎛ n − 1 ⎞ st = ⎜ ⎟ xt + ⎜ ⎟ st −1 ⎝ n ⎠ ⎝ n ⎠ 1 st = ∑ xt −i +1 n i =1 EWMA weights st = αxt + (1 − α )st −1 • The smoothing factor, 0<α<1,determines the rate of decay of old information Technical analysis • Technical analysts attempt to identify patterns in historical financial market data (both price and volume) that can be exploited to generate positive returns • Using transformations of financial time series it may be possible to forecast price movements • The idea is that large gains from successful trades exceed more numerous but smaller losing trades • By controlling for risk, it should be possible generate positive average returns in the long-term Head and shoulders The “head-and-shoulders" pattern is believed to be one of the most reliable trend-reversal patterns. Double bottoms The “double bottom” looks like the letter "W". The twice touched low is considered a support level. Most technical analysts believe that the advance off of the first bottom should be 10-20%. The second bottom should form within 3-4% of the previous low, and volume on the ensuing advance should increase. 2 19/05/2014 Evidence for technical analysis • Neftci (1991) showed that some of the rules employed in technical analysis generate well-defined techniques of forecasting, but even well-defined rules were shown to be useless in prediction if the economic time series is Gaussian. However, if the processes under consideration are nonlinear, then the rules might capture some information. Tests showed that this may indeed be the case for the moving average rule. • Brock et al. (1992) analysed numerous technical trading rules using 90 years of daily stock prices from the Dow Jones Industrial Average up to 1987 and found that they all outperformed the market. • Lo et al. (2000) took a systematic and automatic approach to technical pattern recognition, applying nonparametric kernel regression to a large number of US stocks from 1962 to 1996. By comparing the unconditional empirical distribution of daily stock returns to the conditional distribution (conditioned on specific technical indicators) they found that several technical indicators provided “incremental information and may have some practical value”. RSI example Relative strength index • Wilder (1978) proposed the relative strength index (RSI) to measure price strength by comparing upward and downward price changes: ⎛ s u RSIt = 100⎜⎜ u t d ⎝ st + st ⎞ ⎟⎟ ⎠ where su and sd are EWMA estimates of ut = max(pt-pt-1,0) and dt = max(pt-1-pt,0) • Wilder recommended a smoothing factor of α=1/14 and considered a security to be overbought when RSI>70 and oversold when RSI<30 • Cutler’s RSI uses a simple moving average instead of EWMA Moving Average Convergence / Divergence (MACD) • MACD is a trend-following indicator and measures the difference between a fast and slow exponential moving average (EWMA) of prices: MACDt = EWMAt12(p) – EWMAt26(p) st = EWMAt9(MACD) • MACD can be traded in a number of ways: – Buy (sell) when MACDt moves above (below) st – Buy (sell) when MACDt moves above (below) zero – Divergence between price and MACD levels Source: Wikipedia MACD example Trix • Trix (Triple Exponential) is an oscillator constructed by applying EWMA three times to price time series • Positive values indicate and upwards trend and negative values suggest a downward trend • The application of EWMA three times has the effect of spreading out the weights and decreasing the weight on the most recent observations Source: Wikipedia 3 19/05/2014 Stochastic oscillators • Lane (1950) introduced the stochastic oscillator to measure momentum by comparing the closing price to the price range over a specific period (usually n=14 days): p −p low s fast = 100 close phigh − plow • The rational is that prices tend to close near their past highs in bull markets, and near their lows in bear markets. • Trading signals can be generated when the fast stochastic oscillator crosses its moving average, the slow stochastic oscillator € • A pair of fast and slow oscillators may be formed; the slow oscillator can be derived from the fast one using a simple moving average with n=3 days Trading stochastic oscillators • Buy when sfast crosses up through sslow and sell when sfast crosses down through sslow • An alternative trading strategy is to use the oscillators directly based on their level as was the case of RSI; s > 80 implies overbought and s < 20 implies oversold • Oscillators may be slowed down further during periods of high volatility by taking additional moving averages (or averages with longer periods) • This reduces fluctuations, the number of crossovers and hence transaction costs Stochastic oscillators Bollinger bands • Bollinger bands provide a conditional measure of the highness or lowness of the price relative to previous trades • The bands are defined using an n-period simple moving average, µt for the centre and ±kσt for the bands where σt is the n-period standard deviation (typical values are n=20 and k=2) • While we should not expect 95% of an equity's closing prices, on average, to lie within the Bollinger bands (as for normal distributions), from Chebyshev's inequality we can expect around 75% of the closing prices • Trading strategies: – Buy when the price touches the lower band and exit when price reaches the centre – Buy when the price moves above the upper band or sell when the price goes below the lower band – Sell options when bands are historically far apart or buy options when the bands are historically close together Source: Wikipedia Bollinger bands example Japanese candlesticks • A candlestick chart, reflects the open, high, low and close prices for each time period • The filled part of the candlestick is known as the body and reflects the change between the open and close • Long thin lines above and below the body represent the high/low range • A hollow candlestick implies that the close was higher than the open whereas a filled candlestick implies the opposite Source: Wikipedia 4 19/05/2014 Elliott waves • Elliott argued that because humans are themselves rhythmical, their activities and decisions could be predicted in rhythms • The wave principle posits that collective investor psychology moves from optimism to pessimism and back again • Elliott's approach states that market prices alternate between five point bullish waves and three-point bearish waves • As these waves develop, the larger price patterns unfold in a self-similar fractal geometry. Within the dominant trend, waves 1, 3, and 5 are "motive" waves, and each motive wave itself subdivides in five waves. Waves 2 and 4 are "corrective" waves, and subdivide in three waves. • The Fibonacci sequence appears repeatedly in Elliott wave structures, including motive waves (1, 3, 5), a single full cycle (5 up, 3 down = 8 waves), and the completed motive (89 waves) and corrective (55 waves) patterns • The ratio of the second peak to the first is 1.618 (approximately the golden ratio) € Volume • Volume provides a measure of the number of contracts or transactions occurring during a particular time period • Volume acts as an additional source of information as it represents the level of activity in the market • Strong upward trends are usually associated with increasing prices and high volume. In contrast increasing prices and low volume could signal a precursor to a reversal • Ying (1966) found a contemporaneous correlation between volume and returns and conclude that (i) low (high) volume is associated with decreasing (increasing) prices and (ii) a large increase in volume is usually accompanied by a large absolute change in price From R.N. Elliott's essay, "The Basis of the Wave Principle," October 1940. Fundamental analysis Fundamental ratios • Fundamental analysis attempts to identify securities that have been mispriced by the market. By taking a position now it should be possible to take profits once the market corrects the price. • Key information includes prices, dividends, earnings and cash flows • The P/E ratio (price-to-earnings ratio) of a security is a measure of the share price relative to the annual income or profit earned by the firm per share. A higher P/E ratio means that investors are paying more for each unit of income • The PEG ratio, Price/Earnings To Growth, is a valuation metric for determining the relative trade-off between the price of a stock, the earnings generated per share (EPS), and the company's expected growth. • PEG is a widely employed indicator of a stock's possible true value. The PEG ratio of 1 represents a fair trade-off between the values of cost and the values of growth, indicating that a stock is reasonably valued given the expected growth. • The lower the PEG ratio the more undervalued the stock. The PEG ratio may be better able to discriminate between stocks because unlike the P/E ratio it also accounts for growth. • The objective is to find good companies using information from the analysis of income and financial statements, management, competitive advantages of the business and potential competitors and markets • Value investors specifically attempt to detect undervalued securities P/E ratio and S&P returns • Shiller (2005) demonstrated that P/E ratios are a predictor of twenty-year returns. • The horizontal axis shows the real P/E ratio of the S&P Composite Stock Price Index (inflation adjusted price divided by the prior ten-year mean of inflation-adjusted earnings). • The vertical axis shows the geometric average real annual return on investing in the S&P Composite Stock Price Index, reinvesting dividends, and selling twenty years later. • Data from different twenty year periods is colorcoded as shown in the key. • Shiller states that this "confirms that long-term investors—investors who commit their money to an investment for ten full years—did do well when prices were low relative to earnings at the beginning of the ten years. • Long-term investors would be well advised, individually, to lower their exposure to the stock market when it is high, as it has been recently, and get into the market when it is low." 5