class Bitstampede::Client

Attributes

key[RW]
secret[RW]

Public Class Methods

new(key = nil, secret = nil) click to toggle source
# File lib/bitstampede/client.rb, line 10
def initialize(key = nil, secret = nil)
  @key    = key
  @secret = secret
end

Public Instance Methods

balance() click to toggle source
# File lib/bitstampede/client.rb, line 15
def balance
  mapper.map_balance(net.post("balance"))
end
buy!(amount, price) click to toggle source
# File lib/bitstampede/client.rb, line 23
def buy!(amount, price)
  trade!("buy", amount, price)
end
cancel(id) click to toggle source
# File lib/bitstampede/client.rb, line 31
def cancel(id)
  wrapping_standard_error do
    mapper.map_cancel(net.post("cancel_order", { id: id.to_s }))
  end
end
orders() click to toggle source
# File lib/bitstampede/client.rb, line 19
def orders
  mapper.map_orders(net.post("open_orders"))
end
sell!(amount, price) click to toggle source
# File lib/bitstampede/client.rb, line 27
def sell!(amount, price)
  trade!("sell", amount, price)
end

Private Instance Methods

mapper() click to toggle source
# File lib/bitstampede/client.rb, line 42
def mapper
  @mapper ||= Mapper.new
end
net() click to toggle source
# File lib/bitstampede/client.rb, line 38
def net
  @net ||= Net.new(self)
end
trade!(type, amount, price) click to toggle source
# File lib/bitstampede/client.rb, line 46
def trade!(type, amount, price)
  wrapping_standard_error do
    mapper.map_order(net.post(type, { price: price.to_digits, amount: amount.to_digits }))
  end
end
wrapping_standard_error() { || ... } click to toggle source
# File lib/bitstampede/client.rb, line 52
def wrapping_standard_error &block
  begin
    yield
  rescue ::StandardError => e
    raise Bitstampede::StandardError.new(e.message)
  end
end