Sha256: 6795861e45f39694e2ccfca1442a4a084896c064eee4e212ec8c74550ddab48a

Contents?: true

Size: 782 Bytes

Versions: 6

Compression:

Stored size: 782 Bytes

Contents

module Bitstamp
  class Orders < Bitstamp::Collection
    def all(options = {})
      Bitstamp::Helper.parse_objects! Bitstamp::Net::post('/open_orders').body_str, self.model
    end

    def create(options = {})
      path = (options[:type] == Bitstamp::Order::SELL ? "/sell" : "/buy")
      Bitstamp::Helper.parse_object! Bitstamp::Net::post(path, options).body_str, self.model
    end

    def sell(options = {})
      options.merge!({type: Bitstamp::Order::SELL})
      self.create options
    end

    def buy(options = {})
      options.merge!({type: Bitstamp::Order::BUY})
      self.create options
    end
  end

  class Order < Bitstamp::Model
    BUY  = 0
    SELL = 1

    attr_accessor :type, :amount, :price, :id, :datetime
    attr_accessor :error, :message
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bitstamp-0.2.5 lib/bitstamp/orders.rb
bitstamp-0.2.4 lib/bitstamp/orders.rb
bitstamp-0.2.3 lib/bitstamp/orders.rb
bitstamp-0.2.2 lib/bitstamp/orders.rb
bitstamp-0.2.1 lib/bitstamp/orders.rb
bitstamp-0.2.0 lib/bitstamp/orders.rb