TA-Lib for quant trading

There are many libraries which quant need to use to generate trading signals. TA-Lib is a popular one which can calculate different technical indicators for us without implementing it by our-self.

Steps-by-steps

wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz

tar -xzf ta-lib-0.4.0-src.tar.gz

cd ta-lib/

sudo ./configure

sudo make

sudo make install

pip install ta-lib

#or pip3 install ta-lib

Sometimes you get memory error because your VM has low memory. You can fix it by adding a swap memory. This is an example on Ubuntu.

Check Swap Memory

sudo swapon -s

free -m

Check available Disk Space

df -h

Create Swap File (equal to your RAM)

sudo fallocate -l 4G /swapfile

ls -lh /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
free -m

Make Swap permanent after reboot

sudo nano /etc/fstab

Add to the bottom…
/swapfile none swap sw 0 0

If you get an error like below:
ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Leave a Reply

Your email address will not be published. Required fields are marked *