Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using calc_support_resistance with certain parameters #10

Open
dchhetri opened this issue Jun 10, 2020 · 2 comments
Open

Error when using calc_support_resistance with certain parameters #10

dchhetri opened this issue Jun 10, 2020 · 2 comments

Comments

@dchhetri
Copy link

dchhetri commented Jun 10, 2020

I want to first thank you for this contribution. This library is great.

I am using Python 3.7.5

Using extmethod=METHOD_NAIVECONSEC throws the following error

File "pandas/_libs/tslibs/c_timestamp.pyx", line 236, in 
pandas._libs.tslibs.c_timestamp._Timestamp.__add__
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer 
supported.  Instead of adding/subtracting `n`, use `n * obj.freq`

Using method=trendln.METHOD_HOUGHPOINTS throws the following error

File "/usr/local/lib/python3.7/site-packages/trendln/__init__.py", line 587, in hough_points
rhos = np.linspace(-diag_len, diag_len, diag_len * 2.0)
File "<__array_function__ internals>", line 6, in linspace
File "/usr/local/lib/python3.7/site-packages/numpy/core/function_base.py", line 121, in linspace
.format(type(num)))
TypeError: object of type <class 'float'> cannot be safely interpreted as an integer.

Furthermore, I'm wondering if you're open to taking feature request like more efficient calculation given stream of data?

@GregoryMorse
Copy link
Owner

Hello, thanks for the report and feedback! Can you tell me the version of Python and numpy you are using? The METHOD_HOUGHPOINTS error looks easy to sort out probably just need an int() cast or change 2.0 to 2. The first one also looks like a relatively easy fix as long as its backwards compatible. My suspicion is this could be broken in the latest python versions that I have not used yet.

As for weighted volume, I don't see why it is not supported, simply pass the already weighted volume to the library and it should return the support and resistance lines for it. If you mean the plotting of it, then yes its a good request and the plotting area need some rewriting anyway based on other requests too and the way it should not chain to the main library function but instead let you specify what from that you want to display. Displaying volume should be straight forward for inclusion in next version.

For streams of data, probably a small helper function is likely needed. Since there is a window size, all you have to do is pass the new data plus a window size preceding the new data, and then just merge the trend lines with the ones you already have. But I can add a function which takes the old trend line data, the final window of that trendline data, as well as new data and simply returns the trend line set again. Although not stream lined for this use, it should not be hard to do, but yes merging the trend line code is already in there and not really accessible for this purpose. I will consider this for the next version for sure.

@Meciah
Copy link

Meciah commented Sep 26, 2020

I had the same issue as @dchhetri and changing the 2.0 to 2 in line

{ rhos = np.linspace(-diag_len, diag_len, diag_len * 2.0) }

Worked!

Thank you @GregoryMorse !! I have really enjoyed this package. I believe it is an issue with numpy versions because I switched to my Mac from my PC anaconda environment and the same code started producing the error on my Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants