Class: Bitmex::Order
Overview
Order Placement, Cancellation, Amending, and History
Instance Attribute Summary collapse
-
#clOrdID ⇒ Object
readonly
Returns the value of attribute clOrdID.
-
#orderID ⇒ Object
readonly
Returns the value of attribute orderID.
Attributes inherited from Base
Instance Method Summary collapse
-
#all(filters = {}) {|Hash| ... } ⇒ Array
Get your orders.
-
#cancel(text = nil) ⇒ Bitmex::Mash
Cancel an order.
-
#create(symbol, attributes) ⇒ Bitmex::Mash
Place new order.
-
#initialize(rest, websocket = nil, orderID = nil, clOrdID = nil) ⇒ Order
constructor
A new instance of Order.
-
#update(attributes) ⇒ Bitmex::Mash
Amend the quantity or price of an open order.
Constructor Details
#initialize(rest, websocket = nil, orderID = nil, clOrdID = nil) ⇒ Order
Returns a new instance of Order.
7 8 9 10 11 |
# File 'lib/bitmex/order.rb', line 7 def initialize(rest, websocket = nil, orderID = nil, clOrdID = nil) super rest, websocket @orderID = orderID @clOrdID = clOrdID end |
Instance Attribute Details
#clOrdID ⇒ Object (readonly)
Returns the value of attribute clOrdID.
5 6 7 |
# File 'lib/bitmex/order.rb', line 5 def clOrdID @clOrdID end |
#orderID ⇒ Object (readonly)
Returns the value of attribute orderID.
5 6 7 |
# File 'lib/bitmex/order.rb', line 5 def orderID @orderID end |
Instance Method Details
#all(filters = {}) {|Hash| ... } ⇒ Array
Get your orders
17 18 19 20 21 22 23 |
# File 'lib/bitmex/order.rb', line 17 def all(filters = {}, &ablock) if block_given? websocket.listen order: filters[:symbol], &ablock else rest.get order_path, params: filters, auth: true end end |
#cancel(text = nil) ⇒ Bitmex::Mash
Cancel an order
63 64 65 66 67 68 69 |
# File 'lib/bitmex/order.rb', line 63 def cancel(text = nil) params = { orderID: orderID, clOrdID: clOrdID, text: text } rest.delete order_path, params: params do |response| # a single order only response_handler(response).first end end |
#create(symbol, attributes) ⇒ Bitmex::Mash
Place new order
55 56 57 58 |
# File 'lib/bitmex/order.rb', line 55 def create(symbol, attributes) params = attributes.merge symbol: symbol rest.post order_path, params: params end |
#update(attributes) ⇒ Bitmex::Mash
Amend the quantity or price of an open order
34 35 36 37 |
# File 'lib/bitmex/order.rb', line 34 def update(attributes) params = attributes.merge orderID: orderID, origClOrdID: clOrdID rest.put order_path, params: params end |