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