Keeping consistent market depth using Mt.Gox API I'm trying to write a program using the Mt.Gox API to keep an up-to-date consistent view of their market depth. My current approach is as follows:


Connect WebSocket and subscribe to depth updates
Wait for 1 minute, collecting updates
Request full market depth data via http://data.mtgox.com/api/1/BTCUSD/depth/full
Merge the collected updates into the market data by time-stamp (more recent wins)
Continue merging all future updates into data


After playing around with this for a while, I noticed that the full depth data download doesn't always match the data generated from updates. That's why I added the 1min delay, thinking that maybe the Mt.Gox server only updates the full depth data periodically, but doesn't generate it on the fly.

But even with this protocol, if I run the program twice in parallel, I end up seeing different data in both instances.

Any idea what I might be doing wrong?
In my experience requesting the full market depth from MtGox, often results in flat out incorrect information. To deal with this I've resorted to constructing my own, in a similar manner as you described above. 

What I do is, using the websocket api, I look at all incoming depth events. I then keep two ordered arrays of bids and asks. On depth events if the volume is positive I add the order to the respective array based on the type_str property. If the volume is negative I remove the object from the array.

Make sure to combine objects of the same price, but with different volume. Likewise when removing objects if the negative volume is less then the volume of the same prices object then only deduct from the volume instead of removing. This is how it is done on MtGox's server and it will lead to errors if done differently. 

After letting this run for a little while, though not deep, the order book is quite accurate and representative of what the MtGox order book should be.