class Trader::Order
Constants
- ASK
- BID
Attributes
instruction[RW]
pair[RW]
Public Class Methods
new(_pair, _instruction, _volume, _price)
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 16 def initialize(_pair, _instruction, _volume, _price) @pair = _pair @instruction = _instruction self.volume = _volume self.price = _price end
new_ask(_pair, _volume, _price = nil)
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 10 def self.new_ask(_pair, _volume, _price = nil) new _pair, ASK, _volume, _price end
new_bid(_pair, _volume, _price = nil)
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 6 def self.new_bid(_pair, _volume, _price = nil) new _pair, BID, _volume, _price end
Public Instance Methods
convert_to(_pair, _quote = nil)
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 47 def convert_to(_pair, _quote = nil) _pair = CurrencyPair.for_code _pair, _quote return self if _pair == pair self.class.new(_pair, instruction, volume, price) end
limit?()
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 23 def limit? !@price.nil? end
market?()
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 27 def market? !limit? end
price()
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 39 def price limit? ? pair.quote.pack(@price) : nil end
price=(_value)
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 43 def price=(_value) @price = _value.nil? ? nil : pair.quote.unpack(_value, strict: false) end
volume()
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 31 def volume pair.base.pack @volume end
volume=(_value)
click to toggle source
# File lib/trade-o-matic/structs/order.rb, line 35 def volume=(_value) @volume = pair.base.unpack(_value, strict: false) end