Class: Vertpig::Order
Instance Attribute Summary collapse
-
#closed_at ⇒ Object
readonly
Returns the value of attribute closed_at.
-
#commission ⇒ Object
readonly
Returns the value of attribute commission.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#executed_at ⇒ Object
readonly
Returns the value of attribute executed_at.
-
#fill ⇒ Object
readonly
Returns the value of attribute fill.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#opened_at ⇒ Object
readonly
Returns the value of attribute opened_at.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#remaining ⇒ Object
readonly
Returns the value of attribute remaining.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .book(market, type, depth = 50) ⇒ Object
- .buy_limit(market, amount, price) ⇒ Object
- .cancel(order_id) ⇒ Object
- .history ⇒ Object
- .info(order_id) ⇒ Object
- .open ⇒ Object
- .sell_limit(market, amount, price) ⇒ Object
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Order
constructor
A new instance of Order.
Methods included from Helpers
Constructor Details
#initialize(attrs = {}) ⇒ Order
Returns a new instance of Order.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vertpig/order.rb', line 10 def initialize(attrs = {}) @id = attrs['Id'] || attrs['OrderUuid'] @type = (attrs['Type'] || attrs['OrderType']).to_s.capitalize @exchange = attrs['Exchange'] @quantity = attrs['Quantity'] @remaining = attrs['QuantityRemaining'] @price = attrs['Rate'] || attrs['Price'] @total = attrs['Total'] @fill = attrs['FillType'] @limit = attrs['Limit'] @commission = (attrs['Commission'] || attrs['CommissionPaid']).to_f @raw = attrs @opened_at = (attrs['Opened']) @executed_at = (attrs['TimeStamp']) @closed_at = (attrs['Closed']) end |
Instance Attribute Details
#closed_at ⇒ Object (readonly)
Returns the value of attribute closed_at.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def closed_at @closed_at end |
#commission ⇒ Object (readonly)
Returns the value of attribute commission.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def commission @commission end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def exchange @exchange end |
#executed_at ⇒ Object (readonly)
Returns the value of attribute executed_at.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def executed_at @executed_at end |
#fill ⇒ Object (readonly)
Returns the value of attribute fill.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def fill @fill end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def id @id end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def limit @limit end |
#opened_at ⇒ Object (readonly)
Returns the value of attribute opened_at.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def opened_at @opened_at end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def price @price end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def quantity @quantity end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def raw @raw end |
#remaining ⇒ Object (readonly)
Returns the value of attribute remaining.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def remaining @remaining end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def total @total end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/vertpig/order.rb', line 6 def type @type end |
Class Method Details
.book(market, type, depth = 50) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vertpig/order.rb', line 27 def self.book(market, type, depth = 50) orders = [] if type.to_sym == :both orderbook(market, type.downcase, depth).each_pair do |type, values| values.each do |data| orders << new(data.merge('Type' => type)) end end else orderbook(market, type.downcase, depth).each do |data| orders << new(data.merge('Type' => type)) end end orders end |
.buy_limit(market, amount, price) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/vertpig/order.rb', line 45 def self.buy_limit(market, amount, price) client.get('market/buylimit', { market: market, quantity: amount, rate: price }) end |
.cancel(order_id) ⇒ Object
67 68 69 70 71 |
# File 'lib/vertpig/order.rb', line 67 def self.cancel(order_id) client.get('market/cancel', { uuid: order_id }) end |
.history ⇒ Object
77 78 79 |
# File 'lib/vertpig/order.rb', line 77 def self.history client.get('account/getorderhistory').map{|data| new(data) } end |
.info(order_id) ⇒ Object
61 62 63 64 65 |
# File 'lib/vertpig/order.rb', line 61 def self.info(order_id) client.get('account/getorder', { uuid: order_id }) end |
.open ⇒ Object
73 74 75 |
# File 'lib/vertpig/order.rb', line 73 def self.open client.get('market/getopenorders').map{|data| new(data) } end |
.sell_limit(market, amount, price) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/vertpig/order.rb', line 53 def self.sell_limit(market, amount, price) client.get('market/selllimit', { market: market, quantity: amount, rate: price }) end |