-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloop.rb
61 lines (44 loc) · 833 Bytes
/
loop.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'trex'
def wait_order uuid
until order = Trex::Order.get(Trex.env[:account], uuid)
sleep 1
end
until order.closed?
print "\r... "
sleep 0.5
print "\rOpen Order: #{uuid}."
sleep 0.5
end
return order
end
def order type, rate
puts "Order: #{type} - Rate: #{rate}"
j = JSON.parse(`./bin/order --account-file=#{Trex.env[:account_file]} --market=#{ARGV[1]} --#{type} --rate=#{rate} --amount=all`)
if e=j['err']
raise e
end
uuid = j['result']['uuid']
puts "Opened: #{uuid}"
wait_order uuid
end
def buy
order :buy, ARGV[2]
end
def sell
order :sell, ARGV[3]
end
class << self
def report
end
def run
loop do
@order = buy
report
sleep 1
@order = sell
report
sleep 1
end
end
end
run