Galts-Gulch / avarice

Multi-Indicator Python3 OKCoin CN & Intl Trading Bot/Infrastructure
Other
91 stars 29 forks source link

AttributeError: 'module' object has no attribute 'BollBands' #9

Closed ghost closed 9 years ago

ghost commented 9 years ago

Doing some more testing and have never been able to get bollinger bands to work. Here is the error I receive when attempting to run a simulation.

Database is recent enough; resuming Waiting 12.1 minutes to resume on schedule Connecting to Public OKCoin WebSocket... Candle: 32 | Price: 1333.15 cny | Time: 00:32:58 | Date: 2015/02/01 Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner self.run() File "C:\Python34\lib\threading.py", line 1187, in run self.function(_self.args, *_self.kwargs) File "C:\AvariceSimulation\genutils.py", line 15, in do_every worker_func() File "C:\AvariceSimulation\avarice.py", line 34, in RunCommon strategies.Generic() File "C:\AvariceSimulation\strategies.py", line 15, in Generic hidind = getattr(hidconfig, i) AttributeError: 'module' object has no attribute 'BollBands'

RealJohnGalt commented 9 years ago

This is a very good issue and affects a rewrite I just started!

At the time of adding these volatility indicators (standard deviation, bollinger bands, and rate of change), they were only meant to extend the capabilities of custom strategies which may be written from scratch. If you look at strategies.py and wipe out Generic, all that would need to be done in a custom strategy is append the following to Trade_List: 'Buy' for a buy, 'Sell' for a sell, and otherwise 'None'. Documentation on this was planned, but is instead being put aside for the strategy rewrite I just started, since that will cover most custom strategy capabilities without needing to write python.

Bollinger bands are not supported for trading since no direct signals are generally derived from them (they're purely a volatility indicator). The current generic strategy only supports indicators which use buy/sell signals. I'll add this to the documentation now. If looking for price crossovers to derive signals, then SMA is used instead.

We also have a bollinger bandwidth indicator that isn't setup for trading. This should be setup to use thresholds and only used with a non-volatility indicator. With the strategies rewrite, volatility indicators will be marked as such in hidconfig and only used to allow a signal from one or more indicators (I actually didn't realize this should be done until this issue).

tl;dr: Support for volatility indicators to be paired with non-volatility indicators is in the works, however bollinger bandwidth will be chosen over bollinger bands since the former can be supported outside of custom written strategies.

Thank you again for testing. If you have suggestions on other ways bollinger bands could be applied and configured, I would appreciate hearing them.

RealJohnGalt commented 9 years ago

I updated the documentation for these indicators to help out until this rewrite's complete.

ghost commented 9 years ago

I was looking to pair Bollinger Bands with MACD as I've read that it's a pretty good strategy to trade with. But the strategy I was looking at also mentioned that you needed to look at volume to determine if it was a buy or a sell. As far as I know the bot doesn't look at volume but I haven't gone through the complete code to determine if that is true or not.

RealJohnGalt commented 9 years ago

It currently doesn't. Do you have a link to anything describing this strategy?

Edit: The bot doesn't use volume for anything simply because we don't have any indicators which need it. This is actually something very simple to add.

Edit2: Bollinger bands are relative to the price, whereas bollinger bandwidth is simply (Upper Band - Lower Band) / Middle Band. This is why I said that it would be difficult to use them over bollinger bandwidth.

ghost commented 9 years ago

It was around 1am lastnight and I didn't save the link for the YouTube video unfortunately. Volume looked to be more of a visual queue to determine the strength of the trend, the presenter said to use it as a second confirmation (after MACD) to confirm the trend. He was using MACD with Bollinger Bands trading on the forex currency pairs were GBP / USD.

RealJohnGalt commented 9 years ago

That sounds good. MACD and other trend following momentum indicators are often paired with volatility indicators because they make money in a trending market, but lose when a market isn't trending (or a "sideways" market). If you don't mind, I'd like this to wait until after the rewrite is finished. It's adding native support for most of what you want to do.

Good documentation in a "Configuring" section is going to be key for this to succeed, but here's how it's looking so far:

This maintains all current functionality since the currently functional configurations may still be used in genconfig without any changes. However it also adds much more advanced functionality.

ghost commented 9 years ago

Yeah no problem, no rush at all and was just bringing the issue I was running into, to your attention. I'll continue to test and let you know what else I find.

So far it's a really awesome application and one that is extremely versatile. If you do add ADX to the list, I believe your bot will be the only one that I know that is openly available that will have it.

RealJohnGalt commented 9 years ago

Thank you. ADX is up next after this rewrite. I took a look at ADX and it should be reasonably quick for me to implement. I really think this rewrite will only make it more versatile for traders who want to run more advanced strategies without actually writing any python.

RealJohnGalt commented 9 years ago

This should be fixed in the new strat-rewrite merge into master :+1: . There's documentation on how you may accomplish what you want in http://galts-gulch.github.io/avarice/configuring/ .

I'll continue doing more testing before tagging this as a new beta.