crypto-aggregator
Continuously scans exchanges and calculates the volume-weighted average market pair price (VWAMPP) of each cryptocurrency.
What is volume-weighted average market pair price (VWAMPP)?
Volume-Weighted Average Market Market Pair Price (VWAMPP) is the average of the market pair prices from all exchanges where each market pair price is weighted by its volume.
For more details on how VWAMPP is calculated and why it is used, see this article.
Installation
npm install crypto-aggregator --save
Screenshot
examples/demo.js
Usage
Simple
In its simplest form, it can run as:
let options = {
getForexData_oxr: true,
osx_app_id: "YOUR_OSX_APP_ID"
};
var ca = require("../index.js")(options);
ca.start(options);
Other options and default values
Below are other options and their default values:
options: {
loopForEver: true,
maxNumberOfIterations: 10,
printBanner: true,
getCoinGeckoPrices: true,
getForexData_oxr: false,
osx_app_id: "YOUR_OSX_APP_ID",
enable: true,
bypassOutliers: true,
outlierStandardDeviationDistanceFromMean: 3,
aggregatePriceInterval_ms: 5000,
coingGeckoUpdateInterval_ms: 100 * 1000,
statusBarTextInterval_ms: 1000,
aggregatePricesCallBack: null,
iterationCallBack: null,
discoveredOneTickerCallBack:null,
bPrintStatus: true,
printAllPrices: true,
coinsInStatusBar: ["BTC", "ETH"],
ccxtExchangeRateLimitDivider:1,
trustedExchanges: [
"huobipro",
"kraken",
"binance",
"bittrex",
"bitmex",
"bitstamp",
"coinbasepro",
"gemini",
"itbit",
"bitflyer",
"poloniex",
"independentreserve",
"liquid",
"upbit"
],
excludeExchanges: [
"_1btcxe",
"allcoin",
"theocean",
"xbtce",
"cointiger",
"bibox",
"coolcoin",
"uex",
"dsx",
"flowbtc",
"bcex"
]
}
Data Structure and Callbacks
For simplicity, all discovered data and VWAMPP price for all cryptocurrencies is kept in memory. Callback functions are provided which can be used to write data in your own database.
The in-memory values are as follows:
VWAMPP Prices
The VWAMPP price for all cryptos are in pricesInUSD
. Example:
let options = {
getForexData_oxr: false,
osx_app_id: "YOUR_OSX_APP_ID"
};
var ca = require("../index.js")(options);
ca.start(options);
setTimeout(() => {
let pricesInUSD = ca.pricesInUSD;
let log = ca.log;
log.info(`BTC price is: `, pricesInUSD["BTC"]);
}, 5 * 60 * 1000);
Market Pairs
Makrket pairs are kept inside an object called tickers
. They are organized under a tree of:
let cryptoName = "BTC";
let exchangeName = "binance";
let index = 0;
tickers[cryptoName][exchangeName]["pairs"][index].ticker;
tickers[cryptoName][exchangeName]["pairs"][index].market;
where market
and ticker
are taken directly from ccxt
output of fetchTicker
and fetchMarkets
functions.
Example:
let options = {
getForexData_oxr: true,
osx_app_id: "YOUR_OSX_APP_ID"
};
var ca = require("../index.js")(options);
ca.start(options);
setTimeout(() => {
let tickers = ca.tickers;
let log = ca.log;
log.info(`tickers=`, JSON.stringify(tickers));
}, 5 * 60 * 1000);
Logger
The logger used in this package is available separately in log-with-statusbar npm package
License
Free to use under ICS. Backlinks and credit are greatly appreciated!
Issue and Pull Requests
Issues, contributions, and pull requests are welcome!