Skip to content

Commit

Permalink
docs: Explain update & getResult
Browse files Browse the repository at this point in the history
  • Loading branch information
bennycode committed Sep 5, 2021
1 parent 62ad238 commit f2a0e74
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Technical indicators and overlays to run technical analysis with JavaScript / Ty

## Motivation

Provide a TypeScript implementation for common technical indicators with arbitrary-precision decimal arithmetic.
The "trading-signals" library provides a TypeScript implementation for common technical indicators with arbitrary-precision decimal arithmetic. This library puts more emphasis on the correctness of the calculation than on performance.

## Features

Expand Down Expand Up @@ -66,9 +66,13 @@ console.log(sma.getResult().valueOf()); // "20"
console.log(sma.getResult().toFixed(2)); // "20.00"
```

## Good to know
### When to use `update(...)`?

This library draws attention to miscalculations by throwing errors instead of returning default values. If you call `getResult()`, before an indicator has received the required amount of input values, a `NotEnoughDataError` will be thrown.
You have to call an indicator's `update` method to enter input data. The update method may or may not return a result from the indicator depending on whether the minimum amount of input data has been reached.

### When to use `getResult()`?

You can call `getResult()` at any point in time, but it throws errors unless an indicator has received the minimum amount of data. If you call `getResult()`, before an indicator has received the required amount of input values, a `NotEnoughDataError` will be thrown.

**Example:**

Expand Down Expand Up @@ -96,6 +100,8 @@ sma.update(70);
console.log(sma.getResult().valueOf()); // "40"
```

Most of the time, the minimum amount of data depends on the interval / time period used.

## Disclaimer

The information and publications of [trading-signals](https://github.com/bennycode/trading-signals) do not constitute financial advice, investment advice, trading advice or any other form of advice. All results from [trading-signals](https://github.com/bennycode/trading-signals) are intended for information purposes only.
Expand Down

0 comments on commit f2a0e74

Please sign in to comment.