Class: Gekko::MarketOrder

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

Overview

Represents a market order. If a bid, it must specify the maximum spendable quote currency as remaining quote margin

Instance Attribute Summary collapse

Attributes inherited from Order

#created_at, #expiration, #id, #price, #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, quote_margin, expiration = nil) ⇒ MarketOrder

Returns a new instance of MarketOrder.



11
12
13
14
15
16
17
# File 'lib/gekko/market_order.rb', line 11

def initialize(side, id, size, quote_margin, expiration = nil)
  super(side, id, size, expiration)
  @quote_margin           = quote_margin
  @remaining_quote_margin = @quote_margin
  raise 'Quote currency margin must be provided for a market bid'     if quote_margin.nil? && bid?
  raise 'Quote currency margin can not be specified for a market ask' if quote_margin && ask?
end

Instance Attribute Details

#quote_marginObject

Returns the value of attribute quote_margin.



9
10
11
# File 'lib/gekko/market_order.rb', line 9

def quote_margin
  @quote_margin
end

#remaining_quote_marginObject

Returns the value of attribute remaining_quote_margin.



9
10
11
# File 'lib/gekko/market_order.rb', line 9

def remaining_quote_margin
  @remaining_quote_margin
end

Instance Method Details

#done?Boolean

Returns true if the order has been filled or can not keep executing further due to quote currency margin constraints

Returns:

  • (Boolean)


30
31
32
# File 'lib/gekko/market_order.rb', line 30

def done?
  filled? || (bid? && remaining_quote_margin.zero?)
end

#filled?Boolean

Returns true if the order is filled

Returns:

  • (Boolean)


22
23
24
# File 'lib/gekko/market_order.rb', line 22

def filled?
  remaining.zero?
end