coinfloor / API

All you need to know about the APIs for Coinfloor's Trade Engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ticking order book

npomfret opened this issue · comments

I've trying to keep an in memory copy of the order book in a nodes app using the event stream (https://webapi.coinfloorex.com:8090/event-stream).

Which events do I need to listen to in order to be able to keep an accurate representation of the current order book?

There is guidance on this topic in the Implementation Guide. There's no way to (un)subscribe to/from order books in the Event Stream; you're always subscribed to all of them.

Note that the Event Stream will not give you an initial snapshot of the order books. It only provides incremental updates. I'd recommend to connect to the Event Stream first and begin applying the incremental updates to your (initially empty) view, and then subsequently request a snapshot of the order book and merge it into your (possibly nonempty) view. Note that the snapshot could be lagging the stream, so you would want to remember any stream events that didn't match with any order already in your view before you merged the snapshot and replay those events into your view after you merged the snapshot. If done correctly, you'll have a perfectly consistent view of the order book that you can maintain indefinitely.

This is considerably simpler to implement if you use the WebSocket API, which allows you to subscribe to an order book and capture a snapshot of it in one atomic operation.

Thanks @whitslack thats very helpful.

I took a look at the example WS code but struggled to understand it. However, I saw the feed in my browsers networking output and figured out what to do, almost.

I can see how to subscribe to the order book feed, but the parameters are confusing. What are the magic numbers for base and counter? And what is tag? And what is watch?

And how do I unsubscribe from a feed?

Coinfloor's WebSocket API is documented here. You are specifically asking about the WatchOrders command, which is covered in this section.

The asset codes are enumerated here.