[英]Argument of type '{ period: any; prices: any; }' is not assignable to parameter of type 'MAInput'
I want to use technicalindicators
in my Angular app written in TypeScript, but don't know how to import and use it?我想在我用 TypeScript 编写的 Angular 应用程序中使用
technicalindicators
,但不知道如何导入和使用它?
What I want to do is calculating SMA(Simple Moving Averages) of an array.我想要做的是计算数组的 SMA(简单移动平均线)。
EDIT:编辑:
I have installed technicalindicators
module using npm i --save technicalindicators
command.我已经使用
npm i --save technicalindicators
命令安装了technicalindicators
模块。 Then I imported it like this:然后我像这样导入它:
import {sma} from 'technicalindicators';
Then I tried to use it like this:然后我尝试像这样使用它:
var prices = [1,2,3,4,5,6,7,8,9,10,12,13,15];
var period = 10;
doSMA(period , prices){
console.log('sma result is:' , sma({period, prices}));
}
But I get this error message:但我收到此错误消息:
Argument of type '{ period: any;
'{ period: any; 类型的参数prices: any;
价格:任意; }' is not assignable to parameter of type 'MAInput'
}' 不可分配给类型为 'MAInput' 的参数
Looks like you can use it no problem.. From the source, they have the TS interfaces already.看起来你可以使用它没问题..从源头上看,他们已经有了TS接口。
technicalindicators GitHub 技术指标 GitHub
You just need to npm install --save technicalindicators
你只需要
npm install --save technicalindicators
And to use it, you would import in your angular project the same as any other, have you tried it ?要使用它,您可以像其他任何项目一样导入您的 angular 项目,您尝试过吗?
for example :例如 :
import { StockData } from 'technicalindicators';
EDIT as per your error:根据您的错误编辑:
Following the documentation, the sma
method requires 3 params.根据文档,
sma
方法需要 3 个参数。
eg:例如:
sma({period : 10, values : [1,2,3,4,5,6,7,8,9], reversedInput : true});
From what I can see, it looks like you want to use a SMA.calcultate .据我所知,您似乎想使用 SMA.calculate 。
SMA.calculate({period : 10, values : [1,2,3,4,5,6,7,8,9]});
The error is quite clear though.虽然错误很明显。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.