- What is Tulip Indicators?
- Why the name?
- Why another technical analysis indicator library?
- Why ANSI C?
- Is TI production ready?
- Is TI fast?
- Is TI multi-threaded?
- What about memory management?
- Can I use floats instead of doubles?
- Can I use TI from Excel?
- Are TI bindings available for Java, Python, Ruby, etc?
What is Tulip Indicators?
Tulip Indicators (TI) is a programming library that does the math behind technical analysis for stocks and commodities.
For example, if you have some stock data such as:
Tulip Indicators can do the math to calculate fancy indicators such as:
Note that Tulip Indicators doesn't actually generate the graphics. TI only does the math and generates the numerical values. (The graphics above were made with Tulip Charts, TI's sister project.)
Why the name?
It's named after Tulip Charts. The "Tulip" in Tulip Charts is a reference to Tulip Mania, during which tulip bulb prices reached extraordinary highs in 1637 before quickly collapsing. It's widely considered to be the first major speculation bubble, although newer evidence suggests that it may not have happened as many think.
Why another technical analysis indicator library?
I was working on a number of finance projects, and the existing indicator libraries weren't good enough. In almost every case, other indicator libraries lacked good documentation, they used slow algorithms, and in some cases they had correctness bugs. Many of the alternatives aren't actively developed anymore, so they will likely never improve. Another primary motivation for a clean start was the chance to implement a decent library interface. The alternative libraries do a poor job of this, in my opinion.
Why ANSI C?
ANSI C was chosen to make the library small, fast, and portable. Also, C is very easy to bind to, making bindings for other languages easy as well. In the programming world, C is the least common denominator.
Is TI production ready?
Yes. Tulip Indicators is absolutely ready for real world use, it is used in several high-profile systems, and it is relied on by thousands of traders everyday.
TI is tested in many ways before each new release.
TI includes a large unit test suite. Test data in this suite is taken from books, other sites, and calculated by hand. The test data is aquired from primary sources when possible. This data is compared to TI on every build to check for errors.
TI includes a regression test suite as well. This suite checks that indicator output remains consistent with library updates.
TI includes a fuzzer. This tool checks TI with unusual inputs to make sure that it returns the proper error codes instead of crashing or accessing invalid memory locations.
- TI is also thoroughly tested against TA-Lib for the functions that they share in common. This testing is done by a small utility program called "benchmark" included with TI. This program benchmarks TI's performance against TA-Lib, and it also checks that both libraries generate the same outputs.
Do keep in mind that some functions names or formulas may change slightly before version 1.0 is released, however I won't break your code without good reason. Theses changes will be well documented if they happen.
Is TI fast?
Oh yes. TI is the fastest indicator library I know of. TI achieves its speed not by micro-optimizations, but by using good algorithms. Wherever possible, TI won't make two passes through the data if one will suffice.
Is TI multi-threaded?
No, but TI is fully thread-safe. TI retains no mutable global state. I've found it's best to utilize multiple-cores at the highest level of abstraction, so the threading should generally be done a couple layers of abstraction above TI for the maximum speed gain.
For example, a common use-case it to run an indicator on a thousand stocks. That is the obvious place to parallelize, with one stock running on each core.
What about memory management?
Most TI functions do no runtime memory allocation. A couple functions
allocate temporary buffers using
malloc. These buffers are freed before
the function returns.
Importantly, all outputs from TI functions go into buffers allocated and managed by the caller.
Can I use floats instead of doubles?
Sure. Open "indicators.h" and modify the line
#define TI_REAL double
#define TI_REAL float
Fair warning: make sure to thoroughly test it for your application. Floats don't have a lot of precision, and you may find errors depending on your inputs. This is especially true for indicators with long periods. TI hasn't been tested with floats.
Can I use TI from Excel?
Yes! Tulip Cell is a high quality Excel add-in based on Tulip Indicators. Needless to say, it's also free. In fact, it's the only Excel technical analysis add-in I know of that's free and open-source.
Are TI bindings available for C#, Node.js, Go, Java, Python, Ruby, etc?
You can see the available bindings here.
I have played with making some bindings for other languages, but I haven't cleaned things up enough to publish. If you really need a binding, let me know and I'll see what I can do. If you're doing a commercial project, I'm available for consulting.