Skip to content

Commit

Permalink
leishman#3 - Added support for ClosedOrders
Browse files Browse the repository at this point in the history
  • Loading branch information
Inkybro committed Mar 14, 2014
1 parent 481c641 commit 338391f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
18 changes: 13 additions & 5 deletions lib/kraken_ruby/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 32 additions & 9 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 338391f

Please sign in to comment.