Created
July 13, 2012 04:27
-
-
Save colindean/3102716 to your computer and use it in GitHub Desktop.
Quickly shows the most reasonable USD lowest asker and highest bidder from bitcoincharts.com
This file contains hidden or 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
#!/usr/bin/env ruby | |
require "open-uri" | |
require "json" | |
#get the data | |
j = JSON.parse open("http://bitcoincharts.com/t/markets.json").read | |
#only USD, only active exchanges, and only where there's a bid and ask | |
j.select! {|x| x["currency"] == "USD" and x["volume"] > 0 and !x["ask"].nil? and !x["bid"].nil?} | |
#sort, need lowest ask and highest bidder | |
ask = j.sort {|x,y| x["ask"] <=> y["ask"]} | |
bid = j.sort {|x,y| x["bid"] <=> y["bid"]} | |
puts "highest bidder:" | |
puts bid.last | |
puts "lowest seller:" | |
puts ask.first | |
puts "spread opportunity:" | |
puts spread = bid.last["bid"] - ask.first["ask"] | |
puts p = spread / bid.last["bid"] * 100 | |
puts "worth it! buy at #{ask.first["symbol"]}, sell at #{bid.last["symbol"]}" if p >= 6 | |
puts "not worth it" if p < 6 | |
2.times { puts "" } | |
gox = j.select {|x| x["symbol"] == "mtgoxUSD"} | |
cbx = j.select {|x| x["symbol"] == "cbxUSD"} | |
puts "cbx ask:" | |
puts a = cbx.first["ask"] | |
puts "gox bid:" | |
puts b = gox.first["bid"] | |
puts "diff:" | |
puts s = (b-a)/b*100 | |
puts "buy at cbx and sell at gox?" | |
if s > 6 | |
puts "yes" | |
else | |
puts "no" | |
end | |
2.times { puts "" } | |
puts "gox ask:" | |
puts a = gox.first["ask"] | |
puts "cbx bid:" | |
puts b = cbx.first["bid"] | |
puts "diff:" | |
puts s = (b-a)/b*100 | |
puts "buy at gox and sell at cbx?" | |
if s > 6 | |
puts "yes" | |
else | |
puts "no" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment