Jesse offers many its own indicators which is basically an extended wrapper around the ta-libopen in new window library.
The API has been designed to be the simplest yet flexible enough for all types of needs from developing strategies to doing research in Jupyter Notebooks.
To get started make sure the
indicators module is imported:
import jesse.indicators as ta
The first parameter of all indicators is
candles with the type of a Numpy array.
When developing strategies, usually all you care about is the indicator's value for the current candle. To get just that, simply pass
# give me SMA with period=8 for current candle: ta.sma(self.candles, 8)
To get indicator values for candles other than your trading route (in case you have defined more than one route in your
routes.py file), use
ta.sma(self.get_candles('Binance', 'BTC-USDT', '4h'), 8)
The return type of all indicators returning multiple values is a
namedtuple Python object. In case you're not familiar with the concept of
namedtuple in Python, it's just like a regular tuple but you can also use it as a class object.
For example here are two ways you could use the Bollinger Bands indicator, which as you know, returns three values:
- Use it as a normal tuple:
# as three variables upperband, middleband, lowerband = bollinger_bands(self.candles, period=20) # or you could fetch it as one tuple and retrieve values as you would from a tuple: bb = bollinger_bands(self.candles, period=20) bb # upperband bb # middleband bb # lowerband
- The second way it to use it as a class instance:
bb = bollinger_bands(self.candles, period=20) bb.upperband bb.middleband bb.lowerband