Technical Analysis Library: Solving the Legacy Code Issue

  • December 23, 2019
  • 10 min
technical analysis library

Financial software is a kind of an old-school world of enterprise solutions that are evident only to its residents. Very often, solutions that work for Quant (financial data-analytics) may look very strange to an average software developer who likes seeing code structured according to software development industry standards. Why does that happen?

  1. Quants are not developers. So, if they write code - they do it differently.
  2. Why should one stop using a time-honored working tool?
  3. New software needs to integrate with old software. That affects the technology choice for this new software. As a result - new software is written with an old approach.
  4. When an economist hires a software developer - he rarely knows what is inside the product he makes.

As a result, very often essential decisions, infrastructure units, or even life-cycles of big businesses get dependent on software that an average developer will most call a "legacy code". 

We want to bring up one of the most recent and revealing cases of how we've solved the enterprise operational pain of a technical analysis pro guy by updating the old Technical Analysis Library library to work properly again.

TA-Lib: a technical analysis tool from before 2009

The Technical Analysis Library provides the implementation for approximately 200 technical indicators essential for financial data analysts. This library integrates with many fintech projects. Also, it has an excellent Excel plugin, which is often used by Quants to simplify their research.

Why and how did we migrate the TA-Lib + Excel plugin?

The wrong sides of the TA-Lib library for Windows Excel plugin users were:

  1. Although the code is almost perfect, it hasn't been updated for quite long. 
  2. The library (and the plugin) compiled for 32-bit processors limited by 4GB of memory. As a result, the data volume they can process is also limited.

Solving these two tasks with our help allowed the Quant to load more data and to process this data faster, allowing better analytics reports. 

A small project with a huge impact

Initially, it was a small project request to update the code to make it work faster. But this is not a requirement for the business consuming TA-Lib financial indicators.

Technically, to make TA-Lib great again, we took it through the following steps:

  1. Updating SDK paths to use 64-bit SDKs;
  2. Migrating compiler flags to use 64-bit compilation;
  3. Optionally, for better performance, removing debugger flags which were there by default;
  4. Merging calculus and interface parts of the project;
  5. Updating the XLW library (http://xlw.sourceforge.net/) to the latest version;
  6. Updating the Excel plugin code to use the new Excel wrapper. That includes changing some data types which were affected by re-factoring which happened within the XLW library;
  7. Updating macros definitions which export TA-Lib functions to make them available in Excel;
  8. Changing the way the library returns NaN values because the latest Excel shows them as tiny numbers. We have chosen to return empty strings instead of NaN values.
  9. Compiling and testing just because you will always find something after the migration. We have found the fix for NaN numbers during testing.

Technical analysis in the сloud

The best thing which TA-Lib can provide is having your 200 favorite technical analysis indicators in the cloud. You can easily integrate the tool into the Python computational environment like, for example, Jupyter Notebook or Google Colab. And, unlike for Windows, you can build the TA-Lib library easier for the *NIX environment. To install the library, you need to do the following:

!wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz 
!tar -xzvf ta-lib-0.4.0-src.tar.gz 
!cd ta-lib 
!./configure --prefix=/usr 
!make 
!make install 
!pip install Ta-Lib import talib

After that, you can run the following code to calculate the simple moving average (SMA) using TA-Lib:

from talib import SMA
import numpy as np
result = SMA(np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0]), 3)
print(result)
[nan nan 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.]

How to outsource FinTech efficiently?

technical analysis library

Quite often, some non-IT-coupled businesses may suffer from issues that can be easily solved by a software developer. On the other hand, such companies do not need to hire a full-time developer within their office. It is a perfect case to outsource to a professional team of experts. 

To choose a proper team for your needs, you should always pay attention to:

  1. Interviewing your partner to evaluate communication skills and how good the team understands your business goals.
  2. You agree with the working hours for meetings. The team's working day should intersect with your working day.
  3. You are doing a technical interview. You may ask your friend, who is an IT guy to interview if you are not ready to dive deep into the tech details yourself.
  4. It would help if you had a reliable way of making payments for the work accomplished.
  5. NDA agreement.
  6. You need to ensure that the team has real experts in your business domain.

If you feel like extending your existing team or would like to have a fintech project developed for you - drop us a line, and we'll arrange a quick call with our tech expert to get the ball rolling!

Author

Andrew Mikhailov
Chief Technology Officer

Table of contents

    Do you have an awesome business idea? Let’s make it real!

    Join our newsletter!

    Get weekly updates of the top IT news delivered straight to your inbox

    OFFER OF THE MONTH

    Magento website development. Empower your online store!

    WhatsApp