2

I want to subscribe to market depth updates using the streaming API https://en.bitcoin.it/wiki/MtGox/API/Streaming. I want to receive only depth updates for a particular symbol (EUR for example) or for all symbols. So I connect to wss://websocket.mtgox.com and send the command

{
     "type": "depth",
     "op": "mtgox.subscribe" 
}

I'm expecting to receive depth updates for all symbols. But it sends me updates only for BTCUSD. Though the same subscribe command with parameter "type" = "trades" sends trades for all symbols (not only BTCUSD). That's a little confusing.

The currency parameter is mentioned in API documentation: websocket.mtgox.com:80/mtgox?Currency=EUR, but after connecting to this websocket I receive ticker updates as well. But I don't need ticker updates.

The question is how can I receive only market depth updates for particular symbol? (or all of symbols)

1

Heres how I do it in node.js

var events = require('events');
var io = require('socket.io-client');

var MTGOX = function(){
    var self = this;
    var socket = io.connect('https://socketio.mtgox.com/mtgox');   

    socket.on('message', function(data){

        var message = data;

        if( message.private == "depth"){
            self.emit('depth', data.depth);    
        } else if( message.private == "ticker" ){
            self.emit('ticker', data.ticker);
        } else if( message.private == "trade" ){
            self.emit('trade', data.trade);
        }

    });
};

MTGOX.prototype.__proto__ = events.EventEmitter.prototype;

and then I just listen to the depth event. Also I found this project helpful when I was first figuring this out.

0

In Java, you can use the XChange library which provides this and other data through a unified API for a range of exchanges.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.