Bitcoin Forum
June 20, 2024, 07:40:32 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Market depth and real time updates  (Read 398 times)
zaretskysa (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
July 22, 2013, 03:23:41 PM
 #1

I want to have local copy of mtgox market depth snapshot. So I request full market depth data (https://data.mtgox.com/api/2/BTCEUR/money/depth/full) and connect to websocket (ws://websocket.mtgox.com/mtgox?Currency=USD). But it's not obvious how to apply realtime update to snapshot correctly.

It seems that full mtgox snapshot is updated each 3 minutes on mtgox server, so I buffer depth updates for about 5 minutes, fetch full depth snapshot and try to apply buffered updates. Updates with time stamps lesser than snapshot's time stamp are ignored.

Realtime update has price and total volume, so I find this price in my local snapshot and set new volume for item. If updated volume is zero  I remove item from book. But sometimes  I receive updates for prices that do not present in my local snapshot. So I guess something wrong with my algorithm.

The question is what are rules for merging market depth updates into depth snapshot?
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!