Class: Bitex::BaseOrder
- Inherits:
-
Object
- Object
- Bitex::BaseOrder
- Defined in:
- lib/bitex/base_order.rb
Overview
Base class for Bids and Asks
Instance Attribute Summary collapse
-
#created_at ⇒ Time
Time when this Bid was created.
-
#id ⇒ Integer
This Bid’s unique ID.
-
#issuer ⇒ String
The issuer of this order, helps you tell apart orders created from the web UI and the API.
-
#orderbook ⇒ Symbol
:btc_usd or :btc_ars.
-
#price ⇒ BigDecimal
Maximum price to pay per unit.
-
#reason ⇒ Object
The cancellation reason for your Ask/Bid subclass, if any.
-
#status ⇒ Object
The status in its lifecycle, was defined into Ask/Bid subclass.
Class Method Summary collapse
-
.active ⇒ Object
Returns an array with all your active orders of this type.
-
.all ⇒ Object
Returns an array with all your active orders of this type and another order of this type that was active the last 2 hours.
-
.find(id) ⇒ Object
Find an order in your list of active orders.
- .find_order(order) ⇒ Object
- .orderbooks ⇒ Object
- .reasons ⇒ Object
- .statuses ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#created_at ⇒ Time
Returns Time when this Bid was created.
10 11 12 |
# File 'lib/bitex/base_order.rb', line 10 def created_at @created_at end |
#id ⇒ Integer
Returns This Bid’s unique ID.
6 7 8 |
# File 'lib/bitex/base_order.rb', line 6 def id @id end |
#issuer ⇒ String
Returns The issuer of this order, helps you tell apart orders created from the web UI and the API.
34 35 36 |
# File 'lib/bitex/base_order.rb', line 34 def issuer @issuer end |
#orderbook ⇒ Symbol
Returns :btc_usd or :btc_ars.
14 15 16 |
# File 'lib/bitex/base_order.rb', line 14 def orderbook @orderbook end |
#price ⇒ BigDecimal
Returns Maximum price to pay per unit.
18 19 20 |
# File 'lib/bitex/base_order.rb', line 18 def price @price end |
#reason ⇒ Object
The cancellation reason for your Ask/Bid subclass, if any.
-
:not_cancelled Has not been cancelled.
-
:not_enough_funds Not enough funds to place this order.
-
:user_cancelled Cancelled per user’s request
-
:system_cancelled Bitex cancelled this order, for a good reason.
30 31 32 |
# File 'lib/bitex/base_order.rb', line 30 def reason @reason end |
#status ⇒ Object
The status in its lifecycle, was defined into Ask/Bid subclass.
22 23 24 |
# File 'lib/bitex/base_order.rb', line 22 def status @status end |
Class Method Details
.active ⇒ Object
Returns an array with all your active orders of this type. Uses Order.active under the hood.
44 45 46 |
# File 'lib/bitex/base_order.rb', line 44 def self.active Order.active.select { |o| o.is_a?(self) } end |
.all ⇒ Object
Returns an array with all your active orders of this type and another order of this type that was active the last 2 hours. Uses Order.all under the hood.
38 39 40 |
# File 'lib/bitex/base_order.rb', line 38 def self.all Order.all.select { |o| o.is_a?(self) } end |
.find(id) ⇒ Object
Find an order in your list of active orders. Uses Order.active under the hood.
50 51 52 |
# File 'lib/bitex/base_order.rb', line 50 def self.find(id) from_json(Api.private(:get, "/private#{base_path}/#{id}")) end |
.find_order(order) ⇒ Object
88 89 90 91 92 |
# File 'lib/bitex/base_order.rb', line 88 def self.find_order(order) find(order.id) rescue StandardError order end |
.orderbooks ⇒ Object
94 95 96 |
# File 'lib/bitex/base_order.rb', line 94 def self.orderbooks { 1 => :btc_usd, 5 => :btc_ars } end |
.reasons ⇒ Object
98 99 100 |
# File 'lib/bitex/base_order.rb', line 98 def self.reasons { 0 => :not_cancelled, 1 => :not_enough_funds, 2 => :user_cancelled, 3 => :system_cancelled } end |
.statuses ⇒ Object
102 103 104 |
# File 'lib/bitex/base_order.rb', line 102 def self.statuses { 1 => :received, 2 => :executing, 3 => :cancelling, 4 => :cancelled, 5 => :completed } end |