Labels

Wednesday, October 24, 2018

quantitative finance - Pattern Recognition on Financial Data









In Finviz screener they can detect pattern like Head and Shoulders, Trendline Support, Wedge

Perhaps the most well-known measure of “similarity” is correlation; but this is entirely unsuited to the task at hand.  The reason is that correlation removes the very thing that traders are most interested in: the trend, or drift. 
Dynamic Time Warping (DTW) and correlation capture very different aspects of similarity between two time-series.

These are some suggestions that might be useful.
1.      The data on the curve are bumpier than the roads in my country. So I think you should start by smoothing the curve. There are many smoothing filters like from the simplest median smoothingto Local Regression models like LOESS. There are some parameters to tweak. Take a look at the example.
2.      Finding the local maxima. Python's numpy has an implementation for this and this should help.
My idea is to basically smooth till you get your head and shoulders i.e., three maxima.

Statistical pattern recognition techniques such as CART, recursive partitioning, kernel regression, support vector machines (SVMs)
1.      Bulkowski, T.N. (2000) Encyclopedia of Chart Patterns, John Wiley and Sons, NewYork.
2.      Laedermann, S. (2000), “Head-and-Shoulders Accuracies and How to Trade Them.” IFTA Journal, Vol. 2000 Edition, pp 14-21
3.      Lo, A., Mamaysky, H. and Wang, J. (2000), “Foundations of Technical Analysis: Computational Algorithms, Statistical Inference, and Empirical Implementation.” Journal of Finance, Vol. 55, pp. 1705-1765
4.      Osler, C. L., and Chang, P. H. K., (1995) “Head and Shoulders: Not Just a Flaky Pattern.” Federal Reserve Bank of New York, Staff Reports, Report No. 4

Dynamic Time Warping (DTW) distance

DTW is a method that calculates an optimal match between two given sequences (e.g. time series). It has been used in a supervised learning setup, in particular it has been reported to achieved state of the art results, when used in a nearest neighbour classifier. Dynamic Time Warping, recursive, time-delayed feed forward neural networks, wavelets, empirical mode decomposition, ..., there's plenty of it.

by Toni Giorgino
And here is an example from Systematic Investor with full code:

Time-series clustering – A decade review Saeed Aghabozorgi, Ali Seyed Shirkhorshidi, Teh Ying Wah http://www.sciencedirect.com/science/article/pii/S0306437915000733
1.        Manhattan distance
Math.Abs(a[i]-b[i])
2.        Euclidian distance
Sqrt(Sum(Pow(a[i]-b[i],2)))
1) ED can only be applied to series of equal length. Therefore when points are missing, ED simply is not computable (unless also cutting the other sequence, thus loosing more information).
2) ED does not allow time-shifting or time-warping opposed to all algorithms which are based on DTW.

Markov Analysis

Momentum

There is so much finance literature on this topic, I don't even know where to begin. Specifically on momentum, some of the earlier foundational papers are
·         Momentum Strategies
Momentum has an entire page devoted to it at behaviouralfinance.net.
Lo, Mamaysky, and Wang (2000) conduct rigorous tests of a variety of popular technical indicators (although not specifically the ones you mention).

You might want to check out the book Evidence Based Technical Analysis by David Aronson. In it he applies statistical techniques to determine whether certain technical analysis indicators and ensembles have any predictive power. It's an interesting read and should equip you with some ideas on how you might perform a similar analysis.

Cliff Asness's PhD thesis was based on Momentum and Value. AQR has a lot of interesting research.
Jegadeesh and Titman (Returns to Buying Winners...- first paper linked in the above answer ) seems to be the standard reference.
Renowned CXO Advisory Group have created a research compendium exclusively on momentum investing. This is the most exhaustive treatment of the topic I have ever seen:
With $25 the price is reasonable.


Head-and-shoulders (HS) and inverted head-and-shoulders (IHS) patterns


Head-and-shoulders (HS) and inverted head-and-shoulders (IHS) patterns are characterized by a sequence of five consecutive local extrema E1,...,E5 such that
HS{E1 is a maximumE3>E1,E3>E5E1 and E5 are within 1.5 percent of their averageE2 and E4 are within 1.5 percent of their average,




Reference:

https://www.aqr.com/Strategies#overview
https://quant.stackexchange.com
http://www.cs.uccs.edu/~jkalita/work/StudentResearch/RajagopalSureshMSProject2016.pdf



Books

Technical Analysis for Algorithmic Pattern Recognition



to become a quantitative developer
Scientific Computing
Programming Skills

Accelerated C++ by Andrew Koenig
Effective C++ by Scott Meyers
Scott Meyers has also written More Effective C++ and Effective STL

Learning Python by Mark Lutz
Mark Lutz's second book, Programming Python
 Python for Data Analysis by Wes McKinney

One of the largest quantitative finance projects is the QuantLib project

Software Engineering
Steve McConnell's Code Complete and Robert Martin's Clean Code
 Design PatternsFactory, Decorator or Singleton
free eBook Pro Git
Paul Duvall's Continuous Integration

No comments:

Post a Comment