### Build and install TA-Lib from Git Source: https://github.com/ta-lib/ta-lib-python/wiki/Installation-Directions Build and install TA-Lib from the Git repository. Clone the repository, change into the directory, and run the setup script with sudo if necessary. ```bash git clone git://github.com/mrjbq7/ta-lib.git cd ta-lib $ [sudo] python setup.py install ``` -------------------------------- ### Install TA-Lib from source with setup.py Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install TA-Lib by checking out the sources and running setup.py. ```shell python setup.py install ``` -------------------------------- ### Install TA-Lib from PyPI Source: https://github.com/ta-lib/ta-lib-python/wiki/Installation-Directions Install TA-Lib from PyPI on Debian-based systems. First install build dependencies, then use easy_install to install numpy, Cython, and TA-Lib. ```bash #For debian apt-get install build-essential python-pip python-dev python-stsci.distutils $ easy_install numpy $ easy_install Cython $ easy_install TA-Lib ``` -------------------------------- ### Install TA-Lib from PyPI Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install the TA-Lib Python package from PyPI using pip. ```shell python -m pip install TA-Lib ``` -------------------------------- ### Build and install TA-Lib C library from source on Linux Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Download and build the TA-Lib C library from source on Linux, including configure, make, and install. ```shell tar -xzf ta-lib-0.8.1-src.tar.gz cd ta-lib-0.8.1/ ./configure --prefix=/usr make sudo make install ``` -------------------------------- ### TA-Lib Build Error Example Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/install.md Example build error indicating that the underlying TA-Lib library cannot be found. ```text func.c:256:28: fatal error: ta-lib/ta_libc.h: No such file or directory compilation terminated. ``` -------------------------------- ### Import TA-Lib and create sample data Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Sets up a NumPy array of random close prices for use with the TA-Lib Function API examples. ```python import numpy as np import talib close = np.random.random(100) ``` -------------------------------- ### Install TA-Lib C library with Homebrew Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install the underlying TA-Lib C library on macOS using Homebrew. ```shell brew install ta-lib ``` -------------------------------- ### Install TA-Lib with pip for Apple Silicon Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install TA-Lib with pip using a Python built for arm64, with --no-cache-dir to avoid cached issues. ```shell your-arm64-python -m pip install --no-cache-dir ta-lib ``` -------------------------------- ### Import numpy and talib and generate random close prices Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func.md Sets up the environment by importing numpy and talib, then generates a random array of 100 close prices. This is the prerequisite for all subsequent examples. ```python import numpy import talib close = numpy.random.random(100) ``` -------------------------------- ### Warning when TA-Lib library not found Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Example warning message shown when setup.py cannot find the TA-Lib library. ```shell setup.py:79: UserWarning: Cannot find ta-lib library, installation may fail. warnings.warn('Cannot find ta-lib library, installation may fail.') ``` -------------------------------- ### Set custom TA_LIBRARY_PATH and TA_INCLUDE_PATH Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Set environment variables to specify custom search paths for the TA-Lib library and headers, then install. ```shell export TA_LIBRARY_PATH=$PREFIX/lib export TA_INCLUDE_PATH=$PREFIX/include python setup.py install # or pip install ta-lib ``` -------------------------------- ### TA-Lib manual build note Source: https://github.com/ta-lib/ta-lib-python/wiki/Installation-Directions Notes that building TA-Lib manually with make -jX may fail, but rerunning the command and then running make install will succeed. ```text If you build ``TA-Lib`` manually using ``make -jX``, the build will fail but it's OK! Simply rerun ``make -jX`` followed by ``[sudo] make install`` and it will work as expected. ``` -------------------------------- ### Missing pyconfig.h error Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md This error means Python headers are missing. Install them with the provided apt command. ```shell talib/common.c:8:22: fatal error: pyconfig.h: No such file or directory #include "pyconfig.h" ^ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ``` ```shell sudo apt-get install python3-dev ``` -------------------------------- ### Install TA-Lib via Conda Forge Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install TA-Lib using Conda from the conda-forge channel. ```shell conda install -c conda-forge ta-lib ``` -------------------------------- ### Permission denied error for ta_defs.h Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md This error indicates the user lacks access to the TA-Lib C library installation. Grant access or install to a user-accessible location. ```shell talib/_ta_lib.c:747:28: fatal error: /usr/include/ta-lib/ta_defs.h: Permission denied #include "ta-lib/ta-defs.h" ^ compilation terminated error: command 'gcc' failed with exit status 1 ``` -------------------------------- ### Install TA-Lib C library for Apple Silicon Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install the TA-Lib C library on Apple Silicon (M1) using arch -arm64 to ensure the correct architecture. ```shell arch -arm64 brew install ta-lib ``` -------------------------------- ### Install libta-lib C library via Conda Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Install the underlying TA-Lib C library using the libta-lib package from conda-forge. ```shell $ conda install -c conda-forge libta-lib ``` -------------------------------- ### Human-readable function info Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/abstract.md Use help() or str() to get a human-readable representation of a Function. ```python help(STOCH) str(STOCH) ``` -------------------------------- ### TA-Lib NaN propagation example Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Shows how TA-Lib propagates NaN values to the end of the output, unlike Pandas rolling mean. ```python >>> c = np.array([1.0, 2.0, 3.0, np.nan, 4.0, 5.0, 6.0]) >>> talib.SMA(c, 3) array([nan, nan, 2., nan, nan, nan, nan]) ``` -------------------------------- ### Missing ta_defs.h header error Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md This error indicates the underlying TA-Lib C library is not installed or not found. On Windows, it may be due to a 32-bit/64-bit mismatch. ```shell talib/_ta_lib.c:601:10: fatal error: ta-lib/ta_defs.h: No such file or directory 601 | #include "ta-lib/ta_defs.h" | ^~~~~~~~~~~~~~~~~~ compilation terminated. ``` -------------------------------- ### Create swapfile to fix build hang Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md If the build hangs, possibly due to low memory in a VM, create a swapfile with these commands. ```shell sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile ``` -------------------------------- ### Call abstract functions with price overrides Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/index.md Demonstrates calling abstract functions with the same signature as the function API. Shows default price handling and how to override with the 'price' or 'prices' argument. ```python from talib.abstract import * output = SMA(input_arrays, timeperiod=25) # calculate on close prices by default output = SMA(input_arrays, timeperiod=25, price='open') # calculate on opens upper, middle, lower = BBANDS(input_arrays, 20, 2, 2) slowk, slowd = STOCH(input_arrays, 5, 3, 0, 3, 0) # uses high, low, close by default slowk, slowd = STOCH(input_arrays, 5, 3, 0, 3, 0, prices=['high', 'low', 'open']) ``` -------------------------------- ### Handle insufficient history with talib.InsufficientHistory Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Shows how to handle insufficient history when opening a streaming handle: compute the required lookback plus one and catch talib.InsufficientHistory. ```python from talib import abstract need = abstract.Function('RSI', timeperiod=14).lookback + 1 # 15, usually enough try: s = stream.RSI(history, timeperiod=14) except talib.InsufficientHistory: ... # collect more bars ``` -------------------------------- ### PPO - Percentage Price Oscillator Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Percentage Price Oscillator. ```python real = PPO(close, fastperiod=12, slowperiod=26, matype=1) ``` -------------------------------- ### List all TA-Lib functions and groups in Python Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Use talib.get_functions() to print every function name, and talib.get_function_groups() to print each group with its member functions. The output is a list of names and a dict of group names to lists of function names. ```python import talib # list of functions for name in talib.get_functions(): print(name) # dict of functions by group for group, names in talib.get_function_groups().items(): print(group) for name in names: print(f" {name}") ``` -------------------------------- ### ARM64 configure and config.guess fix Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md For ARM64 builds, configure with an explicit build type or update config.guess, then re-run configure. ```shell ./configure --build=aarch64-unknown-linux-gnu ``` ```shell cp /usr/share/automake-1.16/config.guess /path/to/extracted/ta-lib/config.guess ``` ```shell ./configure ``` -------------------------------- ### Set parameters and run with new input data Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/abstract.md Functions maintain state and remember parameters/input_arrays. Use run() to recalculate with new input data, or set input_arrays and change parameters. ```python SMA.parameters = {'timeperiod': 15} result1 = SMA.run(input_arrays1) result2 = SMA.run(input_arrays2) # Or set input_arrays and change the parameters: SMA.input_arrays = input_arrays1 ma10 = SMA(timeperiod=10) ma20 = SMA(20) ``` -------------------------------- ### 32-bit compile error with bits/libc-header-start.h Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md This error suggests a 32-bit compilation without the appropriate headers. See the linked StackOverflow question for help. ```shell /usr/include/limits.h:26:10: fatal error: bits/libc-header-start.h: No such file or directory #include ^~~~~~~~~~~~~~~~~~~~~~~~~~ ``` -------------------------------- ### PPO - Percentage Price Oscillator Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Percentage Price Oscillator. ```APIDOC ## PPO - Percentage Price Oscillator ### Description Computes the Percentage Price Oscillator. ### Function Signature ```python real = PPO(close, fastperiod=12, slowperiod=26, matype=1) ``` ### Parameters - **close** (array) - Required - Close prices. - **fastperiod** (int) - Optional - Fast period (default: 12). - **slowperiod** (int) - Optional - Slow period (default: 26). - **matype** (int) - Optional - Moving average type (default: 1). ### Returns - **real** (array) - The PPO values. ``` -------------------------------- ### Set TA_INCLUDE_PATH and TA_LIBRARY_PATH for Homebrew Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Set environment variables to help pip find the TA-Lib library and headers when using Homebrew. ```shell export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include" export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib" ``` -------------------------------- ### Inspect out_range and advance a streaming handle Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Shows how to inspect the output range of a handle and how to advance past a skipped bar without changing the value. ```python s.out_range # (begidx, nbelement), as the Function API's output s.advance() # count a skipped bar: the range moves, the value holds ``` -------------------------------- ### Import or instantiate a Function by name Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/abstract.md Functions can be imported directly or instantiated by name using abstract.Function. ```python from talib import abstract sma = abstract.SMA sma = abstract.Function('sma') ``` -------------------------------- ### Open and fill history with stream.RSI.open_and_fill Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Opens a streaming handle and fills it with the history in one pass, returning both the handle and the series over the history. ```python s, rsi = stream.RSI.open_and_fill(history, timeperiod=14) # rsi == talib.RSI(history) ``` -------------------------------- ### Import or instantiate TA-Lib function Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Import a TA-Lib function directly or instantiate it by name using abstract.Function. ```python from talib import abstract # directly SMA = abstract.SMA # or by name SMA = abstract.Function('sma') ``` -------------------------------- ### HT_PHASOR(close) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/cycle_indicators.md Computes the Hilbert Transform - Phasor Components for the given price data. ```APIDOC ## HT_PHASOR(close) ### Description Computes the Hilbert Transform - Phasor Components for the given price data. ### Function Signature ```python inphase, quadrature = HT_PHASOR(close) ``` ### Parameters - **close** (array-like) - Input price data (typically close prices). ### Returns - **inphase** (array) - In-phase component. - **quadrature** (array) - Quadrature component. ### Notes - This function has an unstable period. ``` -------------------------------- ### Multi-output streaming with stream.MACD Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Demonstrates multi-output streaming with stream.MACD: update returns a tuple, and the handle's value is a tuple-like object indexed by output position. ```python m = stream.MACD(close) macd, macdsignal, macdhist = m.update(price) m.value[2] # the histogram, last bar abstract.Function('MACD').output_names # ['macd', 'macdsignal', 'macdhist'] ``` -------------------------------- ### TYPPRICE - Typical Price Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/price_transform.md Computes the typical price from high, low, and close arrays. Returns a single output array. ```python real = TYPPRICE(high, low, close) ``` -------------------------------- ### MACDFIX - Moving Average Convergence/Divergence Fix 12/26 Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes MACD with fixed 12/26 periods. ```python macd, macdsignal, macdhist = MACDFIX(close, signalperiod=9) ``` -------------------------------- ### MFI - Money Flow Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Money Flow Index. ```python real = MFI(high, low, close, volume, timeperiod=14) ``` -------------------------------- ### Streaming API basic usage with stream.SMA Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Shows the basic usage of the Streaming API: create a handle with stream.SMA, compare its value to the Function API's last output, update it bar by bar, peek at a forming bar, and copy the handle. ```python import talib from talib import stream # the Function API: the whole series, from the whole array output = talib.SMA(close) # the Streaming API: a handle, positioned at the end of the history s = stream.SMA(close) assert s.value == output[-1] for price in feed: latest = s.update(price) # one closed bar in, its value out s.peek(forming) # what update would return, committing nothing fork = s.copy() # an independent handle at the same bar ``` -------------------------------- ### QSTICK - Qstick Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Qstick indicator. ```python real = QSTICK(open, close, timeperiod=10) ``` -------------------------------- ### ROCP - Rate of change Percentage: (price-prevPrice)/prevPrice Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Rate of Change Percentage. ```python real = ROCP(close, timeperiod=10) ``` -------------------------------- ### TYPPRICE Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/price_transform.md Calculates the typical price from high, low, and close prices. ```APIDOC ## TYPPRICE ### Description Calculates the typical price from the high, low, and close prices. ### Function Signature ```python real = TYPPRICE(high, low, close) ``` ### Parameters - **high** (array-like) - Required - High prices. - **low** (array-like) - Required - Low prices. - **close** (array-like) - Required - Close prices. ### Returns - **real** (array-like) - The typical price values. ``` -------------------------------- ### STOCHRSI vs STOCH applied to RSI Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Shows the difference between STOCHRSI and STOCH applied to RSI. STOCHRSI is STOCHF applied to RSI, not STOCH. ```python >>> import talib >>> import numpy as np >>> c = np.random.randn(100) # this is the library function >>> k, d = talib.STOCHRSI(c) # this produces the same result, calling STOCHF >>> rsi = talib.RSI(c) >>> k, d = talib.STOCHF(rsi, rsi, rsi) # you might want this instead, calling STOCH >>> rsi = talib.RSI(c) >>> k, d = talib.STOCH(rsi, rsi, rsi) ``` -------------------------------- ### AVGPRICE Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/price_transform.md Calculates the average price from the open, high, low, and close prices. ```APIDOC ## AVGPRICE ### Description Calculates the average price from the open, high, low, and close prices. ### Function Signature ```python real = AVGPRICE(open, high, low, close) ``` ### Parameters - **open** (array-like) - Required - Open prices. - **high** (array-like) - Required - High prices. - **low** (array-like) - Required - Low prices. - **close** (array-like) - Required - Close prices. ### Returns - **real** (array-like) - The average price values. ``` -------------------------------- ### Create OHLCV input dictionary Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Create a dictionary of numpy arrays for OHLCV data to pass to Abstract API functions. All arrays must be the same length. ```python import numpy as np # note that all ndarrays must be the same length! inputs = { 'open': np.random.random(100), 'high': np.random.random(100), 'low': np.random.random(100), 'close': np.random.random(100), 'volume': np.random.random(100) } ``` -------------------------------- ### Call Abstract API functions Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Call Abstract API functions with the same parameters as the function API. Specify the price field with the 'price' argument or a list of prices with 'prices' for multi-input functions. ```python from talib.abstract import * # uses close prices (default) output = SMA(inputs, timeperiod=25) # uses open prices output = SMA(inputs, timeperiod=25, price='open') # uses close prices (default) upper, middle, lower = BBANDS(inputs, 20, 2.0, 2.0) # uses high, low, close (default) slowk, slowd = STOCH(inputs, 5, 3, 0, 3, 0) # uses high, low, close by default # uses high, low, open instead slowk, slowd = STOCH(inputs, 5, 3, 0, 3, 0, prices=['high', 'low', 'open']) ``` -------------------------------- ### PyInstaller hidden import for talib.stream Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Use this command to fix PyInstaller packaging issues by explicitly including the talib.stream module as a hidden import. ```shell pyinstaller --hidden-import talib.stream "replaceToYourFileName.py" ``` -------------------------------- ### HT_SINE(close) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/cycle_indicators.md Computes the Hilbert Transform - SineWave for the given price data. ```APIDOC ## HT_SINE(close) ### Description Computes the Hilbert Transform - SineWave for the given price data. ### Function Signature ```python sine, leadsine = HT_SINE(close) ``` ### Parameters - **close** (array-like) - Input price data (typically close prices). ### Returns - **sine** (array) - Sine wave values. - **leadsine** (array) - Lead sine wave values. ### Notes - This function has an unstable period. ``` -------------------------------- ### MACDFIX - Moving Average Convergence/Divergence Fix 12/26 Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes MACD with fixed 12/26 periods. ```APIDOC ## MACDFIX - Moving Average Convergence/Divergence Fix 12/26 ### Description Computes MACD with fixed 12/26 periods. ### Function Signature ```python macd, macdsignal, macdhist = MACDFIX(close, signalperiod=9) ``` ### Parameters - **close** (array) - Required - Close prices. - **signalperiod** (int) - Optional - Signal period (default: 9). ### Returns - **macd** (array) - MACD line values. - **macdsignal** (array) - Signal line values. - **macdhist** (array) - Histogram values. ``` -------------------------------- ### STOCHF - Stochastic Fast Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Fast Stochastic oscillator, returning fastk and fastd. ```python fastk, fastd = STOCHF(high, low, close, fastk_period=5, fastd_period=3, fastd_matype=0) ``` -------------------------------- ### BOP - Balance Of Power Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Balance of Power indicator. ```python real = BOP(open, high, low, close) ``` -------------------------------- ### List supported indicators and function groups Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/index.md Lists all supported TA functions and groups them by category. ```python import talib print talib.get_functions() print talib.get_function_groups() ``` -------------------------------- ### STOCHF - Stochastic Fast Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Fast Stochastic oscillator. ```APIDOC ## STOCHF - Stochastic Fast ### Description Computes the Fast Stochastic oscillator. ### Function Signature ```python fastk, fastd = STOCHF(high, low, close, fastk_period=5, fastd_period=3, fastd_matype=0) ``` ### Parameters - **high** (array) - Required - High prices. - **low** (array) - Required - Low prices. - **close** (array) - Required - Close prices. - **fastk_period** (int) - Optional - Fast K period (default: 5). - **fastd_period** (int) - Optional - Fast D period (default: 3). - **fastd_matype** (int) - Optional - Fast D MA type (default: 0). ### Returns - **fastk** (array) - Fast K values. - **fastd** (array) - Fast D values. ``` -------------------------------- ### BETA Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/statistic_functions.md Calculates the Beta of the high and low price series over a specified time period. ```APIDOC ## BETA ### Description Calculates the Beta of the high and low price series over a specified time period. ### Method Function Call ### Endpoint BETA(high, low, timeperiod=5) ### Parameters - **high** (array) - Required - High price series. - **low** (array) - Required - Low price series. - **timeperiod** (integer) - Optional - Time period for calculation. Default is 5. ### Returns - **real** (array) - The Beta values. ``` -------------------------------- ### BETA - Beta Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/statistic_functions.md Computes the Beta of two price series (high and low) over a period of 5. Returns a single real value. ```python real = BETA(high, low, timeperiod=5) ``` -------------------------------- ### make error with libtool and spaces in path Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md This error may occur when the path to the TA-Lib library contains spaces. Move it to a path without spaces. ```shell ../libtool: line 1717: cd: .libs/libta_lib.lax/libta_abstract.a: No such file or directory make[2]: *** [libta_lib.la] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all-recursive] Error 1 ``` -------------------------------- ### MFI - Money Flow Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Money Flow Index. ```APIDOC ## MFI - Money Flow Index ### Description Computes the Money Flow Index. ### Function Signature ```python real = MFI(high, low, close, volume, timeperiod=14) ``` ### Parameters - **high** (array) - Required - High prices. - **low** (array) - Required - Low prices. - **close** (array) - Required - Close prices. - **volume** (array) - Required - Volume. - **timeperiod** (int) - Optional - Time period (default: 14). ### Returns - **real** (array) - The MFI values. ``` -------------------------------- ### AVGPRICE - Average Price Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/price_transform.md Computes the average price from open, high, low, and close arrays. Returns a single output array. ```python real = AVGPRICE(open, high, low, close) ``` -------------------------------- ### QSTICK - Qstick Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Qstick indicator. ```APIDOC ## QSTICK - Qstick ### Description Computes the Qstick indicator. ### Function Signature ```python real = QSTICK(open, close, timeperiod=10) ``` ### Parameters - **open** (array) - Required - Open prices. - **close** (array) - Required - Close prices. - **timeperiod** (int) - Optional - Time period (default: 10). ### Returns - **real** (array) - The QSTICK values. ``` -------------------------------- ### WCLPRICE - Weighted Close Price Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/price_transform.md Computes the weighted close price from high, low, and close arrays. Returns a single output array. ```python real = WCLPRICE(high, low, close) ``` -------------------------------- ### ZLEMA - Zero-Lag Exponential Moving Average Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Zero-Lag Exponential Moving Average. ```python real = ZLEMA(close, timeperiod=30) ``` -------------------------------- ### IMI - Intraday Momentum Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Intraday Momentum Index. ```python real = IMI(open, close, timeperiod=14) ``` -------------------------------- ### ROCP - Rate of change Percentage: (price-prevPrice)/prevPrice Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Rate of Change Percentage. ```APIDOC ## ROCP - Rate of change Percentage: (price-prevPrice)/prevPrice ### Description Computes the Rate of Change Percentage. ### Function Signature ```python real = ROCP(close, timeperiod=10) ``` ### Parameters - **close** (array) - Required - Close prices. - **timeperiod** (int) - Optional - Time period (default: 10). ### Returns - **real** (array) - The ROCP values. ``` -------------------------------- ### CMOU - Chande Momentum Oscillator (Unsmoothed) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the unsmoothed Chande Momentum Oscillator. ```python real = CMOU(close, timeperiod=14) ``` -------------------------------- ### WCLPRICE Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/price_transform.md Calculates the weighted close price from high, low, and close prices. ```APIDOC ## WCLPRICE ### Description Calculates the weighted close price from the high, low, and close prices. ### Function Signature ```python real = WCLPRICE(high, low, close) ``` ### Parameters - **high** (array-like) - Required - High prices. - **low** (array-like) - Required - Low prices. - **close** (array-like) - Required - Close prices. ### Returns - **real** (array-like) - The weighted close price values. ``` -------------------------------- ### FOSC - Forecast Oscillator Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Forecast Oscillator. ```python real = FOSC(close, timeperiod=5) ``` -------------------------------- ### CORREL - Pearson's Correlation Coefficient Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/statistic_functions.md Computes Pearson's Correlation Coefficient (r) between high and low prices over a period of 30. Returns a single real value. ```python real = CORREL(high, low, timeperiod=30) ``` -------------------------------- ### STOCH - Stochastic Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Stochastic oscillator. ```APIDOC ## STOCH - Stochastic ### Description Computes the Stochastic oscillator. ### Function Signature ```python slowk, slowd = STOCH(high, low, close, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0) ``` ### Parameters - **high** (array) - Required - High prices. - **low** (array) - Required - Low prices. - **close** (array) - Required - Close prices. - **fastk_period** (int) - Optional - Fast K period (default: 5). - **slowk_period** (int) - Optional - Slow K period (default: 3). - **slowk_matype** (int) - Optional - Slow K MA type (default: 0). - **slowd_period** (int) - Optional - Slow D period (default: 3). - **slowd_matype** (int) - Optional - Slow D MA type (default: 0). ### Returns - **slowk** (array) - Slow K values. - **slowd** (array) - Slow D values. ``` -------------------------------- ### SMA - Simple Moving Average Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Simple Moving Average. ```python real = SMA(close, timeperiod=30) ``` -------------------------------- ### DPO - Detrended Price Oscillator Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Detrended Price Oscillator. ```python real = DPO(close, timeperiod=20) ``` -------------------------------- ### WAD - Williams' Accumulation/Distribution Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes Williams' Accumulation/Distribution (WAD) using high, low, and close prices. ```APIDOC ## WAD - Williams' Accumulation/Distribution ### Description Computes Williams' Accumulation/Distribution (WAD) using high, low, and close prices. ### Function Signature ```python real = WAD(high, low, close) ``` ### Parameters - **high** (array-like) - High price series. - **low** (array-like) - Low price series. - **close** (array-like) - Close price series. ### Returns - **real** (array-like) - The Williams' Accumulation/Distribution values. ``` -------------------------------- ### SMI - Stochastic Momentum Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Stochastic Momentum Index, returning smi and smisignal. ```python smi, smisignal = SMI(high, low, close, timeperiod=13, fastperiod=2, slowperiod=25, signalperiod=9) ``` -------------------------------- ### ROCR - Rate of change ratio: (price/prevPrice) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Rate of Change Ratio. ```python real = ROCR(close, timeperiod=10) ``` -------------------------------- ### SAREXT - Parabolic SAR - Extended Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Parabolic SAR - Extended. ```python real = SAREXT(high, low, startvalue=0, offsetonreverse=0, accelerationinitlong=0, accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0) ``` -------------------------------- ### ERI - Elder Ray Index (Bull Power / Bear Power) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Elder Ray Index, returning bullpower and bearpower. ```python bullpower, bearpower = ERI(high, low, close, timeperiod=13) ``` -------------------------------- ### Calculate momentum with time period of 5 Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func.md Calculates momentum of the close prices with a time period of 5. The output is an array with the initial lookback period set to NaN. ```python output = talib.MOM(close, timeperiod=5) ``` -------------------------------- ### Access function info via info property Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/abstract.md The info property returns a dictionary with details about the function, including input names, parameters, and output names. ```python print Function('stoch').info { 'name': 'STOCH', 'display_name': 'Stochastic', 'group': 'Momentum Indicators', 'input_names': OrderedDict([ ('prices', ['high', 'low', 'close']), ]), 'parameters': OrderedDict([ ('fastk_period', 5), ('slowk_period', 3), ('slowk_matype', 0), ('slowd_period', 3), ('slowd_matype', 0), ]), 'output_names': ['slowk', 'slowd'], } ``` -------------------------------- ### HT_DCPHASE(close) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/cycle_indicators.md Computes the Hilbert Transform - Dominant Cycle Phase for the given price data. ```APIDOC ## HT_DCPHASE(close) ### Description Computes the Hilbert Transform - Dominant Cycle Phase for the given price data. ### Function Signature ```python real = HT_DCPHASE(close) ``` ### Parameters - **close** (array-like) - Input price data (typically close prices). ### Returns - **real** (array) - Dominant Cycle Phase values. ### Notes - This function has an unstable period. ``` -------------------------------- ### ACCBANDS - Acceleration Bands Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Acceleration Bands. Returns upper, middle, and lower bands. ```python upperband, middleband, lowerband = ACCBANDS(high, low, close, timeperiod=20) ``` -------------------------------- ### CCI - Commodity Channel Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Commodity Channel Index. ```python real = CCI(high, low, close, timeperiod=14) ``` -------------------------------- ### TRIMA - Triangular Moving Average Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Triangular Moving Average. ```python real = TRIMA(close, timeperiod=30) ``` -------------------------------- ### PERCENTRANK - Percent Rank Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/statistic_functions.md Computes the Percent Rank of the close price over a period of 100. Returns a single real value. ```python real = PERCENTRANK(close, timeperiod=100) ``` -------------------------------- ### MIDPRICE - Midpoint Price over period Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Midpoint Price over period. ```python real = MIDPRICE(high, low, timeperiod=14) ``` -------------------------------- ### BBANDS Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Bollinger Bands over a given period. ```APIDOC ## BBANDS - Bollinger Bands ### Description Computes Bollinger Bands over a given period. ### Function Signature ```python upperband, middleband, lowerband = BBANDS(close, timeperiod=20, nbdevup=2, nbdevdn=2, matype=0) ``` ### Parameters - **close** (array) - Required - Close price series. - **timeperiod** (int) - Optional - Period for the bands (default: 20). - **nbdevup** (float) - Optional - Number of standard deviations for the upper band (default: 2). - **nbdevdn** (float) - Optional - Number of standard deviations for the lower band (default: 2). - **matype** (int) - Optional - Moving average type (default: 0). ### Returns - **upperband** (array) - Upper band values. - **middleband** (array) - Middle band values. - **lowerband** (array) - Lower band values. ``` -------------------------------- ### MACD - Moving Average Convergence/Divergence Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the MACD indicator, returning macd, macdsignal, and macdhist. ```python macd, macdsignal, macdhist = MACD(close, fastperiod=12, slowperiod=26, signalperiod=9) ``` -------------------------------- ### ZLEMA Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes the Zero-Lag Exponential Moving Average. ```APIDOC ## ZLEMA - Zero-Lag Exponential Moving Average ### Description Computes the Zero-Lag Exponential Moving Average. ### Function Signature ```python real = ZLEMA(close, timeperiod=30) ``` ### Parameters - **close** (array) - Required - Close price series. - **timeperiod** (int) - Optional - Period for the moving average (default: 30). ### Returns - **real** (array) - ZLEMA values. ``` -------------------------------- ### Calculate Bollinger Bands with triple exponential moving average Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func.md Calculates Bollinger Bands using the triple exponential moving average (T3) as the moving average type. The function returns upper, middle, and lower bands. Requires importing MA_Type from talib. ```python from talib import MA_Type upper, middle, lower = talib.BBANDS(close, matype=MA_Type.T3) ``` -------------------------------- ### WILLR - Williams' %R Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes Williams' %R (WILLR) using high, low, and close prices. ```APIDOC ## WILLR - Williams' %R ### Description Computes Williams' %R (WILLR) using high, low, and close prices. ### Function Signature ```python real = WILLR(high, low, close, timeperiod=14) ``` ### Parameters - **high** (array-like) - High price series. - **low** (array-like) - Low price series. - **close** (array-like) - Close price series. - **timeperiod** (int, optional) - Time period. Default is 14. ### Returns - **real** (array-like) - The Williams' %R values. ``` -------------------------------- ### PERCENTILE - Percentile (nearest rank) Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/statistic_functions.md Computes the Percentile (nearest rank) of the close price over a period of 30, using a percentile of 50. Returns a single real value. ```python real = PERCENTILE(close, timeperiod=30, percentile=50) ``` -------------------------------- ### APO - Absolute Price Oscillator Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Absolute Price Oscillator. ```python real = APO(close, fastperiod=12, slowperiod=26, matype=1) ``` -------------------------------- ### VAR Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/statistic_functions.md Calculates the Variance of the close price series over a specified time period. ```APIDOC ## VAR ### Description Calculates the Variance of the close price series over a specified time period. ### Method Function Call ### Endpoint VAR(close, timeperiod=5, nbdev=1) ### Parameters - **close** (array) - Required - Close price series. - **timeperiod** (integer) - Optional - Time period for calculation. Default is 5. - **nbdev** (float) - Optional - Number of standard deviations. Default is 1. ### Returns - **real** (array) - The variance values. ``` -------------------------------- ### ULTOSC - Ultimate Oscillator Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Ultimate Oscillator (ULTOSC) using high, low, and close prices. ```APIDOC ## ULTOSC - Ultimate Oscillator ### Description Computes the Ultimate Oscillator (ULTOSC) using high, low, and close prices. ### Function Signature ```python real = ULTOSC(high, low, close, timeperiod1=7, timeperiod2=14, timeperiod3=28) ``` ### Parameters - **high** (array-like) - High price series. - **low** (array-like) - Low price series. - **close** (array-like) - Close price series. - **timeperiod1** (int, optional) - First time period. Default is 7. - **timeperiod2** (int, optional) - Second time period. Default is 14. - **timeperiod3** (int, optional) - Third time period. Default is 28. ### Returns - **real** (array-like) - The Ultimate Oscillator values. ``` -------------------------------- ### BBANDS - Bollinger Bands Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Bollinger Bands. Returns upper, middle, and lower bands. ```python upperband, middleband, lowerband = BBANDS(close, timeperiod=20, nbdevup=2, nbdevdn=2, matype=0) ``` -------------------------------- ### Price Transform list Source: https://github.com/ta-lib/ta-lib-python/blob/master/README.md Text table of the Price Transform group, listing each function name and its description. ```text AVGPRICE Average Price MEDPRICE Median Price TYPPRICE Typical Price WCLPRICE Weighted Close Price ``` -------------------------------- ### MAVP - Moving average with variable period Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes Moving average with variable period. ```python real = MAVP(close, periods, minperiod=2, maxperiod=30, matype=0) ``` -------------------------------- ### IMI - Intraday Momentum Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Intraday Momentum Index. ```APIDOC ## IMI - Intraday Momentum Index ### Description Computes the Intraday Momentum Index. ### Function Signature ```python real = IMI(open, close, timeperiod=14) ``` ### Parameters - **open** (array) - Required - Open prices. - **close** (array) - Required - Close prices. - **timeperiod** (int) - Optional - Time period (default: 14). ### Returns - **real** (array) - The IMI values. ``` -------------------------------- ### Calculate simple moving average with talib.SMA Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func.md Calculates a simple moving average of the close prices using the function API. The output is an array with the same length as the input, with the initial lookback period set to NaN. ```python output = talib.SMA(close) ``` -------------------------------- ### STOCHRSI - Stochastic Relative Strength Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Stochastic RSI, returning fastk and fastd. ```python fastk, fastd = STOCHRSI(close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0) ``` -------------------------------- ### FRACTAL - Williams Fractal Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes Williams Fractal, returning swinghigh and swinglow. ```python swinghigh, swinglow = FRACTAL(high, low, leftbars=2, rightbars=2) ``` -------------------------------- ### MAMA - MESA Adaptive Moving Average Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/overlap_studies.md Computes MESA Adaptive Moving Average. Note: The MAMA function has an unstable period. ```python mama, fama = MAMA(close, fastlimit=0, slowlimit=0) ``` -------------------------------- ### MACDEXT - MACD with controllable MA type Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes MACD with controllable moving average types. ```python macd, macdsignal, macdhist = MACDEXT(close, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0) ``` -------------------------------- ### WAD - Williams' Accumulation/Distribution Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes Williams' Accumulation/Distribution (WAD) using high, low, and close prices. The function returns a single output array. ```python real = WAD(high, low, close) ``` -------------------------------- ### OBV - On Balance Volume Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/volume_indicators.md Computes the On Balance Volume, a cumulative volume indicator that adds volume on up days and subtracts on down days. ```APIDOC ## OBV - On Balance Volume ### Description Computes the On Balance Volume, a cumulative volume indicator that adds volume on up days and subtracts on down days. ### Function Signature ```python real = OBV(close, volume) ``` ### Parameters - **close** (array) - Close prices. - **volume** (array) - Volume values. ### Returns - **real** (array) - The On Balance Volume values. ``` -------------------------------- ### MOM - Momentum Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Momentum indicator. ```python real = MOM(close, timeperiod=10) ``` -------------------------------- ### DX - Directional Movement Index Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Directional Movement Index. Note: has an unstable period. ```python real = DX(high, low, close, timeperiod=14) ``` -------------------------------- ### BOP - Balance Of Power Source: https://github.com/ta-lib/ta-lib-python/blob/master/docs/func_groups/momentum_indicators.md Computes the Balance Of Power indicator. ```APIDOC ## BOP - Balance Of Power ### Description Computes the Balance Of Power indicator. ### Function Signature ```python real = BOP(open, high, low, close) ``` ### Parameters - **open** (array) - Required - Open prices. - **high** (array) - Required - High prices. - **low** (array) - Required - Low prices. - **close** (array) - Required - Close prices. ### Returns - **real** (array) - The BOP values. ```