Skip to content

Instantly share code, notes, and snippets.

@burke
Created April 17, 2011 07:03
Show Gist options
  • Save burke/923812 to your computer and use it in GitHub Desktop.
Save burke/923812 to your computer and use it in GitHub Desktop.
require 'json'
require 'open-uri'
def most_recent_timestamp
data = JSON.parse(open('http://bitcoincharts.com/t/markets_timestamps.json').read)
data['mtgoxUSD'].to_i
end
def new_transactions(n)
data = JSON.parse(open("http://mtgox.com/code/data/getTrades.php").read)
data.select{|d|d['date'] > n }
end
prev = most_recent_timestamp
loop do
sleep 20
curr = most_recent_timestamp
if curr > prev
txns = new_transactions(prev)
txns.each do |e|
system "echo 'trade: #{e['amount']} at #{e['price']}' | growlnotify -a Bitcoin mtgoxUSD"
end
prev = curr
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment