Skip to content

Latest commit

 

History

History
120 lines (87 loc) · 3.25 KB

Readme.md

File metadata and controls

120 lines (87 loc) · 3.25 KB

Build Status Build Status

Tulip Node

Tulip Node is the official node.js wrapper for Tulip Indicators. It provides 100+ technical analysis indicator functions, such as: simple moving average, Bollinger Bands, MACD, Parabolic SAR, Stochastic Oscillator, and many more.

Installation

Installation should just be:

npm install tulind

It should work on Windows, Os X, and Linux. Node versions 4, 5, 6, 7, 8, and 9 are tested and supported on each platform.

Note that pre-compiled binaries are available for Windows. For other platforms you will need a C++ build environment installed.

You can force building from source with:

npm install tulind --build-from-source

If you run into problems, let me know. I want this to be easy for everyone to use.

Usage

Tulip Node is very easy to use.

var tulind = require('tulind');
console.log("Tulip Indicators version is:");
console.log(tulind.version);

In these examples, we assume you already have price data loaded such as:

//Examples assume you have some price data like this:
//Data order is from oldest to newset (index 0 is the oldest)
var open  = [4,5,5,5,4,4,4,6,6,6];
var high  = [9,7,8,7,8,8,7,7,8,7];
var low   = [1,2,3,3,2,1,2,2,2,3];
var close = [4,5,6,6,6,5,5,5,6,4];
var volume = [123,232,212,232,111,232,212,321,232,321];

Calculating a simple moving average is as easy as:

//Do a simple moving average on close prices with period of 3.
tulind.indicators.sma.indicator([close], [3], function(err, results) {
  console.log("Result of sma is:");
  console.log(results[0]);
});

Example of calculating the Stochastic Oscillator:

//Functions that take multiple inputs, options, or outputs use arrays.
//Call Stochastic Oscillator, taking 3 inputs, 3 options, and 2 outputs.
tulind.indicators.stoch.indicator([high, low, close], [5, 3, 3], function(err, results) {
  console.log("Result of stochastic oscillator is:");
  console.log(results[0]);
  console.log(results[1]);
});

It's also easy to discover argument types at run-time:

//Discover argument types at run-time:
console.log(tulind.indicators.stoch);

//Produces:
{ name: 'stoch',
  full_name: 'Stochastic Oscillator',
  type: 'indicator',
  inputs: 3,
  options: 3,
  outputs: 2,
  input_names: [ 'high', 'low', 'close' ],
  option_names: [ '%k period', '%k slowing period', '%d period' ],
  output_names: [ 'stoch_k', 'stoch_d' ],
  indicator: [Function],
  start: [Function] }

Many (most) indicators return an output array length smaller than the input length. You can get the difference like this:

console.log("Given these options, the output arrays will be this much shorter than the input arrays:");
console.log(tulind.indicators.stoch.start([5,3,3]));

Hopefully it's obvious, but you can see all the available indicators by doing:

console.log(tulind.indicators);

You can also see a full list of the available indicators on the Tulip Indicators website here.