Thursday, August 26, 2010

Different frequency fft waves for S&P500

I've added a graph showing fft (Fast Fourier Transform) based waves of different number of frequencies:

What Fourier says about S&P500?

Based on the Fourier-based extrapolation of the current trend of S&P500, the stock market will raise or fall :)

I've implemented extrapolation of trend based on Fourier analysis, and - as you can see below - depending on the range of data used for calculations, S&P500 will raise or fall:

Fig 1. Fourier extrapolation of S&P500 based on 100 daily quotations


Fig. 2 Fourier extrapolation of S&P500 based on 400 daily quotations



In both cases, Quinn-Fernandes algorithm for frequency estimation was used and 20 harmonics matched.

(the code is not yet optimized for R)


Monday, August 23, 2010

Best correlation trajectory match for EURUSD

Another test of correlation-based matching of trajectories. This time EURUSD.

Best match with correlation of 0.9295 was found at the beginning of 1980 (red line):


In addition to the best match, two second best correlation matches were added (green lines).

Even though, based on the best correlation match (and one of the others) you might expect pretty significant growth, one of the presented second best matches suggests continued correction.

The next step would be to verify whether such matching has any sense at all :)

Download source code (R) and data.

S&P500 - current trajectory similar to situation from 1959/1960

If one believes in market repeating itself, one could say that the current situation is the most similar to one from the break of 1959/1960:


The correlation between the current and 1959/1960's periods is 0.9292. If market goes the same way as in the past, we should expect a small market increase of around 0,5% over the next 10 days.

The time will tell :)

Sunday, August 22, 2010

Simple perfect arbitrage opportunities on forex

Forex is the most liquid of the financial markets. Therefore it is deemed totally deprived from simple arbitrage opportunities.

However, it turns out that one can find - although rarely - perfect arbitrage opportunities even on the most liquid currency crosses.

For example, I've analyzed intraday data (with 10 mins. frequency) for EURJPY, USDJPY and EURUSD for the period of  March 2nd, 2009 - August 20th, 2010. That gives some 54,700 datapoints for each of the crosses.

I defined a perfect arbitrage opportunity for these three crosses, as a situation when difference between EURJPY and USDJPY*EURUSD exceeds 0.1 yen. Then one would be able to sell short EURJPY and at the same time buy USDJPY together with EURUSD (or vice versa) and produce risk free return after adjusting for total spread of 0.1 yen.

In that period I've found 25 instances (out of 54,703 quotations, or 0,0457%) when arbitrage opportunity appeared:


Nevertheless, some of them were substantial - the largest giving 1,31% risk free return!

Visualization of the difference between EURJPY and USDJPY*EURUSD shows, that the arbitrage gap is very rare phenomenon indeed:


The difference between crosses is concentrated in a very narrow range that hardly ever creates arbitrage opportunities. Still, the distribution has very long tails (or at least one of them):




The situation changes a little when you take a look at some less liquid crosses - for example EURPLN vs USDPLN*EURUSD.

The number of arbitrage opportunities increases noticeably (to 6,42% of all analyzed quotations), as well as the rate of potential risk free return (note: total spread set at 0.105 zł):



The difference between base cross (EURPLN) and its equivalent pair (USDPLN*EURUSD) becomes much more volatile:



However the distribution of differences looks much more "normal":


Clearly, there still exist perfect simple arbitrage opportunities on forex. It's possible to exploit them using algorithmic trading. They are rare and often they generate low individual returns. But they are risk free.

Data source: stooq.com


The coming black boxes inside business organizations

Google has recently made available a set of tools for analyzing data using machine learning techniques called Google Prediction API.

As you can read in the recent article in MIT Technology Review:

For example, a bank or credit-card company wanting to use machine learning to build systems that make decisions based on historical transactions is unlikely to have the specialized staff and necessary infrastructure for what is a computationally intensive approach. [...]
Google's black box (...) contains a whole suite of different algorithms. When data is uploaded, all of the algorithms are automatically applied to find out which works best for a particular job, and the best algorithm is then used to handle any new information submitted. [...]
Google does, however, get (...) information [about effectiveness of various techniques] that it can use to improve its machine-learning algorithms. "We don't look at users' data, but we do see the same metrics on prediction quality that they do, to help us improve the service," says Green. The engineers running Prediction API will know if a particular algorithm is rarely used, or if a new one needs to be added to the mix to better process certain types of data.
Source: Tom Simonite "Google Offers Cloud-Based Learning Engine", Technology Review, 2010-08-20

As machine learning and other pattern-recognition technologies become more available and effective, companies will use them more often.

We can learn some lessons from the investment area, where algorithmic trading has already overtaken human discretion at least in terms of number of transactions executed on the US stock exchanges.It's true that quite often trading algorithms are still quite simple, but they are getting better as Moore's law increases the computing power available for them. It seems inevitable that one day algorithmic trading will dominate the investment industry, and human investors will share the fate of chess master Garry Kasparov defeated by IBM's Deep Blue.

Similarly, proliferation of quantitative methods in business may lead to some interesting results. First, managers will be often and often required to know these new technology-enabled methods. Second, the decision making processes, starting with operational aspects, may slowly morph into hardly penetrable black boxes, processing increasing amounts of information generated and gathered by business organizations.


Originally posted at: blog.inlevel.com 

Monday, August 16, 2010

According to today's breaking news, S&P500 will raise or fall :)

Two consequitive news found at finance.google.com today:

1,200 target reachable for the S&P 500 index
The recent economic reports have shown that the economic recovery is petering out, prompting a few economists to consider the possibility of the economy falling into recession. Robert Shiller ...

Why the S&P 500 Stock Index May Fall Below 1,000
The S&P 500 made one sharp move down this year from 1,200 in late April to just about 1,000 in the first week in July. The index may be heading below 1,000 in the next month from the 1,079 where ...

Current index level: 1077.