How to view entire order book

Posted by Alan3285 
How to view entire order book
May 23, 2011 09:59AM
Hi All,

There is an 'interesting' order book on US.OTHER12 whereby it looks like IPredict is perhaps experimenting with a different setup for the market maker.

In order to see how it was structured, I thought I'd experiment with bringing the entire order book into Excel, but I cannot get it to work - within or outside of Excel.

From reading other posts, I understood that this URL would give me the whole book:

/ipapi/?action=book&type=both&contract=US.OTHER12

However, if I open it in either Excel or a browser, I get what I assume to be an HTML / XML (?) file.

That's fine - if I want it in Excel, I would have to parse it.

However, I cannot get it to display all the way through the book - it stops at 46.2c (sell side).

Just to be sure, I entered a sell order for 4567 units at 0.9999 (random units in case there was another sell at 0.9999), and it appears fine in the web interface, but I cannot see it on the above URL (I have removed it now, so you won't find it if you look after reading this).


Just in case I was doing something wrong, I also tried from Luke's webpage:

/796551b68e07040fc8e7c28369526a3e/index.php

but I get the same result (click on the link he provides below the book for that stock).


Is it just me, and since it seems likely it is me doing something wrong, please can someone tell me what?

Thanks,

Alan.
Re: How to view entire order book
May 23, 2011 12:59PM
Try:
[www.ipredict.co.nz]

You will need to specify the max number of rows. I've put 1000, which takes you up to 0.917.

To use it in excel you'll want to delete the first 20 or so lines of info to get the CSV data and then split on commas.
Re: How to view entire order book
May 23, 2011 01:18PM
Great - I must have missed the 'numRowsOrders' parameter.

Where did you find that?

Thanks,

Alan.
Re: How to view entire order book
May 23, 2011 01:24PM
It's in the API documentation, but also the XML has a "messages" block that tells you of any errors or warnings. In your query, it warned it was defaulting to max 500 result rows.

Oliver
Re: How to view entire order book
May 23, 2011 01:34PM
Hi Eeyore,

Sorry to be a pain, but please could you point me to the API documentation where the parameters are listed?

I looked back at my original attempt and I see the 'warning' messages:

Quote
API
<message code="xml.params.info">Parameter info: numRowsOrders param not trying legacy 'entries'</message>
<message code="xml.params.info">Parameter info: entries not found using default 500</message>

However, I figure there might be other useful parameters that I don't know about!

Thanks again,

Alan.
Re: How to view entire order book
May 23, 2011 01:46PM
http://groups.google.com/group/ipredict-developers/web/version-2-api-documentation

If you don't mind reading WADL, you can see the possible parameters formally defined.

Further down the page it has the parameters, but the described defaults are wrong. The default rows is 500 not 10.

Oliver
Re: How to view entire order book
May 23, 2011 02:03PM
Fantastic.

Thanks Oliver - Much appreciated.

Alan.
Re: How to view entire order book
May 23, 2011 04:51PM
Hi,

I am looking at the API page linked above:

http://groups.google.com/group/ipredict-developers/web/version-2-api-documentation?pli=1

The 'book' section reads thus:

Quote
API Documentation

Book

action=bookParams

Params:

  • contract (stock also matches), required - can specify single contract name, or a search term using wildcards e.g. pm* would return any contracts that begins with pm (case insensitive), or a comma seperated list of contract names e.g. MP.PETERS.2011,90D.JUN10.VLOW,91.MAY10.MID
  • type (buy | sell| both), required
  • offsetOrders; integer, defaults to 0
  • offsetContracts; integer, defaults to 0
  • numRowsOrders; integer, defaults to 10
  • numRowsContracts; integer, defaults to 10


Is there anywhere a description of what those paramters actually do?

Specifically, what do the 'offsetOrders' and 'offsetContracts', and 'numRowsContracts' do?

Thanks,

Alan.
Re: How to view entire order book
May 23, 2011 08:56PM
The API isn't fully documented (or well designed, in my humble opinion).

But the offsets are for paging. e.g. if you were displaying results in a web page, you might show 10 per page with next or page number links. You'd fetch 10 at a time (numRowsOrders=10) and use the offset to show the right ones (eg. offsetOrders=20 for page 3 which starts at the 21st record).

The offsetContracts is for the same thing, but with contracts - as you can fetch the book for multiple contracts at once (comma separated).

I've just noticed I pasted the wrong URL for you above. The last parameter should've been output=csv not format=csv. You can also have HTML. Examples:

/ipapi/?action=book&type=both&contract=US.OTHER12&numRowsOrders=100&output=html

/ipapi/?action=book&type=both&contract=US.OTHER12&numRowsOrders=100&output=csv
Re: How to view entire order book
May 23, 2011 11:11PM
Hi Oliver,

Thanks for that. I spotted the output= vs format= thing (it, at least, is documented okay in the page you linked).

I think I can safely ignore the offset stuff since I am bringing them into excel, and I just want it all in one go.

Thanks again,

Alan.
Re: How to view entire order book
May 24, 2011 06:26PM
I've cast my eye over how the Easy API Interface handles the order book, and I've added numRowsOrders=5000 to the URL it collects data from.

I also found a bug in displaying the order book - it was only displaying as many rows of order book as Buy orders. So if there were 22 Buy orders it would show them alongside a matching column of 22 Sell orders, even if there were actually 50 or 100 Sell orders. This is now fixed.

Thanks for calling this to my attention guys.
Re: How to view entire order book
May 24, 2011 07:23PM
Thanks Luke.

I did something similar with my excel experiments, but used 9999 rows.

Alan.
Sorry, only registered users may post in this forum.

Click here to login