Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
moving-averages
Advanced tools
The FinTech utility collections of simple, cumulative, and exponential moving averages.
This module is lack of maintainance.
If you are familiar with python programming maybe you could check stock-pandas which provides powerful statistic indicators support, and is backed by numpy
and pandas
, The performance of stock-pandas is many times higher than JavaScript libraries, and can be directly used by machine learning programs.
The complete collection of FinTech utility methods for Moving average, including:
And moving-averages
will also handle empty values.
$ npm i moving-averages
import {
ma, dma, ema, sma, wma
} from 'moving-averages'
ma([1, 2, 3, 4, 5], 2)
// [<1 empty item>, 1.5, 2.5, 3.5, 4.5]
ma(data, size)
Array.<Number|undefined>
the collection of data inside which empty values are allowed. Empty values are useful if a stock is suspended.Number
the size of the periods.Returns Array.<Number|undefined>
// If the size is less than `1`
ma([1, 2, 3], 0.5) // [1, 2, 3]
// If the size is larger than data length
ma([1, 2, 3], 5) // [<3 empty items>]
ma([, 1,, 3, 4, 5], 2)
// [<2 empty items>, 0.5, 1.5, 3.5, 4.5]
And all of the other moving average methods have similar mechanism.
dma(data, alpha, noHead)
Number|Array.<Number>
the coefficient or list of coefficients alpha
represents the degree of weighting decrease for each datum.
alpha
is a number, then the weighting decrease for each datum is the same.alpha
larger than 1
is invalid, then the return value will be an empty array of the same length of the original data.alpha
is an array, then it could provide different decreasing degree for each datum.Boolean=
whether we should abandon the first DMA.Returns Array.<Number|undefined>
dma([1, 2, 3], 2) // [<3 empty items>]
dma([1, 2, 3], 0.5) // [1, 1.5, 2.25]
dma([1, 2, 3, 4, 5], [0.1, 0.2, 0.1])
// [1, 1.2, 1.38]
ema(data, size)
Calulates the most frequent used exponential average which covers about 86% of the total weight (when alpha = 2 / (N + 1)
).
Number
the size of the periods.Returns Array.<Number|undefined>
sma(data, size, times)
Also known as the modified moving average or running moving average, with alpha = times / size
.
Number=1
Returns Array.<Number|undefined>
wma(data, size)
Calculates convolution of the datum points with a fixed weighting function.
Returns Array.<Number|undefined>
MIT
FAQs
The FinTech utility collections of simple, cumulative, and exponential moving averages.
The npm package moving-averages receives a total of 1,037 weekly downloads. As such, moving-averages popularity was classified as popular.
We found that moving-averages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.