Class: MatchOrderToSlope

Inherits:
Object
  • Object
show all
Defined in:
lib/moneymarket/commands/match_order_to_slope.rb

Instance Method Summary collapse

Instance Method Details

#performObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/moneymarket/commands/match_order_to_slope.rb', line 2

def perform
  Enumerator.new do |y|
    remaining = order.volume
    each_order do |match|
      next if match.timestamp > _order.timestamp # << this should trigger an alert, should never happen

      if match.volume >= remaining
        y << build_match(match, remaining)
        break
      else
        y << build_match(match, match.volume)
        remaining -= match.volume
      end
    end
  end
end