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

TypeError: 'NoneType' object is not subscriptable #1

Open
dRing2000 opened this issue Jan 11, 2021 · 6 comments
Open

TypeError: 'NoneType' object is not subscriptable #1

dRing2000 opened this issue Jan 11, 2021 · 6 comments

Comments

@dRing2000
Copy link

dRing2000 commented Jan 11, 2021

Initializing optimal trading strategy... Traceback (most recent call last): File "./run_bot.py", line 12, in <module> mojo.main(parameters.API_KEY, pair=parameters.pair, granularity=parameters.granularity, duration=parameters.duration, cash_buffer=parameters.cash_buffer, reframe_threshold=parameters.reframe_threshold, continuous=parameters.continuous, chandelier=parameters.chandelier) File "/home/pi/Pi-Trader-master/helper_monkey.py", line 309, in main history_array, buy_point, sell_point = iterate_signal(history_array, best_strategy, pair=pair, granularity=granularity, chandelier=chandelier) File "/home/pi/Pi-Trader-master/helper_monkey.py", line 230, in iterate_signal history_pd = strategize(history_pd, strategy=strategy, chandelier=chandelier) File "/home/pi/Pi-Trader-master/helper_monkey.py", line 113, in strategize if (m[i,3] > (m[i-1,3] + strategy['buy']*m[i-1,5])) and (m[i-1,5]>0): TypeError: 'NoneType' object is not subscriptable

got this after filling API key details and issuing ./run_bot.py command. I'm using XLM/BTC trading pair. 0 XLM, small amount of test BTC on account.

@dRing2000
Copy link
Author

I get the same error using the default BTC-USD trading pair also.

@metalcorebear
Copy link
Owner

Thanks for pointing this out. What is the granularity set to? I’ve not tested it at granularity values other than 300 (5 min) and 900 (15 min). I’ve also not tested with pairs other than USD-BTC. I’ll look into this a bit. It’s a new script and could be a little buggy.

@Mushguys
Copy link

As far as I can tell, this is caused when no strategies have a profit greater than zero.
When that happens, no strategies "beat" the default best_strategy of None in find_optimal_strategy.
This None is returned up the stack to main, which passes it to iterate_signal, which can't subscript it, thus the error.

@metalcorebear
Copy link
Owner

Oh interesting. That makes sense. I didn’t consider that potential failure point. Will update the script to correct that. Thanks for pointing it out.

@metalcorebear
Copy link
Owner

OK, I fixed the NoneType issue in the helper_monkey.py script. It will now default to a {'buy':1.0, 'risk':1.0} strategy in the event that an optimal strategy can't be found.

@metalcorebear
Copy link
Owner

When I have a little bit more time, I think I am going to add a feature where the user can override the strategy optimization and set a default strategy of their choosing.

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