Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fibo/volatility
is the degree of variation of a trading price series over time
https://github.com/fibo/volatility
statistics variance volatility
Last synced: 22 days ago
JSON representation
is the degree of variation of a trading price series over time
- Host: GitHub
- URL: https://github.com/fibo/volatility
- Owner: fibo
- License: mit
- Created: 2018-02-23T19:09:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-10T21:42:58.000Z (about 6 years ago)
- Last Synced: 2024-10-04T21:05:38.047Z (about 1 month ago)
- Topics: statistics, variance, volatility
- Language: JavaScript
- Homepage: http://g14n.info/volatility
- Size: 30.3 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# volatility
> is the degree of variation of a trading price series over time
[Annotated source](#annotated-source) |
[License](#license)[![NPM version](https://badge.fury.io/js/volatility.svg)](http://badge.fury.io/js/volatility)
[![No deps](https://img.shields.io/badge/dependencies-none-green.svg)](https://github.com/fibo/volatility)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![KLP](https://img.shields.io/badge/kiss-literate-orange.svg)](http://g14n.info/kiss-literate-programming)## Annotated source
```javascript
/**
* Volatility is the degree of variation of a trading price series over time.
*
* @param {Array} values
* @returns {Number} sigma, a.k.a. *standard deviation* that is the square root of the values *variance*
*/
function volatility (values) {
const n = values.lengthconst mean = values.reduce((a, b) => (a + b), 0) / n
const deviation = values.reduce((dev, val) => (dev + (val - mean) * (val - mean)), 0)
return Math.sqrt(deviation / n)
}module.exports = volatility
```## License
[MIT](http://g14n.info/mit-license/)