1

I'm getting started with the mtgox api. I'm primarily using this page to tell me how to use it.

What I've currently got, is I can fetch the depth and then put the bids and asks into 'buckets' (each being a range of price), and can tell you the volume at each bucket.

Now what I want to be able to is keep this updated every second or so.

So I'd need to be keeping track of:

  • Trades being made (ie Bids/Asks being met).

  • New Bids/Asks.

  • Bids/Asks being cancelled.

It appears as if the old version of the api could show the net change at each volume, but this doesn't appear to be the case for the new version.

How would I go about doing this?

2 Answers 2

1
+50

There are two ways you can do this.

1) MtGox Polling API V2. You call the getFullDepth to download the full orderbook. Then you call getPartialDepth for updates, replacing all the orders in your master order book. This method is not very efficient and you can only poll at a throttled pace.

Here's a demo from the XChange open source project for simply polling for the partial order book and creating an orderbook chart.

2) MtGox Polling API V2 + streaming. You call the getFullDepth to download the full orderbook. Then you use the streaming API to receive depth events and update your master order book accordingly. Depth updates with an amount of zero mean that the orders were cancelled or filled, i.e. they don't exist anymore and you can remove them.

Here's a demo from the XChange open source project.

0
1

Your link to the "old version of the API" is actually going to the streaming API which is still available. Only the http version was updated and from there it looks difficult to obtain accurate depth info reliably for precise time periods.

So I'd stick with streaming. Updated much more in real-time for your requirements.

Now they deprecated the depth:volume field but they still have volume_int, which is volume change * 1E8, so you could obtain volume from that:

//js for example
var volume = volume_int * Math.pow(10,-8);

Check out the github samples at the bottom of the wiki page to help get started. For example, this one

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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