Class: Gekko::LimitOrder

Inherits:
Order
  • Object
show all
Defined in:
lib/gekko/limit_order.rb

Overview

Represents a limit order. These order must specify a price.

Instance Attribute Summary collapse

Attributes inherited from Order

#created_at, #expiration, #id, #remaining, #side, #size

Instance Method Summary collapse

Methods inherited from Order

#ask?, #bid?, #crosses?, #expired?, #fill_or_kill?, #message

Constructor Details

#initialize(side, id, size, price, expiration = nil) ⇒ LimitOrder

Returns a new instance of LimitOrder.



10
11
12
13
14
# File 'lib/gekko/limit_order.rb', line 10

def initialize(side, id, size, price, expiration = nil)
  super(side, id, size, expiration)
  @price = price
  raise 'Price must be a positive integer' if @price.nil? || (!@price.is_a?(Fixnum) || (@price <= 0))
end

Instance Attribute Details

#priceObject

Returns the value of attribute price.



8
9
10
# File 'lib/gekko/limit_order.rb', line 8

def price
  @price
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/gekko/limit_order.rb', line 23

def done?
  filled?
end

#filled?Boolean

Returns true if the order is filled

Returns:

  • (Boolean)


19
20
21
# File 'lib/gekko/limit_order.rb', line 19

def filled?
  remaining.zero?
end