The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Tag Info

Hot answers tagged algorithm

26

As mentioned elsewhere on this site, Lo, Mamaysky, and Wang (2000) do exactly what you're talking about, namely algorithmic detection of head and shoulders patterns. Their definition: Head-and-shoulders (HS) and inverted head-and-shoulders (IHS) patterns are characterized by a sequence of five consecutive local extrema $E_1,...,E_5$ such that  HS \...

17

I would recommend that you read "Evidence-Based Technical Analysis" by David Aronson. Firstly, I am mentioning it because it is a highly worthwhile book. Secondly, on pp151--161 he attempts to "objectify subjective TA", using the head-and-shoulders pattern as an example.

14

Dynamic Time Warping, recursive, time-delayed feedforward neural networks, wavelets, empirical mode decomposition, ..., there's plenty of it. BUT If you want my advice, don't go this way, I wasted too much time doing things like that. Neither big nor small players (profitably and consistently) trade this way and for a good reason. Technical analysis is a ...

11

After having done a lot of research on the topic I found the following excellent research piece on ETF.com: Wealthfront modifies historic asset-class returns with current market implied expected returns (Black-Litterman) as well as with the in-house views of Chief Investment Officer Burton Malkiel’s team. In addition, Wealthfront sets minimum and ...

9

For years, I performed this brute-force search daily on my universe of tradable stocks and futures. It is a waste of time. If your computer discovers that hog futures and MSFT are cointegrated, for example, do you really care? I would never trade that pair. There is no economic connection between hogs and Microsoft, so I must assume that the reported, small ...

8

Theoretically, the answer to the question is yes, a correlation matrix for potential pairs trades can be computed in $O\left((n^2t)^{(\omega+\epsilon)/3}\right)$ time, for any $\epsilon > 0$, where $\omega < 2.38$ is the so-called exponent of matrix multiplication. However, these algorithms have a reputation for having a very large constant factor ...

8

You can find an exact algorithm with a step-by-step explanation here: https://www.dropbox.com/s/t4fq067kzx26mhw/project_paper.pdf As you can see from the URL it is an archived document because the original site is unfortunately long gone and the tool referenced in the paper with it :-( But it should be helpful anyway to understand what is going on. Notice ...

8

I think you might find this answer in The future language of quant programming? useful. People get this problem wrong because they always end up discussing the theoretical advantages of these languages rather than the practical uses of these languages. Theoretically speaking: Haskell is elegant and has many of the theoretical advantages (language ...

8

The following link has a good summary of a typical pair trading strategy: https://www.quantstart.com/articles/Backtesting-An-Intraday-Mean-Reversion-Pairs-Strategy-Between-SPY-And-IWM It actually has full python code as well. It doesn't include a cointegration check though. Edit: if X and Y are cointegrated: calculate Beta between X and Y ...

7

I just made a Genetic Algorithms calculator you can try at http://www.gregthatcher.com/Stocks/GeneticAlgorithmCalculator.aspx I'm not a "quant expert" like all of you (I'm just a programmer), but here is what I've found. 1.) If you set the constraints up correctly, the results are amazing. e.g. you can get portfolios that have very high return and low risk....

7

Measuring expected shortfall (also known as conditional value-at-risk) answers the simpler question of "what is my average expected loss at the i-th quantile?" given the empirical distribution of returns. A variation is value-at-risk which measures the loss at the i-th quantile. Arguably you could leave at this this and you have your answer. You probably ...

6

The most basic strategy is beta-based quantiles. That is to say, you first control for losses on your individual stock versus overall market performance. (Your trading strategy may or may not wish to hedge away the market factor using, say, SPX futures). Then you choose a quantile, call it the 5th percentile, beyond which you consider a move to be ...

5

Hello people. This is quite a complex problem if you want to solve this in a computationally efficient way for a rolling window. I have gone ahead and written a solution to this in C#. I want to share this as the effort required to replicate this work is quite high. First, here are the results: here we take a simple drawdown implementation and re-...

5

I won't give you the answer delivered on a silver platter but hopefully the following will get your started: a) you need to define exactly over which look-back period you aim to derive the maximum drawdown. b) you need to keep track of the max price while you iterate the look-back window. c) you need to keep track of the min price SUBSEQUENT to any NEW ...

5

One idea is Dynamic time warping (DTW). There is an R package for that: dtw Here is the vignette:Computing and Visualizing Dynamic Time Warping Alignments in R: The dtw Packageby Toni Giorgino And here is an example from Systematic Investor with full code: Time Series Matching with Dynamic Time Warping

5

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 time series patterns have any predictive power. It's an interesting read and should equip you with some ideas on how to differentiate between folklore and statistical rigor. It also gives you ample ...

5

SOLUTION: Let $r_t$ be the log-return at time $t$, and $\hat{r}_t$ be the predicted log-return from the regression model. Initialize $loglik(0:T)=0$,$\epsilon_1=0$, $\sigma_1 = 0$, $\mu=U(0,1)*0.0001,\phi=U(0,1)*0.01$, $\alpha_0=U(0,1)*0.00002,\alpha_1=U(0,1)*0.01,\beta_1=0.9 + U(0,1)* 0.01$, $B=10,000$ For $b$ = 1 to $B$ $\quad$ For $t$ = 2 to $T$: $\... 5 I would create categories, and work on risk parity among the categories. Otherwise, variance is not really a good measure of downside risk: Change your risk measure, use a rolling window historical VaR or Expected Shortfall at some horizon that matches your investment style. downside semi-variance could do the trick too if don't want to change your algo ... 5 Unfortunately, there is no correct answer for this question, it's like what car you should drive on your weekend. C++ is a popular language in quantitative finance, but it's usually (but not always!) only used to build the application backbone, such as derivative pricing. Why C++? C++ is a good choice because C++ is platform independent, we can natively ... 4 You question is quite strange: so you do not want to use methods inspired by bioinfo and genetics (neural networks, GA, geometry of folding, etc) but methods that are used in these fields? In terms of modeling, the problematics in bioinfo and genetics are mainly: tree or graph matching (to build metrics in the space of molecules), like in SIGMA: a Set-... 4 Mathematically speaking that is an impossible thing to do. There are simply too many variables and randomness that you cannot do it. Rather than analyzing competitors trade data; why don't you analyze the market. You can consider every bar; as a trade. If the bar was up; it means you went long and made a profit. If the bar was down; it means you went short ... 4 I am not sure they are comparable as they serve for slightly different purposes. In robotics (specifically vision), Hough Transform is used for objects (or shape) detection. This can subsequently be used for objects tracking, but Hough Transform has no prediction phase. On the other hand, Kalman Filter is a two phase algorithm; measure and predict. With ... 4 Perhaps construct a Brownian Bridge between the day's open and close, then scale it according to the day's high and low. 4 Some reading that may be of interest to you and which proceeds along similar lines of thought is that of Shmilovici in "Predicting Stock Returns Using a Variable Order Markov Tree Model". Abstract: "The weak form of the Efficient Market Hypothesis (EMH) states that the current market price fully reflects the information of past prices and rules out ... 4 Assume$p_i(x)\$ is a payoff of one particular option. You can try to reproduce the diagram using a bunch of options with strikes on the breakpoints (underlying is useless, because its payoff can always be modelled by buy&sell of a certain call and put). Then you can create a system of k equations with n unknowns (number of each kind of option). All other ...

4

Well, I did some modest research on this topic, looking at peers. Most of them use Modern Portfolio Theory, see this pic: You can find this small survey here: https://www.linkedin.com/pulse/roboadvisors-like-commodore-vic20-apparently-according-raffaele-zenti?trk=mp-reader-card The sector, I mean Roboadvisors, has a lot of disruption potential, obviously....

4

I've read this question and the other question you asked and I hope I can help. The important thing to realize that in any market multiple market makers operate and they are all trying to optimize their risk adjusted return. A market maker earns a return buying low and selling high. Suppose you are the only market maker and you quote this spread: 1 | Bid ...

3

How about an O(N log(n)) solution ? To be a viable trading strategy, you often expect them variances to be similar, so just calculate ordinary volatility and put it in an ordered array. Of course that's going to be period dependent, so pick a few arbitrary periods and see which instruments end up being together. Then you get clusters of vastly smaller ...

3

Zipline, the opensource python backtester, has a batch and iterative implementation for max drawdown. Here is the batch: https://github.com/quantopian/zipline/blob/master/zipline/finance/risk.py#L284 Here is the iterative: https://github.com/quantopian/zipline/blob/master/zipline/finance/risk.py#L578 disclosure: I'm one of the zipline maintainers

3

I do recommend to you the chapter 8 of the Ernest Chan book "Quantitative Trading: How to Build Your Own Algorithmic Trading Business" The chapter's name is "Conclusion: Can Independent Traders Succeed? " The conclusion is that yes but I now cant remember very well the chapter...

Only top voted, non community-wiki answers of a minimum length are eligible