Pytalib is a python technical analysis library developed CMSC5720 project group which support various types of technical indicators. Pytalib adapts object oriented paradigm that each indicator is represented as an object. Unlike function-based library, using objects allow us to store some intermediate variables, for example Average gain/loss in RSI. This improves flexibility if we want to do further analysis on indicators.
Python 3.6.4
- Networkx
- Scipy
Pytalib has been published on Python Package Index (PyPi). Pytalib can be installed using the following command.
pip install pytalib
- Moving Average Convergence Divergence
- Simple Moving Average
- Weighted Moving Average
- Exponential Moving Average
- Trix
- Average Directional Index
- Commodity Channel Index
- Detrended Price Oscillator
- Mass Index
- Vortex Indicator
- Rate of Change
- Relative Strength Index
- Stochastic Oscillator
- Money Flow Index
- True Strength Index
- Ultimate Oscillator
- Williams
- Know Sure Thing Oscillator
- Average True Range
- Bollinger Bands
- Price Channel
- Keltner Channel
- Standard Deviation
- Accumulation Distribution Line
- Ease of Movement
- Force Index
- Negative Volume Index
- On Balance Volume
- Put Call Ratio
Implementations the following time series-to-graph algorithm which takes the time series as parameter and returns a networkx undirected graph.
- ts2vg_basic(series)
Reference: "From time series to complex networks: The visibility graph" by L. Lacasa, B. Luque, F. Ballesteros, J. Luque, and J. C. Nuno
- ts2vg_fast(series)
Reference: "Fast transformation from time series to visibility graphs" by Xin Lan, Hongming Mo, Shiyu Chen, Qi Liu, and Yong Deng
- ts2hvg(series)
Reference: "Horizontal visibility graphs: exact results for random time series" by B. Luque , L. Lacasa, F. Ballesteros and J. Luque
Implementation of multiscale horizontal-visibility-graph correlation analysis (MHVGCA) that utilised horizontal visibility graph and degree sequence similarity to estimate the correlation between time series under specific time scale.
- mhvgca_method(series_a, series_b, timescale=20)
Reference: "Multiscale horizontal-visibility-graph correlation analysis of stock time series" by Weidong Li and Xiaojun Zhao
from pytalib.indicators.trend import SimpleMovingAverage
prices = [1,2,3,4,5,6,7,8,9,10]
sma = SimpleMovingAverage(prices=prices, period=3)
result = sma.calculate()
# reuse sma object
prices2 = [10,9,8,7,6,5,4,3,2,1]
sma.reset(prices=prices2, period=3)
result2 = sma.calculate()
import networkx as nx
from pytalib.graph import visibility_graph as vg
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('TkAgg')
prices = [1,3,2,4,5,6,9,8,9,10]
G = vg.ts2vg_fast(prices)
nx.draw_networkx(G, with_labels=True, font_weight='bold')
plt.title('visibility graph of prices')
plt.show()
import networkx as nx
from pytalib.graph import visibility_graph as vg
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('TkAgg')
prices = [1,3,2,4,5,6,9,8,9,10]
G = vg.ts2hvg(prices)
nx.draw_networkx(G, with_labels=True, font_weight='bold')
plt.title('horizontal visibility graph of prices')
plt.show()