18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/devilicious/arbitrer.rb', line 18
def run!
@market_queue = []
spawn_observers!
loop do
sleep 1 while @market_queue.empty?
market_1 = @market_queue.shift
markets.each do |market_2|
next if market_1 == market_2
if market_1.order_book.nil? || market_2.order_book.nil?
Log.debug "Order book(s) not available, skipping"
next
end
order_book_1 = market_1.order_book.dup
order_book_2 = market_2.order_book.dup
order_book_1.market = market_1.dup
order_book_2.market = market_2.dup
check_for_opportunity(order_book_1, order_book_2)
check_for_opportunity(order_book_2, order_book_1)
end
end
end
|