The parameter type '{ period: any; prices: any; }' does not match the 'MAInput' parameter type

Can someone help me with using the technicalindicators library in my Angular app? I'm working in TypeScript and need to know how to import and utilize it properly.

Specifically, I am trying to calculate Simple Moving Averages (SMA) of an array.

UPDATE:

After installing the technicalindicators module using the command npm i --save technicalindicators, I imported it as follows:

import {sma} from 'technicalindicators';

Then I attempted 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}));
  }

However, I encountered the following error message:

Argument of type '{ period: any; prices: any; }' is not assignable to parameter of type 'MAInput'

Answer №1

It appears that utilizing this tool should not be an issue.. The TS interfaces are readily available from the source.

Check out technicalindicators on GitHub

All you have to do is

npm install --save technicalindicators

To incorporate it into your angular project, simply import it like any other package. Have you given it a try?

For instance :

import { StockData } from 'technicalindicators';

Adjust based on your error:

Following the guidelines, the sma method requires 3 parameters.

eg:

sma({period : 10, values : [1,2,3,4,5,6,7,8,9], reversedInput : true});

It seems like you intend to use SMA.calcultate .

SMA.calculate({period : 10, values : [1,2,3,4,5,6,7,8,9]});

The error message is quite straightforward though.

Refer to TechnicalIndicators Documentation for more information

Here's an operational example: DEMO

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the world of TypeScript and JSON.stringify functions in JavaScript

In this simplified scenario: export class LoginComponent{ grant_type: string="password"; jsonPayload: string; Login(username, password){ this.jsonPayload = JSON.stringify({ username: username, password: password, grant_type: this.g ...

Transform an Array of Objects into a Multi-Dimensional Array using JavaScript

Just starting out with Java Script and I have an array of objects like this: [{ firstName: "John", lastName: "Doe", age: 46 }, { firstName: "Mike", lastName: "Jeffrey", age: 56 }] I want to transform this array of objects into a m ...

Looking for assistance with troubleshooting my isotope.js [code written in jquery and html]?

Explore this JSFiddle link I'm attempting to create sortable fancybox images, similar to the filtering functionality seen on this website. I previously achieved this with v1 of isotope but have been struggling with v2. After countless attempts and ad ...

Is there a way to "redirect" the user during the onbeforeunload event? If not, what is the alternative method to achieve this?

Can the browser be redirected to another page upon closing? Various Methods Tried: Attempted using onunload, but unsuccessful window.onunload = function redirect(){...} Another method tested, also unsuccessful: window.onbeforeunload = redirect(){ ...

Just starting out with React and encountering the error: Invalid element type, a string was expected

I seem to be going in circles with the following issue as I try to load the basics of a React app into the browser. An error message stating 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite c ...

Asynchronous jQuery operations using promises and finally functionality

I am attempting to interact with a REST api using jQuery's ajax feature. My goal is to return the Promise<Customer> object, but I am encountering an error stating that the property finally is missing. It used to work before, so I assume there h ...

Error: Unable to access properties of an undefined value while attempting to retrieve 'getProfile'

I am attempting to pull information from a local JSON file and display it in a table using Angular 12. However, for the initial step, I just want to log the data from the file to the console. Unfortunately, I encountered an error as described in the title. ...

Mongodb error occurred due to a duplicate key in the collection with the key value set

I need to set up multiple user accounts. The first account creation is successful, but I encounter an error when trying to create a new account: BulkWriteError: insertDocument :: caused by :: 11000 E11000 duplicate key error index: db.users.$friends. ...

The creation of an Outlook 365 add-in using Angular8 presents challenges when attempting to delete a cookie that was generated with ngx

I have developed an Office 365 add-in for Outlook. The add-in is built using Angular8 and I am utilizing ngx-cookie-service to store my authentication token information in a cookie. Despite being able to install the add-in, store the auth token in the co ...

a modified higher order component in React that promotes code reusability

I have created a simple higher-order component (HOC) that injects a React context as a prop in the wrapped component. function withTranslate(WrappedComponent) { //we forward the ref so it can be used by other return React.forwardRef((props, ref) => ...

What is the best way to transfer data from a clicked table row to another component?

I am currently working on developing an email inbox component for a system where the emails are displayed in a table format. When a user clicks on a specific row, it should lead to another component for further details. Since the information is not rende ...

Obtaining POST request parameters in an Express server

Below is the code snippet for adding a product using an angular service. The product is passed as the body. addProduct(product): Observable<any> { return this.http.post<Observable<any>>( `http://localhost:4401/api/products`, ...

Is the && operator being utilized as a conditional statement?

While following a tutorial, I came across this code snippet that uses the 'and' operator in an unusual way. Is this related to React? Can someone provide an explanation or share documentation that clarifies it? {basket?.length > 0 && ...

Is there a way to mock a keycloak API call for testing purposes during local development?

At my company, we utilize Keycloak for authentication integrated with LDAP to fetch a user object filled with corporate data. However, while working remotely from home, the need to authenticate on our corporate server every time I reload the app has become ...

The Angular Material dialog fails to display content when triggered within an event listener in Google Maps

Within my project, I am utilizing Angular 6.0.6 and Angular Material 6.3.0. One issue I have encountered is with a dialog component that I have added to the entryComponents in the app module. Strangely, when I attempt to open this dialog within the rightcl ...

The raycaster is experiencing issues when used with multiple cameras in the Three.js library

I am currently developing an application similar to the threeJs editor. In this project, I have implemented four different cameras, each with unique names and positions. Here is an example of one of the cameras: cameras['home'] = new THREE.Combi ...

What is the purpose of the "@" symbol when declaring an AngularJS controller in Coffeescript?

Currently, I am following a tutorial to familiarize myself with AngularJS alongside Rails 4. Interestingly, the author demonstrates how to create an Angular controller using the following syntax: @restauranteur.controller 'HomeCtrl', ['$sco ...

Using angular2 to perform an http.delete request on an in-memory-web-api

My project utilizes on-premise servers, with the backend running on .NET Core. Since I develop on a Mac and cannot run an instance of our backend, I have created a separate (angular-cli) environment for my project that uses the in-memory-web-api. Although ...

What are the steps for creating a unique plane geometry using three.js?

I am hoping to develop a three.js plane with a higher number of points than the default setup. This means I won't be using PlaneGeometry since it doesn't allow me to define custom points. My goal is to have the flexibility to animate or move any ...

What is the best way to transform JSON or an array from an AJAX responseText into a JavaScript array?

I recently implemented ajax into my code, and it is working perfectly. It provides me with either JSON or an array as the output. Here is the snippet of code I used: xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","http://map_ajax_control.php",false); xm ...