Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jxm262/btc-stats
Bitcoin price api to calculate statistics on spot prices across exchanges.
https://github.com/jxm262/btc-stats
bitcoin exchange javascript
Last synced: 12 days ago
JSON representation
Bitcoin price api to calculate statistics on spot prices across exchanges.
- Host: GitHub
- URL: https://github.com/jxm262/btc-stats
- Owner: jxm262
- License: mit
- Created: 2015-01-11T17:09:28.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-06-10T19:33:22.000Z (over 7 years ago)
- Last Synced: 2024-10-28T01:28:14.220Z (17 days ago)
- Topics: bitcoin, exchange, javascript
- Language: JavaScript
- Size: 27.3 KB
- Stars: 30
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
btc-stats [![Build Status](https://travis-ci.org/jxm262/btc-stats.svg?branch=master)](https://travis-ci.org/jxm262/btc-stats)
=========
Bitcoin price api to calculate statistics on spot prices across exchanges. Uses the [xchange.js](https://github.com/jxm262/xchange.js) module to retrieve current ticker prices.
Note!! This is highly in the Alpha stage.
This project currently supports the following exchanges
+ bitfinex
+ bitstamp
+ okcoin
+ btce
+ bter
+ hitbtc
+ ccex
Note: these are all using btc-usd
## DownloadThe source is available for download from npm or here on github (master branch)
npm install btc-stats
If preferred, you can specify a range of exchanges by calling the .exchanges() function. Otherwise, the functions will run across all the exchanges mentioned above.```js
//example - use only these 3 exchanges
btcstats.exchanges(["bitfinex", "bitstamp", "okcoin"]);
```#### Quick Examples
```js
var btcstats = require("btc-stats");//if this line isn't specified, it runs the avg function across all exchanges, not just these 3
btcstats.exchanges(["bitfinex", "bitstamp", "okcoin"]);//Example print the average price across 3 exchanges (bitfinex, bitstamp, okcoin)
btcstats.avg(function(error, resp) {
if (!error) {
console.log(resp);
}
});
```
## Documentation* [`avg`](#avg)
* [`weightedAvg`](#weightedAvg)
* [`min`](#min)
* [`max`](#max)
* [`minVolume`](#minVolume)
* [`maxVolume`](#maxVolume)
* [`minSpread`](#minSpread)
* [`maxSpread`](#maxSpread)
* [`exchangeMinSpread`](#exchangeMinSpread)
* [`exchangeMaxSpread`](#exchangeMaxSpread)
All Functions accept a callback argument* `callback(err, results)` - Called when the process completes, or an error occurs.
Calculates average midpoint price across exchanges. Midpoint is defined as mid-price between bid vs ask.
```js
btcstats.avg(function(error, resp) {
//response format { price: xxx }
});
```---------------------------------------
### weightedAvg(callback)Calculates average midpoint price across exchanges, weighted by volume.
```js
btcstats.weightedAvg(function(error, resp) {
//response format { price: xxx }
});
```---------------------------------------
### min(callback)Calculates the exchange with the minimum price.
```js
btcstats.min(function(error, resp) {
//response format { price: xxx , exchange: xxx}
});
```---------------------------------------
### max(callback)Calculates the exchange with the maximum price.
```js
btcstats.max(function(error, resp) {
//response format { price: xxx , exchange: xxx }
});
```---------------------------------------
### minVolume(callback)Calculates the exchange with the minimum volume.
```js
btcstats.minVolume(function(error, resp) {
//response format { volume: xxx , exchange: xxx }
});
```---------------------------------------
### maxVolume(callback)Calculates the exchange with the maximum volume.
```js
btcstats.maxVolume(function(error, resp) {
//response format { volume: xxx , exchange: xxx }
});
```---------------------------------------
### minSpread(callback)Calculates minimum spread between all exchanges. Defined as the exchange with the lowest asking price vs the exchange with the highest bidding price. This result may often be a negative number if 1 exchange has a higher bid vs an exchange with a lower ask (potential arbitrage maybe ? :)
```js
btcstats.minSpread(function(error, resp) {
//response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx }
});
```---------------------------------------
### maxSpread(callback)Calculates maximum spread between all exchanges. Defined as the exchange with the highest asking price vs the exchange with the lowest bidding price.
```js
btcstats.maxSpread(function(error, resp) {
//response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx }
});
```
---------------------------------------
### exchangeMinSpread(callback)Calculates the exchange (within the list of exchanges) , with the minimum spread. Defined as the exchange with the highest asking price vs the lowest bidding price.
```js
btcstats.exchangeMinSpread(function(error, resp) {
//response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx }
});
```---------------------------------------
### exchangeMinSpread(callback)Calculates the exchange (within the list of exchanges) , with the minimum spread. Defined as the exchange with the highest asking price vs the lowest bidding price.
```js
btcstats.exchangeMinSpread(function(error, resp) {
//response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx }
});
```---------------------------------------
Working on btc-stats
====================To help work on btc-stats, you'll need to
- have Node installed.
- Then clone the repo
- install dependencies```
git clone https://github.com/jxm262/btc-stats.git
cd btc-stats
npm install
```
## To run tests (using mocha chai)
```
npm test
```
About the Project
=================
This project utilizes my earlier project - [xchange.js](https://github.com/jxm262/xchange.js). Please please feel free to join in and help contribute. I'm also very open to suggestions or code reviews :)