class Btcmrb::Order

Public Class Methods

all(instrument="BTC", limit=10) click to toggle source
# File lib/btcmrb/order.rb, line 4
def self.all(instrument="BTC", limit=10)
  # Documentation
  # POST "/order/history"
  # since parameter - an order id.
  # {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}
  # {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}

  # Implementation
  {
    :uri => "/order/history",
    :body => {"currency":"AUD","instrument":instrument,"limit":limit,"since":1},
    :verb => "POST",
    :auth => true
  }
end
cancel(id) click to toggle source
# File lib/btcmrb/order.rb, line 86
def self.cancel(id)
  # Documentation
  # POST "/order/cancel"
  # {"orderIds":[6840125478]}
  # => {"success":true,"errorCode":null,"errorMessage":null,"responses":[{"success":false,"errorCode":3,"errorMessage":"order does not exist.","id":6840125478}]}

  # Implementation
  {
    :uri => "/order/cancel",
    :body => {"orderIds":id},
    :verb => "POST",
    :auth => true
  }
end
create(currency, instrument, price, volume, order_side, order_type, client_request_id="abc-cdf-1000") click to toggle source
# File lib/btcmrb/order.rb, line 67
def self.create(currency, instrument, price, volume, order_side, order_type, client_request_id="abc-cdf-1000")
  # Documentation
  # POST "/order/create"
  # The clientRequestId is not currently used but must be specified. Any string is valid.
  # Price of $130 = 13000000000 (i.e x 100000000)
  # Volume of 1 BTC = 100000000 (i.e x 100000000)
  # {"currency":"AUD","instrument":"BTC","price":13000000000,"volume":10000000,"orderSide":"Bid","ordertype":"Limit","clientRequestId":"abc-cdf-1000"}
  # => {"success":true,"errorCode":null,"errorMessage":null,"id":100,"clientRequestId":"abc-cdf-1000"}
  # => {"success":false,"errorCode":3,"errorMessage":"Invalid argument.","id":0,"clientRequestId":"abc-cdf-1000"}

  # Implementation
  {
    :uri => "/order/create",
    :body => {"currency":currency,"instrument":instrument,"price":(price*100000000).round(0),"volume":(volume*100000000).round(0),"orderSide":order_side,"ordertype":order_type,"clientRequestId":client_request_id},
    :verb => "POST",
    :auth => true
  }
end
open_orders(instrument="BTC", limit=10) click to toggle source

Similar to Index, but only returns open orders

# File lib/btcmrb/order.rb, line 21
def self.open_orders(instrument="BTC", limit=10)
  # Documentation
  # POST "/order/open"
  # {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}
  # {"success":true,"errorCode":null,"errorMessage":null,"orders":[{"id":1003245675,"currency":"AUD","instrument":"BTC","orderSide":"Bid","ordertype":"Limit","creationTime":1378862733366,"status":"Placed","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":10000000,"clientRequestId":null,"trades":[]},{"id":4345675,"currency":"AUD","instrument":"BTC","orderSide":"Ask","ordertype":"Limit","creationTime":1378636912705,"status":"Fully Matched","errorMessage":null,"price":13000000000,"volume":10000000,"openVolume":0,"clientRequestId":null,"trades":[{"id":5345677,"creationTime":1378636913151,"description":null,"price":13000000000,"volume":10000000,"fee":100000}]}]}

  # Implementation
  {
    :uri => "/order/open",
    :body => {"currency":"AUD","instrument":instrument,"limit":limit,"since":1},
    :verb => "POST",
    :auth => true
  }
end
show(*ids) click to toggle source
# File lib/btcmrb/order.rb, line 52
def self.show(*ids)
  # Documentation
  # POST "/order/detail"
  # {"orderIds":[6840125478]}


  # Implementation
  {
    :uri => "/order/detail",
    :body => {"orderIds":ids},
    :verb => "POST",
    :auth => true
  }
end
trade_history(instrument="BTC", limit=10) click to toggle source
# File lib/btcmrb/order.rb, line 36
def self.trade_history(instrument="BTC", limit=10)
  # Documentation
  # POST "/order/trade/history"
  # since parameter - a trade id.
  # {"currency":"AUD","instrument":"BTC","limit":10,"since":33434568724}


  # Implementation
  {
    :uri => "/order/trade/history",
    :body => {"currency":"AUD","instrument":instrument,"limit":limit,"since":1},
    :verb => "POST",
    :auth => true
  }
end