Stock-Prediction-Models icon indicating copy to clipboard operation
Stock-Prediction-Models copied to clipboard

ABCD Strategy seems to use future knowledge

Open nlothian opened this issue 6 years ago • 1 comments

    ma = pd.Series(trend).rolling(ma).mean().values
    x = []
    for a in range(ma.shape[0]):
        for b in range(a, ma.shape[0], skip_loop):
            for c in range(b, ma.shape[0], skip_loop):
                for d in range(c, ma.shape[0], skip_loop):
                    if ma[b] > ma[a] and \
                    (ma[c] < ma[b] and ma[c] > ma[a]) \
                    and ma[d] > ma[b]:
                        x.append([a,b,c,d])

This is pretty dense code so I'm probably wrong here, but it looks to me like this takes values derived from the (backwards) moving average (which fine), but it loops forward over the time period (which isn't).

The easiest way to see this is to pass in different length datasets. The trading strategies should be identical up to the end of the shortest strategy. However, they diverge significantly before this.

In this example, I pass in 60 days vs 80 days of data, and the trading strategy diverges after 8 days

image

image

nlothian avatar Oct 22 '19 06:10 nlothian

Looking over the code the abcd strategy seems to look for trends in forms of s the problem is that the decision on a point i should be based only on the result when d = i (in the code). This is simply not true. This code precisely eliminates the biggest failures that this method would have, that is, forecasting a sale and having had to buy or vice versa

ansev-0 avatar Jul 06 '20 13:07 ansev-0