Wednesday, February 2, 2011

Kth Nearest Neighbor Algorithmic Predictions


So I noticed that Adaptive Trading Systems claimed to have achieved a fairly nice looking equity curve forecasting S&P500 Futures via KNN (Kth Nearest Neighbor) with the below inputs,

"
S&P500 Futures
S&P500 Index
Russel 2000 Index
OEX Put/Call Ratio
"
Fundamentally, these variables look at sentiment, futures basis, and relative performance, and are probably the main causes for this strategy's success.

Applying KNN

Here's a simple guide to implementing KNN in Excel. There're also a number of Matlab packages available.

Sunday, November 7, 2010

About spurious correlations



I was talking to a fellow mathematician, someone not familiar with financial economics, around autocorrelation within financial data. "It could be spurious..." he said, implying and concluding that the relationship may not be practically exploitable.

OK, so the next logical thought is, even if the correlation IS spurious, can it still be applied somehow?

(Above figure gives HFRI Hedge Fund Index Autocorrelations for the indicated period)

Spuriousness explained

William C. Burns has given a great example of a spurious correlation,
"

  1. Get data on all the fires in San Francisco for the last ten years.
  2. Correlate the number of fire engines at each fire and the damages in dollars at each fire.
Note the significant relationship between number of fire engines and the amount of damage. Conclude that fire engines cause the damage.
"

So basically, it means that correlation statistics do not explain cause and effect orders.

Some relationships remain exploitable

OK, so let's go back to significant correlations of stock index values against Dividend Yield or the autocorrelation thing. Fundamentally speaking these relationships may make sense with respect to expected rational behavior of institutional traders. However, someone who does not have a background in financial economics would assume spuriousness.

Does it really matter? Referring to serial correlation, so what if a security's return at time t, S(t) depends on S(t-1), or that maybe S(t-1) depends on S(t); as long as the relationship's there and statistically significant, it is probably exploitable. The bottom line is everything.

Tuesday, September 8, 2009

Slight-Edge Butterfly Effect

Roulette, with a paltry 1/37, or 2.7% edge, makes casinos serious profit over time, financial trading sits on very similar ground. Having a statistical edge does not necessarily result with positive expectancy, though it definitely helps. This calls for an empirical test.


Empirical analysis

Forecast Model- Multilayer Perceptron Neural Network

Input/Predictive Variables- Various commodity and Dow Jones indexes

Output/Dependent Variable- Next Day Return of the S&P500 Index (Next Day Open price – Next Day closing price)

Training Period- from Jan. 2002 to Jan 2005

Test Period- from Jan 2005 to Aug. 2009


Focused only on next-day direction, the predicted values offered a winning rate of just about 54%. Keep in mind this stands quite superior to the roulette casino edge. Then out of curiosity, I wanted to see how hypothetical trades off these forecasts would have resulted, basically buying/shorting at the open and liquidating positions at the NYSE close. Virtual trading equity starts at 1, or 100%, and would compound daily, winning or losing. See chart below.



I know- it’s pretty cool, 400% plus return in roughly 4.5 years. It also appeared that the mid 2007 volatility jump pushed performance up tremendously. This brings the thought that maybe with volatility based position size adjustments; return over time could become smoother and even higher. Imagine what a higher hit rate could achieve…