Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

volatility

is the degree of variation of a trading price series over time

Annotated source | License

NPM version No deps JavaScript Style Guide KLP

Annotated source

/**
 * 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.length

  const 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

About

is the degree of variation of a trading price series over time

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.