npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

btc-stats

v0.0.2

Published

Bitcoin price api. Calculates statistics on spot prices across exchanges.

Downloads

24

Readme

btc-stats Build Status

Bitcoin price api to calculate statistics on spot prices across exchanges. Uses the 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

Download

The 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.

Example

btcstats.exchanges(["bitfinex", "bitstamp", "okcoin"]);

Quick Examples

var btcstats = require("../lib/btcstats")

//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

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.

btcstats.avg(function(error, resp) {
    //response format { price: xxx }
});

Calculates average midpoint price across exchanges, weighted by volume.

btcstats.weightedAvg(function(error, resp) {
    //response format { price: xxx }
});

Calculates the exchange with the minimum price.

btcstats.min(function(error, resp) {
    //response format { price: xxx , exchange: xxx}
});

Calculates the exchange with the maximum price.

btcstats.max(function(error, resp) {
    //response format { price: xxx , exchange: xxx }
});

Calculates the exchange with the minimum volume.

btcstats.minVolume(function(error, resp) {
    //response format { volume: xxx , exchange: xxx }
});

Calculates the exchange with the maximum volume.

btcstats.maxVolume(function(error, resp) {
    //response format { volume: xxx , exchange: xxx }
});

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 ? :)

btcstats.minSpread(function(error, resp) {
    //response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx } 
});

Calculates maximum spread between all exchanges. Defined as the exchange with the highest asking price vs the exchange with the lowest bidding price.

btcstats.maxSpread(function(error, resp) {
    //response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx } 
});

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.

btcstats.exchangeMinSpread(function(error, resp) {
    //response format { spread: xxx, bid: xxx, ask: xxx, bidExchange: xxx, askExchange: xxx } 
});

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.

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. Please please feel free to join in and help contribute. I'm also very open to suggestions or code reviews :)