ujfjhz / FFFF

Free-software For Financial Freedom.
GNU General Public License v2.0
2 stars 1 forks source link

Spectral analysis #18

Open ujfjhz opened 8 years ago

ujfjhz commented 8 years ago

static approach does not consider the specific market or the recent lengths of the dominant sine wave.
Spectral analysis will help to identify the dominant cycle, and thus determine the frequency of that cycle making the applied trading rules adaptive to the market.

Seeking adaptive approach!

ujfjhz commented 8 years ago

"Currency Trading in the FX market"

Hafeez (2007) researched the segmentation of the FX market and found that 7approximately 24-49 percent of the participants are profit-seeking. 1 Even with this conser- vative approach it becomes evident that the FX market is very different from other finan- cial markets in that at least half of the participants engage without any intention of making a profit on their investment (Hafeez, 2007). This would in theory make it possible for the profit-seekers to turn a profit from the participants seeking to trade the currency for other reasons, the liquidity-seekers. Hafeez (2007) researched the distribution of profit and loss and found that the profit-seekers have collectively earned profit while the liquidity-seekers collectively had losses (Figure 6).

As described by Isaac Newton in 1687 every function of time is regarded as a signal pos- sible to describe through a mathematical function (McElroy, 2005). This makes the cur- rency exchange rate as a time series comply with the same mathematical rules as regular sound or trembles from an earthquake. In 1822 the French mathematician Joseph Fourier first claimed that any function, continu- ous or discontinuous, is possible to describe mathematically through the use of only sine functions.

When there is no obvious dominant cycle and the power of the different frequency are fairly evenly distributed we have a random signal also known as white noise. This is how the signal always would behave if the market was per- fectly efficient and the random walk theory would apply. By doing spectral analysis it is possible to identify when the market is not behaving randomly.

Cooley and Tukey (1965) introduced the fast Fourier transform making it possible for computers to calculate large amount of data fast to perform discrete Fourier transform. He concluded that all signals in finance are discrete and aperiodic making the use of the discrete time Fourier transform suitable for finding the sine and cosine waves.

As a solution to this problem Ehlers (2001) suggested the use of the principle of maximum entropy to obtain a higher resolution without adding more sample points. By this he intro- duced the MESA to finance. This transform takes the noise in a spectrum and uses the principle of maximum entropy to estimate the spectrum thus improving the spectral accu- racy. This more modern and advanced transform method is theoretically more suitable for the FX market due to its ability to increase spectrum resolution based on estimates.

There are different strategies and approaches to write a thesis. An inductive approach means that that the scientist starts collecting empirics without any expectations and pro- ceeds to draw conclusions and create theories from the findings. Another strategy is the deductive approach, which means that the scientist sets off from theory and end with em- piric data. This means that the working process starts with creating expectations, followed by collecting empiric data to see whether or not the empiric data correspond to the expec- tations (Jacobsen, 2002).

When having a defined prediction or assumption that can be tested empirically and that can be falsified.

The study uses three different transform methods to perform the calculations necessary to find the dominant cycle. These are DFT, MESA and Hilbert transform. The selection of these methods are based on literature describing characteristics of the different transforms making them suitable for determining trend and cycles on financial markets. The DFT is the general transform used in various applications and recommended in litera- ture to be used with TA. Several early studies have been performed with DFT or similar transforms and it is suitable to use this transform in our study to be able to compare it with previous research. However, the DFT is designed for calculations on large sets of data that does not change over time as much as the financial markets and has therefore been rejected as to slow for trading applications (Dunis & Miao, 2006; Ehlers, 2001). In an experiment testing spectral analysis this transform is necessary to include since it is the most basic and most widely used transform of all (Brigham, 1988). The Hilbert transform is suggested by Ehlers (2001) as a simple and straightforward method to find the dominant cycle even thought it might be too blunt for the financial market. The Hilbert Transform uses very small amounts of data compared to the DFT and does not require even a full-length cycle within the samples to measure the frequency of the wave (Ehlers, 2001). The transform uses the small amount of data available and draws a full series of sine waves by using regression analysis. It estimates how the signal probably looks like and then performs the spectral analysis on the rendered, longer signal (Kaufman, 2005). To include this transform in the study makes it possible to test if this is a solution 18for the low spectral resolution discussed as the flaw of the DFT. If the regression analysis creates a sufficiently good estimation of the real price cycle it could increase the accuracy of the older, less advanced spectral analysis methods. The third and last transform in this study is the MESA as suggested by Ehlers (2002) to be a more precise transform to be used on the financial markets. The transform theoretically manages to use the principle of maximum entropy to estimate the dominant cycle based on a small amount of data. In comparison to the Hilbert transform the MESA transform esti- mates in the frequency domain and not in the time domain, when Hilbert tries to create a longer signal the MESA tries to fill in the gaps after the transform has been conducted (Ehlers, 2002). Due to the higher spectral resolution Ehlers (2002) argues that it is possible to gather enough samples on a shorter time frame with MESA and thereby get a more up to date spectral analysis of the market which is more updated than the long time span re- quired by traditional DFT. This is the only spectral analysis transform we have found men- tioned in literature and articles to be especially suitable for the financial markets and it should theoretically perform better than the other transforms.

The FX market is an over-the-counter market making it possible to trade currencies at any hour of the day. But all currencies are not traded as frequent on all markets, thus making the volume of trade fluctuate during the day. European currencies have a lower trade vol- ume during the nighttime but are still possible to trade on the Asian and American markets. This makes it possible to trade a FX pair in a timeframe during which there are very few fundamental events inflicting on the rates. The exchange rate is more likely to not trend during nighttime resulting in a sideways price movement.

To measure the performance of the different transforms it is necessary not only to look at the total return on investment, but also at the profit factor and the expected payoff. These ratios measure the performance in relation to factors that may inflict on the total perform- ance such as the number of trades and trade volume. The profit factor is the ratio between the gross total profit and the gross total loss of all the trades. This is a measurement which shows not only the performance but also the risk of the investment where a higher value indicates lower risk. Generally a value over 1.5 is considered as a good system performing high-frequency trading. The expected payoff is the average profit or loss (in dollar) per trade. The calculation is (ProfitTrades/TotalTrades)(GrossProfit/ProfitTrades)- (LossTrades/TotalTrades) (GrossLoss/LossTrades). This ratio depends on the initial in- vestment and might be difficult to use as comparison between systems.

All measurements of performance might stem from factors making the test with the high- est total return of investment the worst system in the long run. The result might for in- stance derive from a specific part of the period making it a good system for this specific period but much worse during another period. Another flaw is the problem with compar- ing results. A system may have a high profit factor, but can still perform badly due to a low amount of trades. Therefore, to evaluate a system it is better to investigate the stability of 24the returns rather than the total return. A more stable flow of returns makes it possible to increase the risk in each investment and thereby increase the total return on investment. To measure stability our study uses two recognized measurements of volatility used to ev- aluate funds and other investments. The first one is the standard deviation (σ) of the return which is the square root of the variance of a data set. One standard deviation includes 68 percent of all the returns closest to the mean return and calculates the distance to the re- turn furthers away from the mean. A high standard deviation therefore indicates a more scattered set of returns which defines it as more unstable. The second measurement used in our study is the Sharpe ratio introduced by Nobel laure- ate William Forsyth Sharpe in 1966 originally presented as the reward-to-variability ratio (Sharpe, 1966). The formula, as seen in Figure 10, is the ratio of the asset return minus the risk-free rate of return divided by the standard deviation. This ratio gives a good indication on how stable the returns will be in the future and therefore how reliable the performance is. It is difficult to use the Sharpe ratio for comparison between different markets, but as comparison between strategies trading the same product it is a good tool for finding the most stable one. To understand what is a good ratio, the S&P 500 is commonly used which was estimated to be about 0.32 between 1973 and 1993 (Osler & Chang, 1995).

ujfjhz commented 8 years ago

[CurrencyTradingInTheFXMarket.pdf](https://github.com/ujfjhz/CostBalancer/files/371189