TALi++ - Incremental Technical Analysis Library
Project description
TALIpp - Incremental Technical Analysis Library
talipp
(or tali++
) is a Python library implementing financial indicators for technical analysis. The distinctive feature of the library is its incremental computation which fits extremely well real-time applications or applications with iterative input in general.
Unlike existing libraries for technical analysis which typically have to work on the whole input vector in order to calculate new values of indicators, talipp
due to its incremental architecture calculates new indicators' values exclusively based on the delta input data. That implies, among others, it requires O(1)
time to produce new values in comparison to O(n)
(or worse) required by other libraries.
Supported incremental operations include:
- appending new values to the input
- updating the last input value
- removing arbitrary number of the input values
Besides the already mentioned superior time complexity for delta input operations, talipp
's incremental approach immediately offers other interesting features for free, such as indicator chaining or building new indicators combined from other indicators. See section with examples to get an idea.
Incremental nature of talipp
naturally excels in applications with frequent CUD
operations but it can be used for charting, back-testing, ... as any other existing library.
Last but not least, talipp
is a very young project and therefore open to any suggestions of amending the API to users' liking. You are encouraged to come up with proposals.
What's new in version 1.4.0
- new indicators: Detrended Price Oscillator (DPO), Ease of Movement (EMV), Klinger Volume Oscillator (KVO), Vortex Indicator (VTX)
For the full history of changes see CHANGELOG.
List of incremental indicators
talipp
currently provides below set of indicators. If your favourite indicator is missing, then create a ticket via GitHub Issues and there is a good chance that it will be included in the future version of the library.
- Accumulation/Distribution (ADL)
- Aroon
- Average Directional Index (ADX)
- Average True Range (ATR)
- Awesome Oscillator (AO)
- Balance of Power (BOP)
- Bollinger Bands (BB)
- Chaikin Oscillator
- Chande Kroll Stop
- Choppiness Index (CHOP)
- Coppock Curve
- Commodity Channel Index (CCI)
- Donchian Channel (DC)
- Detrended Price Oscillator (DOP)
- Ease of Movement (EMV)
- Ichimoku Kinko Hyo
- Keltner Channel (KC)
- Klinger Volume Oscillator (KVO)
- Know Sure Thing (KST)
- Mass Index
- Mean Deviation
- Moving Average (ALMA, SMA, SMMA, DEMA, EMA, HMA, KAMA, TEMA, VWMA, WMA)
- Moving Average Convergence Divergence (MACD)
- On-balance Volume (OBV), Smoothed On-balance Volume (SOBV)
- Parabolic SAR
- Pivots High/Low
- Rate of Change (ROC)
- Relative strength index (RSI)
- SFX TOR
- Standard Deviation
- Stochastic Oscillator
- Stochastic RSI
- TRIX
- True Strength Index (TSI)
- Ultimate Oscillator (UO)
- Vortex Indicator (VTX)
Installation
pip install talipp
In case you want to install the latest version from the repo, use
pip install git+https://github.com/nardew/talipp.git@master
Examples
Consult examples
folder to see usage of every single indicator included in the library. To get the basic look and feel of the API, see below.
from talipp.indicators import EMA, SMA, Stoch
from talipp.ohlcv import OHLCVFactory
# EMA indicator ([float] -> [float])
ema = EMA(period = 3, input_values = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10])
# treat indicators as any other list
print(f'EMA(3): {ema}') # [3.0, 5.0, 7.0, 4.5, 4.25, 5.125, 6.5625, 8.28125]
print(f'Last EMA value: {ema[-1]}') # 8.28125
# append a new input value incrementally
ema.add_input_value(11)
print(f'EMA after adding a new value: {ema}') # [3.0, 5.0, 7.0, 4.5, 4.25, 5.125, 6.5625, 8.28125, 9.640625]
# change the last added value
ema.update_input_value(15)
print(f'EMA after updating the last value: {ema}') # [3.0, 5.0, 7.0, 4.5, 4.25, 5.125, 6.5625, 8.28125, 11.640625]
# change the last added value again
ema.update_input_value(18)
print(f'EMA after updating the last value: {ema}') # [3.0, 5.0, 7.0, 4.5, 4.25, 5.125, 6.5625, 8.28125, 13.140625]
# remove the last added value
ema.remove_input_value()
print(f'EMA after removing the last value: {ema}') # [3.0, 5.0, 7.0, 4.5, 4.25, 5.125, 6.5625, 8.28125]
# STOCH indicator ([OHLCV] -> [composite])
stoch = Stoch(5, 3, OHLCVFactory.from_dict({
'high': [5, 10, 15, 20, 25, 30, 35],
'low': [1, 4, 7, 10, 13, 16, 19],
'close': [3, 9, 8, 19, 18, 17, 19]
}))
# print result as a list of composite values for 'k' and 'd' output parameters
print(f'Stoch(5, 3) composite result: {stoch}') # [StochVal(k=70.83333333333333, d=None), StochVal(k=50.0, d=None), StochVal(k=42.857142857142854, d=54.563492063492056)]
# print result as lists per output parameters
print(f'Stoch(5, 3) decomposed result: {stoch.to_lists()}') # {'k': [70.83333333333333, 50.0, 42.857142857142854], 'd': [None, None, 54.563492063492056]}
# Indicator chaining
sma1 = SMA(3)
sma2 = SMA(3, input_indicator = sma1)
sma3 = SMA(3, input_indicator = sma2)
sma1.add_input_value([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
print(f"SMA1: {sma1}") # [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
print(f"SMA2: {sma2}") # [3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
print(f"SMA3: {sma3}") # [4.0, 5.0, 6.0, 7.0]
Performance
To illustrate performance scaling of talipp
we ran several tests together with the industry standard talib
library and its python wrapper ta-lib. The takeaway from the comparison is following:
- for batch processing (i.e. one-off calculation of indicators without addition of further delta values)
talib
is a clear winner. This is not surprising at all since it is implemented in C and it is tailored for vector calculations in one shot.talipp
's incremental (i.e. not vector) calculation and features such as indicator chaining (which internally implements output listeners) must inevitably come at a cost. That being said,talipp
calculates SMA for batch of 50k values incrementally still in ~200ms which is perfectly acceptable for many applications - where
talipp
clearly takes the lead is incremental calculation. Again this is well expected sincetalipp
's CUD operations takeO(1)
time compared toO(n)
time oftalib
. For 50k input the difference is as big as ~200ms vs. ~6800ms. - from the graphs it is apparent that
talipp
scales linearly with the size of the input compared to quadratic curve oftalib
when incremental operations are concerned. This follows fromtalipp
'sO(1)
time for delta operations vs.talib
'sO(n)
.
Contact
- to report issues, bugs, corrections or to propose new features use preferably Github Issues
- for topics requiring more personal approach feel free to send an e-mail to
Support
If you like the library and you feel like you want to support its further development, enhancements and bug fixing, then it will be of great help and most appreciated if you:
- file bugs, proposals, pull requests, ...
- spread the word
- donate an arbitrary tip
BTC
:3GJPT6H6WeuTWR2KwDSEN5qyJq95LEErzf
ETH
:0xC7d8673Ee1B01f6F10e40aA416a1b0A746eaBe68
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file talipp-1.4.0.tar.gz
.
File metadata
- Download URL: talipp-1.4.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6b76be809bddbbb80a5f7cd8d85b3d8ceeff104909ce07a1c3e537690460977 |
|
MD5 | e9cc6c183c8479bb50d54f7a14adc94b |
|
BLAKE2b-256 | d10632f59857f76ad0982ba40c51337669e8b843d89a098ebe9739a726615b28 |
File details
Details for the file talipp-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: talipp-1.4.0-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 728a99e6a4b372efb854a46cc95e516b02e4d481cab584a1c7746ecaae1810b3 |
|
MD5 | 0589234cc84f1e18bd345e2131220779 |
|
BLAKE2b-256 | 7aab1fd20af5076612162ed087b1e73431143467027b707561cd5d015ae56fe5 |