## Is it possible to predict the next return’s sign by looking for historical patterns?

One of the main problems when trying to develop **investment algorithms** is finding an estimator (with the intention to predict future returns) that minimizes error between the estimation and the real return.

As we can see in “Vecinos cercanos en una serie temporal“, there are many algorithms, like Nearest Neighbors, Artificial Neural Network or Genetic Algorithm, that can be used with this goal.

In this post we are going to develop an algorithm, called **Pattern Identification**, which seeks the market situation for past movements. Once this situation is identified in the past, this will help us to estimate the sign of the next return.

**Pattern Identification Algorithm **

Starting with a daily returns series, each day we take the sign of the last 20 values (sequence or pattern) and look for this sequence in the whole historical series.

In all successful cases, we check the sign of the next daily return. The sign that appears in the largest number of cases is going to be the estimator.

If patterns are not found with search, the process is repeated with a smaller pattern (19 in the first iteration and so on).

**Results**

Working with a sample of 8500 assets (Fixed Income Funds, Equity Funds, Fixed Income ETFs, Equity ETFs & Stocks), the median percentage of success (the estimation is positive / negative and the real return is positive / negative) is 50.7% (48.62% in percentile 5 and 52.87% in percentile 95).

This success is due to 2 different situations:

**True Positives**(TP): when the estimation’s sign is positive and the real return’s sign is also positive (+ => +).**True Negatives**(TN): when the estimation’s sign is negative and the real return’s sign is also negative (- => -).

The same thing happens with failures (when the algorithm fails):

**False Positives**(FP): when the estimation’s sign is positive and the real return’s sign is negative (+ => -).**False Negatives**(FN): when the estimation’s sign is negative and the real return’s sign is positive (- => +).

Separating by asset types and calculating the evaluation metrics that can be derived from the confusion matrix:

And the ROC space…

**Conclusions**

With the proposed method to estimate future returns, we can obtain **results with over 50% accuracy. Furthermore sensitivity, fall-out and precision remain above 50%**. All these statistics are higher in Fixed Income Funds and ETFs and lower in Stocks.

However, since the MCC is near to 0 (read the post titled “Confusion matrix & MCC statistic“), **we can state that Pattern Identification is not better than a random predictor**.