Class: Coinigy::Order
Overview
Represents an Order in an account
Constant Summary
- BUY =
Order types
1.freeze
- SELL =
2.freeze
- LIMIT =
Price types
3.freeze
- STOP_LIMIT =
6.freeze
- LIMIT_MARGIN =
8.freeze
- STOP_LIMIT_MARGIN =
9.freeze
Instance Attribute Summary collapse
-
#auth_id ⇒ Object
Returns the value of attribute auth_id.
-
#auth_nickname ⇒ Object
Returns the value of attribute auth_nickname.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#exch_code ⇒ Object
Returns the value of attribute exch_code.
-
#exch_id ⇒ Object
Returns the value of attribute exch_id.
-
#exch_name ⇒ Object
Returns the value of attribute exch_name.
-
#executed_price ⇒ Object
Returns the value of attribute executed_price.
-
#foreign_order_id ⇒ Object
Returns the value of attribute foreign_order_id.
-
#last_updated ⇒ Object
Returns the value of attribute last_updated.
-
#limit_price ⇒ Object
Returns the value of attribute limit_price.
-
#mkt_name ⇒ Object
Returns the value of attribute mkt_name.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#order_price_type ⇒ Object
Returns the value of attribute order_price_type.
-
#order_status ⇒ Object
Returns the value of attribute order_status.
-
#order_time ⇒ Object
Returns the value of attribute order_time.
-
#order_type ⇒ Object
Returns the value of attribute order_type.
-
#price_type_id ⇒ Object
Returns the value of attribute price_type_id.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#quantity_remaining ⇒ Object
Returns the value of attribute quantity_remaining.
-
#stop_price ⇒ Object
Returns the value of attribute stop_price.
-
#subscription ⇒ Object
Relations.
-
#unixtime ⇒ Object
Returns the value of attribute unixtime.
Attributes inherited from Model
Instance Method Summary collapse
Methods inherited from Model
#errors?, #initialize, #inspect, #save
Constructor Details
This class inherits a constructor from Coinigy::Model
Instance Attribute Details
#auth_id ⇒ Object
Returns the value of attribute auth_id
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def auth_id @auth_id end |
#auth_nickname ⇒ Object
Returns the value of attribute auth_nickname
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def auth_nickname @auth_nickname end |
#display_name ⇒ Object
Returns the value of attribute display_name
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def display_name @display_name end |
#exch_code ⇒ Object
Returns the value of attribute exch_code
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def exch_code @exch_code end |
#exch_id ⇒ Object
Returns the value of attribute exch_id
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def exch_id @exch_id end |
#exch_name ⇒ Object
Returns the value of attribute exch_name
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def exch_name @exch_name end |
#executed_price ⇒ Object
Returns the value of attribute executed_price
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def executed_price @executed_price end |
#foreign_order_id ⇒ Object
Returns the value of attribute foreign_order_id
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def foreign_order_id @foreign_order_id end |
#last_updated ⇒ Object
Returns the value of attribute last_updated
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def last_updated @last_updated end |
#limit_price ⇒ Object
Returns the value of attribute limit_price
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def limit_price @limit_price end |
#mkt_name ⇒ Object
Returns the value of attribute mkt_name
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def mkt_name @mkt_name end |
#operator ⇒ Object
Returns the value of attribute operator
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def operator @operator end |
#order_id ⇒ Object
Returns the value of attribute order_id
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def order_id @order_id end |
#order_price_type ⇒ Object
Returns the value of attribute order_price_type
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def order_price_type @order_price_type end |
#order_status ⇒ Object
Returns the value of attribute order_status
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def order_status @order_status end |
#order_time ⇒ Object
Returns the value of attribute order_time
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def order_time @order_time end |
#order_type ⇒ Object
Returns the value of attribute order_type
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def order_type @order_type end |
#price_type_id ⇒ Object
Returns the value of attribute price_type_id
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def price_type_id @price_type_id end |
#quantity ⇒ Object
Returns the value of attribute quantity
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def quantity @quantity end |
#quantity_remaining ⇒ Object
Returns the value of attribute quantity_remaining
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def quantity_remaining @quantity_remaining end |
#stop_price ⇒ Object
Returns the value of attribute stop_price
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def stop_price @stop_price end |
#subscription ⇒ Object
Relations
26 27 28 |
# File 'lib/coinigy/order.rb', line 26 def subscription @subscription end |
#unixtime ⇒ Object
Returns the value of attribute unixtime
14 15 16 |
# File 'lib/coinigy/order.rb', line 14 def unixtime @unixtime end |
Instance Method Details
#attributes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/coinigy/order.rb', line 28 def attributes { 'exch_id' => exch_id, 'exch_code' => exch_code, 'exch_name' => exch_name, 'mkt_name' => mkt_name, 'limit_price' => limit_price, 'operator' => operator, 'order_id' => order_id, 'order_type' => order_type, 'order_price_type' => order_price_type, 'order_status' => order_status, 'quantity' => quantity, 'order_time' => order_time, 'foreign_order_id' => foreign_order_id, 'auth_nickname' => auth_nickname, 'auth_id' => auth_id, 'quantity_remaining' => quantity_remaining, 'stop_price' => stop_price, 'price_type_id' => price_type_id, 'display_name' => display_name, 'executed_price' => executed_price, 'last_updated' => last_updated, 'unixtime' => unixtime } end |
#cancel ⇒ Object
72 73 74 |
# File 'lib/coinigy/order.rb', line 72 def cancel subscription.client.cancel_order(order_id) end |
#place ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/coinigy/order.rb', line 53 def place exchange = subscription.exchanges.find { |exchange| exchange.exch_code == exch_code } market = exchange.markets.find { |market| market.mkt_name == mkt_name } order_type_id = (order_type == 'Buy') ? BUY : SELL subscription.client.add_order('auth_id' => auth_id, 'exch_id' => exchange.exch_id, 'mkt_id' => market.mkt_id, 'order_type_id' => order_type_id, 'price_type_id' => price_type_id, 'limit_price' => limit_price, 'order_quantity' => quantity) end |
#replace(changes = {}) ⇒ Object
66 67 68 69 70 |
# File 'lib/coinigy/order.rb', line 66 def replace(changes = {}) cancel assign_attributes(changes.slice(:limit_price, :quantity)) place end |