class Trader::AccountOrder
Constants
- CANCELED
- CLOSED
- OPEN
- PENDING
Attributes
backend[R]
forced_pair[R]
session[R]
Public Class Methods
new(_backend, _session, _raw, _forced_pair=nil)
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 8 def initialize(_backend, _session, _raw, _forced_pair=nil) @backend = _backend @session = _session @raw = _raw @forced_pair = _forced_pair end
Public Instance Methods
cancel!()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 74 def cancel! @raw = backend.cancel_order(session, id) self end
convert_to(_pair, _quote=nil)
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 15 def convert_to(_pair, _quote=nil) forced_pair = CurrencyPair.for_code _pair, _quote return self if forced_pair == pair self.class.new backend, session, @raw, forced_pair end
executed_volume()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 61 def executed_volume convert_base original_pair.base.pack @raw.executed_volume end
finished?()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 79 def finished? status == CLOSED or status == CANCELED end
id()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 23 def id @raw.id end
instruction()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 43 def instruction @raw.instruction end
limit?()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 39 def limit? @raw.limit? end
original_pair()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 31 def original_pair @raw.pair end
pair()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 27 def pair forced_pair || original_pair end
pending_volume()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 65 def pending_volume convert_base(volume - executed_volume) end
price()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 47 def price if limit? convert_quote original_pair.quote.pack @raw.price else nil end end
refresh!()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 69 def refresh! @raw = backend.fetch_order(session, id) self end
status()
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 35 def status @raw.status end
volume()
click to toggle source
TODO: executed_price
# File lib/trade-o-matic/core/account_order.rb, line 57 def volume convert_base original_pair.base.pack @raw.volume end
Private Instance Methods
convert_base(_price)
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 87 def convert_base(_price) return _price if forced_pair.nil? _price.convert_to forced_pair.base end
convert_quote(_price)
click to toggle source
# File lib/trade-o-matic/core/account_order.rb, line 92 def convert_quote(_price) return _price if forced_pair.nil? _price.convert_to forced_pair.quote end