dysonance / trendy Goto Github PK
View Code? Open in Web Editor NEWNumerical trendline algorithms for technical analysis of financial securities.
License: GNU General Public License v2.0
Numerical trendline algorithms for technical analysis of financial securities.
License: GNU General Public License v2.0
sorry for the way I do this, it is my first comment
only include this
x = x[window+1:]
y = y[window+1:]
before
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)
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
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.
# 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.