Closed pimsnoek closed 4 years ago
I' ve found the problem. Findiff doesn't support Python 2.7 anymore
Sorry for the late response. Yes findiff does not support Python 2.7, however the rest of the code should support it.
Also findiff has no real good reason not to support it as this library is small, easy to rewrite and not particularly complicated. In the article I wrote I started to go into how the details of it work. If its absolutely critical, a Python 2.7 version of it could be written.
If there are any Python 2.7 bugs in this projects code on the other hand, feel free to report them and they will be fixed or at least support for Python 2.7 deliberately and explicitly removed (which again I see no good reason for).
I hope you can help, I get an error when I run the sample code from example.py I will get this error: "FinDiff objects can only be applied to arrays or evaluated(!) functions returning arrays") from err
I will use Python 2.7. I hope someone can help me to fix this
code from example.py
import trendln import matplotlib.pyplot as plt
import yfinance as yf # requires yfinance - pip install yfinance tick = yf.Ticker('^GSPC') # S&P500 hist = tick.history(period="max", rounding=True) mins, maxs = trendln.calc_support_resistance(hist[-1000:].Close) minimaIdxs, pmin, mintrend, minwindows = trendln.calc_support_resistance((hist[-1000:].Low, None)) #support only mins, maxs = trendln.calc_support_resistance((hist[-1000:].Low, hist[-1000:].High)) (minimaIdxs, pmin, mintrend, minwindows), (maximaIdxs, pmax, maxtrend, maxwindows) = mins, maxs minimaIdxs, maximaIdxs = trendln.get_extrema(hist[-1000:].Close) maximaIdxs = trendln.get_extrema((None, hist[-1000:].High)) #maxima only minimaIdxs, maximaIdxs = trendln.get_extrema((hist[-1000:].Low, hist[-1000:].High)) fig = trendln.plot_support_resistance(hist[-1000:].Close) # requires matplotlib - pip install matplotlib plt.savefig('suppres.svg', format='svg') plt.show() plt.clf() #clear figure fig = trendln.plot_sup_res_date((hist[-1000:].Low, hist[-1000:].High), hist[-1000:].index) #requires pandas plt.savefig('suppres.svg', format='svg') plt.show() plt.clf() #clear figure curdir = '.' trendln.plot_sup_res_learn(curdir, hist)