From 338391f39987175455ec9f459e2b33f3b7fc4c6c Mon Sep 17 00:00:00 2001 From: Ethan Barron Date: Thu, 13 Mar 2014 21:13:38 -0500 Subject: [PATCH] #3 - Added support for ClosedOrders --- lib/kraken_ruby/client.rb | 18 ++++++++++++----- spec/client_spec.rb | 41 ++++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/lib/kraken_ruby/client.rb b/lib/kraken_ruby/client.rb index cc78fc1..5edf158 100644 --- a/lib/kraken_ruby/client.rb +++ b/lib/kraken_ruby/client.rb @@ -99,13 +99,21 @@ def trade_balance(assets=nil, opts={}) post_private 'TradeBalance', opts end - def open_orders(trades=nil, opts={}) - if trades - raise ArgumentError if !(trades.is_a?(TrueClass) || trades.is_a?(FalseClass)) - opts[:trades] = trades - end + def open_orders(opts={}) + #if trades + # raise ArgumentError if !(trades.is_a?(TrueClass) || trades.is_a?(FalseClass)) + # opts[:trades] = trades + #end post_private 'OpenOrders', opts end + + def closed_orders(opts={}) + #if trades + # raise ArgumentError if !(trades.is_a?(TrueClass) || trades.is_a?(FalseClass)) + # opts[:trades] = trades + #end + post_private 'ClosedOrders', opts + end def query_orders(opts={}) post_private 'QueryOrders', opts diff --git a/spec/client_spec.rb b/spec/client_spec.rb index b7e3828..65b0f19 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -341,20 +341,43 @@ expect(result).to be_instance_of(Hashie::Mash) expect(result[:open]).to be_instance_of(Hashie::Mash) - result = kraken.open_orders(true) - expect(result).to be_instance_of(Hashie::Mash) - expect(result[:open]).to be_instance_of(Hashie::Mash) + #result = kraken.open_orders(true) + #expect(result).to be_instance_of(Hashie::Mash) + #expect(result[:open]).to be_instance_of(Hashie::Mash) end end - context "given invalid input for 'trades'" do - it "throws an ArgumentError exception" do - expect { kraken.open_orders(1234) }.to raise_error(ArgumentError) - expect { kraken.open_orders(1234.56) }.to raise_error(ArgumentError) - expect { kraken.open_orders({}) }.to raise_error(ArgumentError) - expect { kraken.open_orders([]) }.to raise_error(ArgumentError) + #context "given invalid input for 'trades'" do + # it "throws an ArgumentError exception" do + # expect { kraken.open_orders(1234) }.to raise_error(ArgumentError) + # expect { kraken.open_orders(1234.56) }.to raise_error(ArgumentError) + # expect { kraken.open_orders({}) }.to raise_error(ArgumentError) + # expect { kraken.open_orders([]) }.to raise_error(ArgumentError) + # end + #end + end + + context "using closed_orders()" do + context "given valid input" do + it "gets a list of the user's closed orders" do + result = kraken.closed_orders + expect(result).to be_instance_of(Hashie::Mash) + expect(result[:closed]).to be_instance_of(Hashie::Mash) + + #result = kraken.closed_orders(true) + #expect(result).to be_instance_of(Hashie::Mash) + #expect(result[:closed]).to be_instance_of(Hashie::Mash) end end + + #context "given invalid input for 'trades'" do + # it "throws an ArgumentError exception" do + # expect { kraken.open_orders(1234) }.to raise_error(ArgumentError) + # expect { kraken.open_orders(1234.56) }.to raise_error(ArgumentError) + # expect { kraken.open_orders({}) }.to raise_error(ArgumentError) + # expect { kraken.open_orders([]) }.to raise_error(ArgumentError) + # end + #end end end