-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implementing a new Custom Indicator: AttributeError: 'NoneType' object has no attribute 'size' and #342
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
Comments
You need (first error) the self.SuperTrend = Indicators_Class.SUPERTREND(self.data.df, 7, 3) Additionally (second error), you need to wrap the indicator computation in self.SuperTrend = self.I(Indicators_Class.SUPERTREND, self.data.df, 7, 3) |
Thank you! I knew it was going to be something easy, I just wasn't seeing it. I used the second recommendation you gave and it worked just fine. Thanks a lot! |
Although, now that I say that, I should clarify another error I'm getting. I'm creating the SUPERTREND function in a way that the backtesting library will then plot the line on the chart for me, which it is not doing. So if you add
Any idea? |
Yeah, this is the project issue tracker. It's polite to everyone subscribed to first use the search. See #233. |
My apologies, thank you for pointing me in the right direction, I think I see the timestamp issue and will fix on my end. Great support! Thanks! :) UPDATE That was exactly the issue, I am downloading datasets from Yahoo Finance and the format that the timestamps come in doesn't jive with backtesting, so to finish this off, to fix the plotting issue, I just did this right after importing the .csv file:
This fixed the format and plotted nicely. Thanks again. |
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
I'm looking to just add on to the indicators library, trying to copy the format used for the SMA. Currently, I'm trying to create the SuperTrend indicator, which can be generated using the Pandas TA library, however I'm running into some errors which I can't quite figure out what's happening. It has to do with the
next()
function of backtesting somehow (I think).I've attached a full working code (with comments) for anyone to recreate my issue. Here is a list of dependencies needed to run it:
Running this on Python 3.7.9 and Windows 10.
As you'll see, I define a custom
Indicators_Class
in the middle with some functions to return both the default SMA as a boilerplate, and the SUPERTREND, which I'm trying to get working. The top section just downloads AAPL's dataset from Yahoo Finance and saves it to a .csv file, which can be glanced over as the issue lies with either theIndicators_Class
or the backtesting section near the bottom.Steps to Reproduce
So, using this full code to recreate the issue (sorry about the length, but it is a full working example that downloads a dataset, etc.):
Actual Behavior
...I receive this traceback:
Which I thought had something to do with how I was passing in the data to the
SUPERTREND()
function, so I changed line 138:from
self.SuperTrend = Indicators_Class.SUPERTREND(self.data, 7, 3)
to
self.SuperTrend = Indicators_Class.SUPERTREND(df, 7, 3)
...after doing so, I get the following traceback:
...which I think I'm receiving because the length of
self.data
at that point during the backtest is only 2, and the length ofdf
that I passed into theSUPERTREND()
function is 506.Additional info
So, I'm trying to get this SUPERTREND indicator working by following the boilerplate SMA template, however I'm running into these two issues. I think it has to do with converting to
pd.Series()
in some capacity or another, but I'm stuck, would like to figure it out so I can keep adding to that indicator library for plotting purposes. Thanks!The text was updated successfully, but these errors were encountered: