goxstream

0.1.1 • Public • Published

goxstream

Dependency Status

A node.js readable stream for mtgox, based on ws. Reports ticker, depth, trade and lag data in real time. Supports the bitcoin (BTC) channels from this list. Namecoin (NMC) and litecoin (LTC) are currently not traded on MtGox but might be in a near future.

API

goxstream.createStream([opts])

Creates and returns a readable object stream. The options argument configures what type of data you are interested and have the following properties:

  • currency (string) E.g 'USD', 'EUR' etc. Default is 'USD'.
  • ticker (Boolean) Stream ticker data. Default is true.
  • depth (Boolean) Stream depth data, i.e. buys and sells on the market. Default is false.
  • trade (Boolean) Stream trade data, i.e. actual transactions between buyers and sellers. Default is false.
  • lag (Boolean) Stream lag data. Default is false.
  • restart_interval (Number) Time interval in ms. Restart stream after no new data delay. Default is 30000.

goxstream.currencies()

Returns an array of currencies that are available on MtGox.

Examples

Pipe 'USD' ticker data to stdout:

var gox = require('goxstream')
gox.createStream().pipe(process.stdout)

Pipe 'EUR' depth data to file:

var gox = require('goxstream')
var fs  = require('fs')
var options = { currency: 'EUR', ticker: false, depth: true }
gox.createStream(options).pipe(fs.createWriteStream('./EUR'))

Install

npm install goxstream

JSON Format

Here's a brief summary on the different json blobs.

ticker object

All objects under 'ticker' have the same properties as 'high', e.g. 'value', 'value_int' etc

{
    "channel": "d5f06780-30a8-4a48-a2f8-7ed181b4a13f"
  , "channel_name": "ticker.BTCUSD"
  , "op": "private"
  , "origin": "broadcast"
  , "private": "ticker"
  , "ticker": {
        "high": {
            "value": "115.84000"
          , "value_int": "11584000"
          , "display": "$115.84000"
          , "display_short": "$115.84"
          , "currency": "USD"
        }
      , "low": {}
      , "avg": {}
      , "vwap": {}
      , "vol": {}
      , "last_local": {}
      , "last_orig": {}
      , "last_all": {}
      , "last": {}
      , "buy": {}
      , "sell": {}
      , "item": "BTC"
      , "now": "1368096380598414"
    }
}

depth object

{
    "channel": "24e67e0d-1cad-4cc0-9e7a-f8523ef460fe"
  , "channel_name": "depth.BTCUSD"
  , "op": "private"
  , "origin": "broadcast"
  , "private": "depth"
  , "depth": {
        "price": "92"
      , "type": 2
      , "type_str": "bid"
      , "volume": "14.28693815"
      , "price_int": "9200000"
      , "volume_int": "1428693815"
      , "item": "BTC"
      , "currency": "USD"
      , "now": "1368097807984368"
      , "total_volume_int": "84559126689"
    }
}

trade object

{
    "channel": "dbf1dee9-4f2e-4a08-8cb7-748919a71b21"
  , "channel_name": "trade.BTC"
  , "op": "private"
  , "origin": "broadcast"
  , "private": "trade"
  , "trade": {
        "type": "trade"
      , "date": 1368098037
      , "amount": 1.86011338
      , "price": 111.09999
      , "tid": "1368098037413285"
      , "amount_int": "186011338"
      , "price_int": "11109999"
      , "item": "BTC"
      , "price_currency": "USD"
      , "trade_type": "bid"
      , "primary": "Y"
      , "properties": "market"
    }
}

lag object

{
    "channel": "85174711-be64-4de1-b783-0628995d7914"
  , "channel_name": "trade.lag"
  , "op": "private"
  , "origin": "broadcast"
  , "private": "lag"
  , "lag": {
        "qid": "26dc2324-e790-47e8-aef7-e0a1f0633589"
      , "stamp": "1368098833428529"
      , "age":47058
    }
}

License

MIT

Dependencies (3)

Dev Dependencies (1)

Package Sidebar

Install

npm i goxstream

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • ralphtheninja