From f4a4cd02335aa48beb7f91b37156715286b57d53 Mon Sep 17 00:00:00 2001 From: eps Date: Sun, 23 Jun 2013 14:27:03 +0100 Subject: [PATCH] added order_book method --- lib/bitstamp.rb | 4 ++++ spec/bitstamp_spec.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/bitstamp.rb b/lib/bitstamp.rb index 9444b0c..bd341c6 100644 --- a/lib/bitstamp.rb +++ b/lib/bitstamp.rb @@ -40,6 +40,10 @@ def self.ticker return Bitstamp::Ticker.from_api end + def self.order_book + return JSON.parse Bitstamp::Net.post('/order_book/').body_str + end + def self.setup yield self end diff --git a/spec/bitstamp_spec.rb b/spec/bitstamp_spec.rb index 142411e..7b86585 100644 --- a/spec/bitstamp_spec.rb +++ b/spec/bitstamp_spec.rb @@ -28,4 +28,16 @@ Bitstamp.balance.should be_kind_of Hash end + + it 'should have a order_book method' do + Bitstamp.order_book.should be_kind_of Hash + end + + it 'should have bids and asks in the order_book' do + order_book = Bitstamp.order_book + order_book.should have_key("asks") + order_book.should have_key("bids") + order_book["asks"].should be_kind_of Array + order_book["bids"].should be_kind_of Array + end end