Giter Club home page Giter Club logo

trendy's Issues

IndexError: boolean index did not match indexed array along dimension 0

Hi @dysonance,

When I do

# find trend on closing price
trendy.minitrends(ohlc.c, window=30, charts=True)

I get the following error IndexError: boolean index did not match indexed array along dimension 0.

    143     # Find whether max's or min's
--> 144     maxi = (y[x[crit]] - y[x[crit] + window] > 0) & \
    145            (y[x[crit]] - y[x[crit] - window] > 0) * 1

Let say n = len(ohlc.c), so in the function minitrends, x and y have shape (n, ), but crit has shape (n-window-1,). I think this is because numpy has evolved since you wrote the package. Can you provide a more modern implementation for these line of code?

My environment is:

python 3.6.9
numpy 1.16.4

minitrend fixed

sorry for the way I do this, it is my first comment

only include this

x = x[window+1:]
y = y[window+1:]

before

Find whether max's or min's

maxi = ((y[x[crit]] - y[x[crit] + window] > 0) & \
       (y[x[crit]] - y[x[crit] - window] > 0) * 1)
mini = ((y[x[crit]] - y[x[crit] + window] < 0) & \
       (y[x[crit]] - y[x[crit] - window] < 0) * 1)
maxi = maxi.astype(float)

image

bug in gentrends

Hi Jacob,

I found a small bug in gentrends.
in your section"# Find the indexes of these maxima in the data# Find the indexes of these maxima in the data", you forget that the min or max value can be found before segment starting point.
Here is the fix.

Implement trendlines

# Find the indexes of these maxima in the data
segments = int(segments)
maxima = np.ones(segments)
minima = np.ones(segments) 
x_maxima = np.ones(segments)
x_minima = np.ones(segments)
segsize = int(len(y)/segments)
for i in range(1, segments+1):
    ind2 = i*segsize
    ind1 = ind2 - segsize
    seg = y[ind1:ind2]
    maxima[i-1] = max(seg)
    minima[i-1] = min(seg)
    x_maxima[i-1] = ind1 + (np.where(seg == maxima[i-1])[0][0])
    x_minima[i-1] = ind1 + (np.where(seg == minima[i-1])[0][0])

Francis

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.