Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated examples

  • Loading branch information...
commit 44d2c33a1d1369405ee10595e1cdac03fd0f7e42 1 parent 3013255
@oransel authored
View
62 Readme.md
@@ -4,15 +4,71 @@ A thin [node.js](http://nodejs.org) wrapper around [TA-LIB](http://ta-lib.org/),
## Installation
+To install the most recent release from npm, run:
+
npm install talib
+## Building
+
+The source code is available at [github](http://github.com/oransel/node-talib). You can either clone the repository or download a zip file of the latest release.
+
+Once you have the source, you can build the module by running
+
+ make all
+
+in the main directory. If everything goes well, the module will be available in the build/Release folder.
+
## Examples
-Coming soon...
+TALib is very simple to use.
+
+``` js
+// load the module and display its version
+var talib = require('./build/Release/talib');
+console.log("TALib Version: " + talib.version);
+
+// display all available indicator function names
+var functions = talib.functions;
+for (i in functions) {
+ console.log(functions[i].name);
+}
+
+// retreive Average Directional Movement Index indicator specifications
+var function_desc = talib.explain("ADX");
+console.log(function_desc.name);
+console.log(function_desc.group);
+console.log(function_desc.hint);
+console.log(function_desc.inputs);
+console.log(function_desc.optInputs);
+console.log(function_desc.outputs);
+```
+
+Assuming the market data is readily available, you can calculate an indicator by calling the `execute` function with the name of the indicator and required input parameters.
+
+``` js
+// market data as arrays
+var marketdata = { open: [...], close: [...], high: [...], low: [...], volume: [...] };
+
+// execute Average Directional Movement Index indicator function with time period 9
+talib.execute({
+ name: "ADX",
+ startIdx: 0,
+ endIdx: marketData.close.length - 1,
+ high: marketData.high,
+ low: marketData.low,
+ close: marketData.close,
+ optInTimePeriod: 9
+}, function (result) {
+
+ console.log("ADX Function Results:");
+ console.log(result);
+
+});
+```
-## Roadmap
+For working examples look in the `examples/` directory. You can execute the examples using node.
-* Add async processing
+ node examples/adx.js
## License
View
9 examples/adx.js
@@ -1,12 +1,15 @@
var talib = require("../build/Release/talib");
var fs = require("fs");
+// Display module version
console.log();
console.log("TALib Version: " + talib.version);
+// Load market data
var marketContents = fs.readFileSync('examples/marketdata.json','utf8');
var marketData = JSON.parse(marketContents);
+// execute ADX indicator function with time period 9
talib.execute({
name: "ADX",
startIdx: 0,
@@ -16,8 +19,10 @@ talib.execute({
close: marketData.close,
optInTimePeriod: 9
}, function (result) {
- console.log();
- console.log("ADX Function:");
+
+ // Show the result array
+ console.log("ADX Function Results:");
console.log(result);
+
});
View
2  examples/adx_explain.js
@@ -1,9 +1,11 @@
var talib = require("../build/Release/talib");
var functions = talib.functions;
+// Display module version
console.log();
console.log("TALib Version: " + talib.version);
+// Display ADX indicator function specifications
console.log(talib.explain("ADX"));
View
3  examples/functions.js
@@ -1,11 +1,14 @@
var talib = require("../build/Release/talib");
var functions = talib.functions;
+// Display module version
console.log();
console.log("TALib Version: " + talib.version);
+// Display all indicator functions
console.log(functions);
+// Display total indicator function count
console.log();
console.log("Total Functions: " + functions.length);
Please sign in to comment.
Something went wrong with that request. Please try again.