Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Update talib.js - fixed talib callback signature #924

Merged
merged 2 commits into from
Aug 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions core/talib.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
var talib = require("talib");
var semver = require("semver");
var _ = require('lodash');

var talibError = 'Gekko was unable to configure talib indicator:\n\t';
var talibGTEv103 = semver.gte(talib.version, '1.0.3');

// Wrapper that executes a talib indicator
var execute = function(callback, params) {
return talib.execute(
params,
function(result) {
if(result.error)
return callback(result.error);

callback(null, result.result);
}
);
// talib callback style since talib-v1.0.3
var talibCallback = function(err, result) {
if(err) return callback(err);
callback(null, result.result);
};

// talib legacy callback style before talib-v1.0.3
var talibLegacyCallback = function(result) {
var error = result.error;
talibCallback.apply(this, [error, result]);
};

return talib.execute(params, talibGTEv103 ? talibCallback : talibLegacyCallback);
}

// Helper that makes sure all required parameters
Expand Down