crypto-aggregator
Advanced tools
Comparing version 1.0.0 to 1.0.2
let options = { | ||
// Forex conversions | ||
getForexData_oxr: true, // Mocked values will be uses if set to false | ||
getForexData_oxr: false, // Mocked values will be uses if set to false | ||
osx_app_id: "YOUR_OSX_APP_ID", // openexchangerates.org app id | ||
@@ -5,0 +5,0 @@ |
@@ -245,8 +245,14 @@ "use strict"; | ||
// Call the callback function | ||
Globals.options.discoveredOneTickerCallBack({ | ||
symbol: crypto, | ||
exchangeName: exchangeName, | ||
ticker: ticker, | ||
market: m | ||
}); | ||
try { | ||
if (Globals.options.discoveredOneTickerCallBack) { | ||
Globals.options.discoveredOneTickerCallBack({ | ||
symbol: crypto, | ||
exchangeName: exchangeName, | ||
ticker: ticker, | ||
market: m | ||
}); | ||
} | ||
} catch (error) { | ||
log.error(error); | ||
} | ||
} | ||
@@ -570,3 +576,3 @@ log | ||
} | ||
// In this pass we assume the total volume for each crypto (aggregatedValueAmongAllExchanges.baseVolume) | ||
// In this pass we assume the total volume for each crypto (aggregatedValueAmongAllExchanges.baseVolume) | ||
//is already calculated in the previous pass | ||
@@ -633,3 +639,3 @@ case "calculatePrice": { | ||
// At this point we have all the prices from different pairs in | ||
// At this point we have all the prices from different pairs in | ||
// aggregatedValueAmongAllExchanges.tickerPrices | ||
@@ -1098,7 +1104,6 @@ if ( | ||
oxr.latest(() => { | ||
if (oxr.rates) { | ||
if (oxr.rates && !oxr.error) { | ||
// Apply exchange rates and base rate to `fx` library object: | ||
fx.rates = oxr.rates; | ||
fx.base = oxr.base; | ||
// log.log("fx.rates: ", JSON.stringify(fx.rates)); | ||
log.info( | ||
@@ -1112,5 +1117,8 @@ `Got Forex values. 1 USD is: `, | ||
} else { | ||
log.error( | ||
"Wasn't able to use live data for converting forex, wrong App ID?" | ||
); | ||
let msg = | ||
"Wasn't able to use live data for converting forex, wrong App ID?"; | ||
if (oxr.error) { | ||
msg += ` ${oxr.error}`; | ||
} | ||
log.error(msg); | ||
log.info("Falling back to mocked values for forex conversions."); | ||
@@ -1117,0 +1125,0 @@ Globals.fallBackToMockForexValues = true; |
{ | ||
"name": "crypto-aggregator", | ||
"version": "1.0.0", | ||
"description": "Aggregates cryptocurrency prices from various exchanges. Prices from different exchanges are weighted by their market cap.", | ||
"version": "1.0.2", | ||
"description": "Aggregates cryptocurrency prices from various exchanges. Prices from different exchanges are weighted by their volume. The result is the Volume-Weighted-Average-Price (VWAP) for each cryptocurrency.", | ||
"main": "examples/demo.js", | ||
@@ -16,2 +16,4 @@ "scripts": { | ||
"crypto", | ||
"VWAP", | ||
"Volume-Weighted-Average-Price", | ||
"market", | ||
@@ -18,0 +20,0 @@ "cap", |
# crypto-aggregator | ||
Continuously scans exchanges and calculates the volume-weighted average price of each cryptocurrency. | ||
Continuously scans various exchanges and calculates the average price of each cryptocurrency. | ||
[![NPM](https://badge.fury.io/js/crypto-aggregator.svg)](https://www.npmjs.com/package/crypto-aggregator) | ||
@@ -33,2 +32,3 @@ [![NPM Downloads][downloadst-image]][downloads-url] | ||
## Simple | ||
In its simplest form, it can run as: | ||
@@ -47,2 +47,4 @@ ```javascript | ||
## Other options and default values | ||
Below are other options and their default values: | ||
```javascript | ||
@@ -124,4 +126,8 @@ options: { | ||
# License | ||
Free to use under [ICS](https://opensource.org/licenses/ISC). Backlinks and credit are greatly appreciated! | ||
# Issue and Pull Requests | ||
Issues and pull requests are welcome. |
130
4586192
11
1914