# alphacate

> Toolkit with various indicators and oscillators for the technical stock analysis

Latest version **0.4.0** (published 2020-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install alphacate
pnpm add alphacate
yarn add alphacate
bun add alphacate
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2020-03-30 |
| First published | 2019-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 3 |
| Unpacked size | 110.5 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Lukas B |
| Maintainers | atticus2k |
| Keywords | average-true-range, linearly-weighted-moving-average, moving-average-convergence-divergence, simple-moving-average, exponential-moving-average, stochastic-oscillator, bollinger-bands, on-balance-volume, relative-strength-index, weighted-moving-average, rate-of-change, money-flow-index, standard-deviation, fintech, financial-technology, stock, math, technical-analysis, finance, invest, trading, indicator, oscillator, algorithmic, nyse, quant |

## Links

- npm: https://www.npmjs.com/package/alphacate
- Repository: https://github.com/codeplayr/alphacate
- Homepage: https://github.com/codeplayr/alphacate#readme
- Issues: https://github.com/codeplayr/alphacate/issues
- npm.io page: https://npm.io/package/alphacate

## Dependencies (3)

- [underscore](https://npm.io/package/underscore.md) 1.8.x
- [convert-hrtime](https://npm.io/package/convert-hrtime.md) 3.x
- [bankers-rounding](https://npm.io/package/bankers-rounding.md) 0.x

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 0.4.0 (latest) — 2020-03-30
- 0.3.0 — 2019-10-20
- 0.2.0 — 2019-10-03
- 0.1.3 — 2019-09-13
- 0.1.1 — 2019-09-05
- 0.1.0 — 2019-09-05

## README

# Alphacate

---

A Node.js toolkit with various indicators and oscillators for the technical stock analysis. This package contains only the mathematical calculations.

## Installation

---

    $ npm install alphacate [--save]

## Example

---

```js      
//retrieve indicator module via accessor or alias
const LWMA = require('alphacate').LWMA;
const BB = require('alphacate').BollingerBands;

//do computation asynchronously
let run = async () => {
    try{
        //pass optional configuration object into the constructor
        let lwma = new LWMA( {periods: 4} );
        let bb = new BB( {periods: 4} );

        let data = [25.5, 26.75, 27.0, 26.5, 27.25];

        //set data series
        lwma.setValues( data );
        bb.setValues( data );

        //invoke calculate() to compute and retrieve result collection
        //an error will be throw if passed data serie or options are invalid
        let lwmaResultCollection = await lwma.calculate();
        let bbResultCollection = await bb.calculate();
        
        for(let i=0, len=lwmaCollection.length; i<len; i++){
            console.log(`Price: ${lwmaCollection[i].price}, LWMA: ${lwmaCollection[i].lwma}, BB Upper: ${bbCollection[i].upper}`);
        }

    }
    catch( err ){
        console.log(err.message);
    }
};

run();
```



### List of indicators

---

See the list below for all available indicators in the package. Retrieve the indicator module via the accessor property or with the alias.


Indicator                               |Module accessor               		|Alias              
----------------------------------------|-----------------------------------|-----------
Average True Range                      |AverageTrueRange                   |ATR                
Bollinger Bands                         |BollingerBands                     |BB                 
Exponential Moving Average              |ExponentialMovingAverage           |EMA                
Linearly Weighted Moving Average        |LinearlyWeightedMovingAverage      |LWMA               
Money Flow Index                        |MoneyFlowIndex                     |MFI
Moving Average Convergence Divergence   |MovingAverageConvergenceDivergence |MACD               
On Balance Volume                       |OnBalanceVolume                    |OBV                
Rate Of Change                          |RateOfChange                       |ROC
Relative Strength Index                 |RelativeStrengthIndex              |RSI                
Simple Moving Average                   |SimpleMovingAverage                |SMA   
Smoothed Moving Average                 |SmoothedMovingAverage              |SMMA             
Stochastic Oscillator                   |StochasticOscillator               |SO                 
Weighted Moving Average                 |WeightedMovingAverage              |WMA

### Data serie item

---

The type of the item in the data serie that will be passed into the `setValues` function

Indicator								|Type       |Usage
----------------------------------------|-----------|---------------------------------------
Average True Range                      |Number     |                             
Bollinger Bands                         |Number     |                             
Exponential Moving Average              |Number     |                             
Linearly Weighted Moving Average        |Number     | 
Money Flow Index                        |Object     |{high:\<Number\>, low:\<Number\>, close:\<Number\>, volume:\<Number\> };                            
Moving Average Convergence Divergence   |Number     |                             
On Balance Volume                       |Object     |{price:\<Number\>, volume:\<Number\>}  
Rate Of Change                          |Number     |                           
Relative Strength Index                 |Number     |                             
Simple Moving Average                   |Number     |
Smoothed Moving Average                 |Number     |                             
Stochastic Oscillator                   |Number     |                             
Weighted Moving Average                 |Number     |

### Result collection item

---

Each item in the result collection contains several object properties. See the list below which properties belongs to the particular indicator. All values are numbers except where noted.


Indicator								|Collection Item properties
----------------------------------------|--------------------------------------------------
Average True Range                      |{tr, atr}                              
Bollinger Bands                         |{upper:\<Array\>, middle:\<Array\>, lower:\<Array\>, price:\<Array\>}  
Exponential Moving Average              |{price, ema}                           
Linearly Weighted Moving Average        |{price, lmwa}	                       
Moving Average Convergence Divergence   |{slow_ema:\<Array\>, fast_ema:\<Array\>, signal_ema:\<Array\>, macd:\<Array\>, prices:\<Array\>}
On Balance Volume                       |{price, obv}                           
Rate Of Change                          |{price, roc}
Relative Strength Index                 |{price, gain, loss, avg_gain, avg_loss, rs, rsi}   
Simple Moving Average                   |{price, sma}  
Smoothed Moving Average                 |{price, smma}                         
Stochastic Oscillator                   |{k,v, price}                          
Weighted Moving Average                 |{price, wma} 

### Indicator options

---

To configure the indicator with different settings, you can pass an optional configuration object into the indicator constructor.

Indicator								|Option properties									
----------------------------------------|-------------------------------------------
Average True Range                      |periods, startIndex, endIndex, lazyEvaluation, maxTickDuration				
Bollinger Bands                         |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration				
Exponential Moving Average              |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration, emaResultsOnly, startWithFirst		
Linearly Weighted Moving Average        |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration		
Money Flow Index                        |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration		
Moving Average Convergence Divergence   |fastPeriods, slowPeriods, signalPeriods, sliceOffset, lazyEvaluation, maxTickDuration
On Balance Volume                       |startIndex, endIndex, lazyEvaluation, maxTickDuration						
Rate Of Change                          |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration
Relative Strength Index                 |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration					
Simple Moving Average                   |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration	
Smoothed Moving Average                 |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration			
Stochastic Oscillator                   |periods, startIndex, endIndex, smaPeriods, sliceOffset, lazyEvaluation, maxTickDuration 	
Weighted Moving Average                 |periods, startIndex, endIndex, sliceOffset, lazyEvaluation, maxTickDuration

See the table below for a description of the particular option property.

Option property     |Type       |Description
--------------------|-----------|------------------------
periods             |Number     |The time periods to calculate the indicator
startIndex          |Number     |The index for the passed data serie to start the calulation
endIndex            |Number     |The index for the passed data serie to end the calculation
sliceOffset         |Boolean    |Omit items in result collection used for inital period calculation
fastPeriods         |Number     |The time periods for the fast moving average
slowPeriods         |Number     |The time periods for the slow moving average
signalPeriods       |Number     |The time periods for the signal average
smaPeriods          |Number     |The time periods for the simple moving average
lazyEvaluation      |Boolean    |Do the computation of passed values in an asynchronous fashion
maxTickDuration     |Number     |The computation tick duration in milliseconds. If the computation is not completed, it will be continued in the tick of the next event loop.

## Run Tests

---

All tests are inside `test` folder

Run tests:

    $ npm test

Run code coverage report:

    $ npm run coverage    

## License

This project is under the MIT License. See the LICENSE file for the full license text.

---
_Source: https://npm.io/package/alphacate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
