Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMA calculation seems incorrent #31

Closed
hungchai opened this issue Oct 11, 2015 · 1 comment
Closed

SMA calculation seems incorrent #31

hungchai opened this issue Oct 11, 2015 · 1 comment

Comments

@hungchai
Copy link

The output of SMA(10) is 135.5, and it is wrong.
But I used the same json data to find SMA10 by python talib module , the output is 135.91 and it is correct.

Here is my test script

var talib = require('talib');
var util = require('util');
console.log("TALib Version: " + talib.version);
// var request = require('request');


var marketData = {
"c": [
    130.7,
    131.0,
    127.3,
    129.3,
    135.5,
    139.7,
    139.6,
    142.0,
    142.1,
    141.9
]
};
talib.execute({
    name: "SMA",
    startIdx: 0,
    endIdx: marketData.c.length-1,
    inReal:marketData.c,
    optInTimePeriod: 10
}, function (result) {
    var outreal = result.result.outReal;
    console.log("SMA(10) Function Results:");
    console.dir(outreal.pop());

});

output is

TALib Version: 1.0.0
SMA(10) Function Results:
135.5
@oransel
Copy link
Owner

oransel commented Oct 12, 2015

Please test with the latest published version. Here is the output of your test script with the latest version

1.0.2
SMA(10) Function Results:
135.91

@oransel oransel closed this as completed Oct 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants