Comparing version 0.0.3 to 0.0.4
@@ -7,2 +7,6 @@ var Q = require('q'); | ||
var TIMEOUT = 5000; | ||
var ACCEPTABLE_VARIANCE = 3; | ||
var MINIMUM_VALUES_VARIANCE = 3; | ||
/** | ||
@@ -16,3 +20,7 @@ * GET PRICE FROM API SERVICE | ||
function requestPrice(urlAPI, objectPath, callback){ | ||
request.get(urlAPI, function(error, res, body){ | ||
request({ | ||
method: 'GET', | ||
url: urlAPI, | ||
timeout: TIMEOUT | ||
}, function(error, res, body){ | ||
@@ -64,3 +72,3 @@ if(error){ | ||
function(err, prices){ | ||
var infoAverage = smartaverage(3, 3, prices); | ||
var infoAverage = smartaverage(ACCEPTABLE_VARIANCE, MINIMUM_VALUES_VARIANCE, prices); | ||
var pricesProviders = {}; | ||
@@ -67,0 +75,0 @@ prices.forEach(function(price, i){ |
{ | ||
"name": "btcaverage", | ||
"description": "Get Bitcoin price average from 13 providers. Doing math variance algorithm: if some service is broken the average not will be broken.", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"author": "CodersBrothers", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/CodersBrothers/btcaverage", |
# Bitcoin price average | ||
This library uses multiple providers of price for calculate average price in $ (USD), but with one important feature: If some service is broken the average not will be broken. Use a math concept: Variance. This use prices calculating variance and discarding the farthest values. This library is resistant for errors in providers. | ||
This library uses multiple providers of price for calculate price average in $ (USD), but with one important feature: If some service is broken the average not will be broken. Use a math concept: Variance. BtcAverage uses providers prices calculating variance and discarding the farthest values. This library is resistant for errors of the providers. | ||
@@ -28,3 +28,3 @@ ## Providers | ||
```js | ||
var btcaverage = require('./btcaverage'); | ||
var btcaverage = require('btcaverage'); | ||
btcaverage() | ||
@@ -31,0 +31,0 @@ .then(function(priceDetails){ |
8731
148