Created
August 12, 2013 09:00
-
-
Save hannahherbig/6209303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bigdecimal' | |
max = min = count = start = last = bank = nil | |
$<.each_line do |line| | |
line.strip! | |
case line | |
when /^Starting with BANK of (.+) BTC$/ | |
start = last = bank = BigDecimal.new($1) | |
count = 0 | |
max = BigDecimal.new(-1) / 0 | |
min = BigDecimal.new(1) / 0 | |
when /^BANK: (.+)$/ | |
count += 1 | |
bank = BigDecimal.new($1) | |
profit = bank - start | |
change = bank - last | |
win = change >= 0 | |
up = profit >= 0 | |
print "\e[%dm%+d\e[m" % [change >= 0 ? 32 : 31, change] | |
last = bank | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bigdecimal' | |
count = start_bank = last_bank = bank = nil | |
$<.each_line do |line| | |
line.strip! | |
case line | |
when /^Starting with BANK of (.+) BTC$/ | |
start_bank = last_bank = bank = BigDecimal.new($1) | |
count = 0 | |
when /^BANK: (.+)$/ | |
count += 1 | |
bank = BigDecimal.new($1) | |
profit = bank - start_bank | |
change = bank - last_bank | |
win = change >= 0 | |
up = profit >= 0 | |
puts "%s | \e[%dm%+.8f\e[m | \e[%dm%+.8f\e[m | %.8f" % | |
[(Time.now.strftime '%H:%M:%S'), change >= 0 ? 32 : 31, change, | |
profit >= 0 ? 32 : 31, profit, bank] | |
# puts "\x03%d%+.8f\x03 | \x03%d%+.8f\x03 | %.8f" % | |
# [change >= 0 ? 3 : 4, change, profit >= 0 ? 3 : 4, profit, bank] | |
last_bank = bank | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bigdecimal' | |
max = min = count = start = last = bank = nil | |
$<.each_line do |line| | |
line.strip! | |
case line | |
when /^Starting with BANK of (.+) BTC$/ | |
start = last = bank = BigDecimal.new($1) | |
count = 0 | |
max = BigDecimal.new(-1) / 0 | |
min = BigDecimal.new(1) / 0 | |
when /^BANK: (.+)$/ | |
count += 1 | |
bank = BigDecimal.new($1) | |
profit = bank - start | |
change = bank - last | |
win = change >= 0 | |
up = profit >= 0 | |
print "\r%d | \e[%dm%+.8f\e[m | \e[%dm%+.8f\e[m | %.8f\e[K" % | |
[count, change >= 0 ? 32 : 31, change, | |
profit >= 0 ? 32 : 31, profit, bank] | |
if bank > max | |
puts | |
max = bank | |
end | |
if change < min | |
puts | |
min = change | |
end | |
last = bank | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment