Skip to content

Commit 5abd09a

Browse files
authored
Merge pull request #9 from neilgarb/orderbook
Update API
2 parents 7743214 + 5d2a705 commit 5abd09a

File tree

3 files changed

+125
-5
lines changed

3 files changed

+125
-5
lines changed

src/Luno/Client.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,38 @@ public function GetOrder(Request\GetOrder $req): Response\GetOrder
187187
}
188188

189189
/**
190-
* GetOrderBook makes a call to GET /api/1/orderbook.
190+
* GetOrderBook makes a call to GET /api/1/orderbook_top.
191191
*
192-
* Returns a list of bids and asks in the order book. Ask orders are sorted by
193-
* price ascending. Bid orders are sorted by price descending. Note that
194-
* multiple orders at the same price are not necessarily conflated.
192+
* Returns a list of the top 100 bids and asks in the order book.
193+
* Ask orders are sorted by price ascending.
194+
* Bid orders are sorted by price descending.
195+
* Orders of the same price are aggregated.
195196
*/
196197
public function GetOrderBook(Request\GetOrderBook $req): Response\GetOrderBook
197198
{
198-
$res = $this->do("GET", "/api/1/orderbook", $req, false);
199+
$res = $this->do("GET", "/api/1/orderbook_top", $req, false);
199200
$mapper = new \JsonMapper();
200201
return $mapper->map($res, new Response\GetOrderBook);
201202
}
202203

204+
/**
205+
* GetOrderBookFull makes a call to GET /api/1/orderbook.
206+
*
207+
* Returns a list of all bids and asks in the order book.
208+
* Ask orders are sorted by price ascending.
209+
* Bid orders are sorted by price descending.
210+
* Multiple orders at the same price are not aggregated.
211+
*
212+
* Warning: This may return a large amount of data. Generally you should rather
213+
* use GetOrderBook or the Streaming API.
214+
*/
215+
public function GetOrderBookFull(Request\GetOrderBookFull $req): Response\GetOrderBookFull
216+
{
217+
$res = $this->do("GET", "/api/1/orderbook", $req, false);
218+
$mapper = new \JsonMapper();
219+
return $mapper->map($res, new Response\GetOrderBookFull);
220+
}
221+
203222
/**
204223
* GetQuote makes a call to GET /api/1/quotes/{id}.
205224
*
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Luno\Request;
4+
5+
class GetOrderBookFull extends AbstractRequest
6+
{
7+
/**
8+
* Currency pair
9+
*/
10+
protected $pair;
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getPair(): string
16+
{
17+
if (!isset($this->pair)) {
18+
return "";
19+
}
20+
return $this->pair;
21+
}
22+
23+
/**
24+
* @param string $pair
25+
*/
26+
public function setPair(string $pair)
27+
{
28+
$this->pair = $pair;
29+
}
30+
}
31+
32+
// vi: ft=php
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Luno\Response;
4+
5+
class GetOrderBookFull extends AbstractResponse
6+
{
7+
protected $asks;
8+
protected $bids;
9+
protected $timestamp;
10+
11+
/**
12+
* @return \Luno\Types\OrderBookEntry[]
13+
*/
14+
public function getAsks(): array
15+
{
16+
if (!isset($this->asks)) {
17+
return [];
18+
}
19+
return $this->asks;
20+
}
21+
22+
/**
23+
* @param \Luno\Types\OrderBookEntry[] $asks
24+
*/
25+
public function setAsks(array $asks)
26+
{
27+
$this->asks = $asks;
28+
}
29+
30+
/**
31+
* @return \Luno\Types\OrderBookEntry[]
32+
*/
33+
public function getBids(): array
34+
{
35+
if (!isset($this->bids)) {
36+
return [];
37+
}
38+
return $this->bids;
39+
}
40+
41+
/**
42+
* @param \Luno\Types\OrderBookEntry[] $bids
43+
*/
44+
public function setBids(array $bids)
45+
{
46+
$this->bids = $bids;
47+
}
48+
49+
/**
50+
* @return int
51+
*/
52+
public function getTimestamp(): int
53+
{
54+
if (!isset($this->timestamp)) {
55+
return 0;
56+
}
57+
return $this->timestamp;
58+
}
59+
60+
/**
61+
* @param int $timestamp
62+
*/
63+
public function setTimestamp(int $timestamp)
64+
{
65+
$this->timestamp = $timestamp;
66+
}
67+
}
68+
69+
// vi: ft=php

0 commit comments

Comments
 (0)