简体   繁体   English

'{ period: any; 类型的参数价格:任意; }' 不可分配给类型为 'MAInput' 的参数

[英]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.虽然错误很明显。

TechnicalIndicators Documentation 技术指标文档

Here is a working example: DEMO这是一个工作示例: DEMO

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型“ any []”的参数不能分配给类型“ A”的参数。 类型“ any []”中缺少属性“ a” - Argument of type 'any[]' is not assignable to parameter of type 'A'. Property 'a' is missing in type 'any[]' &#39;{ [key: string]: any; 类型的参数 }&#39; 不可分配给“any[]”类型的参数 - Argument of type '{ [key: string]: any; }' is not assignable to parameter of type 'any[]' &#39;ReadableStream 类型的参数<any> &#39; 不可分配给类型为 &#39;ReadableStream&#39; 的参数 - Argument of type 'ReadableStream<any>' is not assignable to parameter of type 'ReadableStream' x 类型的参数不能分配给 '{ x: any; 类型的参数。 }' - Argument of type x is not assignable to parameter of type '{ x: any; }' typescript:类型&#39;any []&#39;的参数不能分配给&#39;[]&#39;类型的参数.ts(2345) - typescript : Argument of type 'any[]' is not assignable to parameter of type '[]'.ts(2345) '{验证器类型的参数:任何; }' 不可分配给“ValidatorFn”类型的参数 - Argument of type '{ validator: any; }' is not assignable to parameter of type 'ValidatorFn React Typescript:'{ [x: number]: any; 类型的参数 }' 不可分配给类型的参数 - React Typescript: Argument of type '{ [x: number]: any; }' is not assignable to parameter of type “string”类型的参数不能分配给类型为“{[key:string]:any;}的参数 - Argument of type 'string' is not assignable to parameter of type '{ [key:string]:any;} “事件”类型的参数不可分配给“CdkDragMove”类型的参数<any> &#39; - Argument of type 'Event' is not assignable to parameter of type 'CdkDragMove<any>' “any”类型的参数不可分配给“never”类型的参数 typescript 解决方案 - argument of type 'any' is not assignable to parameter of type 'never' typescript solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM