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?