class Bitstamp::Orders
Public Instance Methods
all(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 3 def all(options = {}) Bitstamp::Helper.parse_objects! Bitstamp::Net.post('/open_orders').body, self.model end
buy(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 21 def buy(options = {}) options.merge!({ type: Bitstamp::Order::BUY, side_execution: Bitstamp::Order::LIMIT_ORDER }) self.create options end
create(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 7 def create(options = {}) path = self.order_path(options) Bitstamp::Helper.parse_object! Bitstamp::Net.post(path, options).body, self.model end
find(order_id)
click to toggle source
# File lib/bitstamp/orders.rb, line 48 def find(order_id) all = self.all index = all.index {|order| order.id.to_i == order_id} return all[index] if index end
limit_order_path(type, options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 75 def limit_order_path(type, options = {}) "/#{type}" end
market_buy(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 30 def market_buy(options = {}) options.merge!({ type: Bitstamp::Order::BUY, side_execution: Bitstamp::Order::MARKET_ORDER }) self.create options end
market_order_path(type, options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 70 def market_order_path(type, options = {}) currency_pair = options[:currency_pair].to_s.empty? ? "btcusd" : options[:currency_pair] "/v2/#{type}/market/#{currency_pair}" end
market_sell(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 39 def market_sell(options = {}) options.merge!({ type: Bitstamp::Order::SELL, side_execution: Bitstamp::Order::MARKET_ORDER }) self.create options end
order_path(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 60 def order_path(options = {}) currency_pair = options[:currency_pair].to_s.empty? ? "btcusd" : options[:currency_pair] type = (options[:type] == Bitstamp::Order::SELL ? "sell" : "buy") if options[:side_execution] == Bitstamp::Order::MARKET_ORDER market_order_path(type, options) else limit_order_path(type, options) end end
sell(options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 12 def sell(options = {}) options.merge!({ type: Bitstamp::Order::SELL, side_execution: Bitstamp::Order::LIMIT_ORDER }) self.create options end
status(order_id, options = {})
click to toggle source
# File lib/bitstamp/orders.rb, line 55 def status(order_id, options = {}) options.merge!({id: order_id}) Bitstamp::Helper.parse_objects! Bitstamp::Net.post('/order_status', options).body, self.model end