Skip to content

Commit fe9f4e7

Browse files
committed
Implement market.get_limit_orders(depth) bitshares#244
1 parent ab26541 commit fe9f4e7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

bitshares/market.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ def orderbook(self, limit=25):
234234
``base``, ``quote`` and ``price``. From those you can
235235
obtain the actual amounts for sale
236236
237+
.. note:: This method does order consolidation and hides some
238+
details of individual orders!
239+
237240
"""
238241
orders = self.blockchain.rpc.get_order_book(
239242
self["base"]["id"], self["quote"]["id"], limit
@@ -271,6 +274,42 @@ def orderbook(self, limit=25):
271274
data = {"asks": asks, "bids": bids}
272275
return data
273276

277+
def get_limit_orders(self, limit=25):
278+
""" Returns the list of limit orders for a given market.
279+
280+
:param int limit: Limit the amount of orders (default: 25)
281+
282+
Sample output:
283+
284+
.. code-block:: js
285+
286+
{'bids': [0.003679 USD/BTS (1.9103 USD|519.29602 BTS),
287+
0.003676 USD/BTS (299.9997 USD|81606.16394 BTS),
288+
0.003665 USD/BTS (288.4618 USD|78706.21881 BTS),
289+
0.003665 USD/BTS (3.5285 USD|962.74409 BTS),
290+
0.003665 USD/BTS (72.5474 USD|19794.41299 BTS)],
291+
'asks': [0.003738 USD/BTS (36.4715 USD|9756.17339 BTS),
292+
0.003738 USD/BTS (18.6915 USD|5000.00000 BTS),
293+
0.003742 USD/BTS (182.6881 USD|48820.22081 BTS),
294+
0.003772 USD/BTS (4.5200 USD|1198.14798 BTS),
295+
0.003799 USD/BTS (148.4975 USD|39086.59741 BTS)]}
296+
297+
298+
.. note:: Each bid is an instance of
299+
class:`bitshares.price.Order` and thus carries the keys
300+
``base``, ``quote`` and ``price``. From those you can
301+
obtain the actual amounts for sale
302+
303+
"""
304+
return list(
305+
map(
306+
lambda x: Order(x, blockchain_instance=self.blockchain),
307+
self.blockchain.rpc.get_limit_orders(
308+
self["base"]["id"], self["quote"]["id"], limit
309+
),
310+
)
311+
)
312+
274313
def trades(self, limit=25, start=None, stop=None):
275314
""" Returns your trade history for a given market.
276315

0 commit comments

Comments
 (0)