Tulipy requires numpy as all inputs and outputs are numpy arrays (dtype=np.float64).
You can install via pip install tulipy.
If a wheel is not available for your system, you will need to pip install Cython numpy to build from the source distribution.
In [1]:
import numpy as np
import tulipy as ti
In [2]:
ti.TI_VERSION
Out[2]:
In [3]:
DATA = np.array([81.59, 81.06, 82.87, 83, 83.61,
83.15, 82.84, 83.99, 84.55, 84.36,
85.53, 86.54, 86.89, 87.77, 87.29])
Information about indicators are exposed as properties:
In [4]:
def print_info(indicator):
print("Type:", indicator.type)
print("Full Name:", indicator.full_name)
print("Inputs:", indicator.inputs)
print("Options:", indicator.options)
print("Outputs:", indicator.outputs)
In [5]:
print_info(ti.sqrt)
Single outputs are returned directly. Indicators returning multiple outputs use
a tuple in the order indicated by the outputs property.
In [6]:
ti.sqrt(DATA)
Out[6]:
In [7]:
print_info(ti.sma)
In [8]:
ti.sma(DATA, period=5)
Out[8]:
Invalid options will throw an InvalidOptionError:
In [9]:
try:
ti.sma(DATA, period=-5)
except ti.InvalidOptionError:
print("Invalid Option!")
In [10]:
print_info(ti.bbands)
In [11]:
ti.bbands(DATA, period=5, stddev=2)
Out[11]:
If inputs of differing sizes are provided, they are right-aligned and trimmed from the left:
In [12]:
DATA2 = np.array([83.15, 82.84, 83.99, 84.55, 84.36])
In [13]:
# 'high' trimmed to DATA[-5:] == array([ 85.53, 86.54, 86.89, 87.77, 87.29])
ti.aroonosc(high=DATA, low=DATA2, period=2)
Out[13]: