Class: Bitex::BaseOrder

Inherits:
Object
  • Object
show all
Defined in:
lib/bitex/base_order.rb

Overview

Base class for Bids and Asks

Direct Known Subclasses

Ask, Bid

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atTime

Returns Time when this Bid was created.

Returns:

  • (Time)

    Time when this Bid was created.



10
11
12
# File 'lib/bitex/base_order.rb', line 10

def created_at
  @created_at
end

#idInteger

Returns This Bid’s unique ID.

Returns:

  • (Integer)

    This Bid’s unique ID.



6
7
8
# File 'lib/bitex/base_order.rb', line 6

def id
  @id
end

#issuerString

Returns The issuer of this order, helps you tell apart orders created from the web UI and the API.

Returns:

  • (String)

    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

#order_bookSymbol

Returns :btc_usd or :btc_ars.

Returns:

  • (Symbol)

    :btc_usd or :btc_ars



14
15
16
# File 'lib/bitex/base_order.rb', line 14

def order_book
  @order_book
end

#priceBigDecimal

Returns Maximum price to pay per unit.

Returns:

  • (BigDecimal)

    Maximum price to pay per unit.



18
19
20
# File 'lib/bitex/base_order.rb', line 18

def price
  @price
end

#reasonObject

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

#statusObject

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

.activeObject

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

.allObject

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

Instance Method Details

#cancel!Object



73
74
75
76
# File 'lib/bitex/base_order.rb', line 73

def cancel!
  path = "/private#{self.class.base_path}/#{id}/cancel"
  self.class.from_json(Api.private(:post, path), self)
end