@@ -0,0 +1,2240 @@
+from exchanges import helpers%0Afrom exchanges import bitfinex%0Afrom exchanges import bitstamp%0Afrom exchanges import okcoin%0Afrom exchanges import cex%0Afrom exchanges import btce%0Afrom time import sleep%0Afrom datetime import datetime%0Aimport csv%0A%0A%0A# PREPARE OUTPUT FILE%0A%0A# tell computer where to put CSV%0Afilename = datetime.now().strftime(%22%25Y-%25m-%25d--%25H-%25M-%25S%22)%0Aoutfile_path='csvoutput'+filename+'.csv'%0A%0A# open it up, the w means we will write to it%0Awriter = csv.writer(open(outfile_path, 'w'))%0A%0A#create a list with headings for our columns%0Aheaders = %5B'datetime', 'bitstamp_price', 'bitstamp_bid', 'bitstamp_ask', 'bitfinex_price', 'bitfinex_bid', 'bitfinex_ask', 'okcoin_price', 'okcoin_bid', 'okcoin_ask', 'cex_price', 'cex_bid', 'cex_ask', 'btc-e_price', 'btc-e_bid', 'btc_ask'%5D%0A%0A#write the row of headings to our CSV file%0Awriter.writerow(headers)%0A%0A%0A%0A# GET DATA, PUT INTO FILE - LOOP FOR A CERTAIN TIME%0A%0A#set a counter telling us how many times we've gone through the loop, this is the first time, so we'll set it at 1%0Ai = 1%0A%0A#loop through pages of JSON returned, 100 is an arbitrary number%0Awhile i %3C 200:%0A  #print out what number loop we are on, which will make it easier to track down problems when they appear%0A  print i%0A%0A%0A  #initialize the row%0A  row = %5B%5D%0A  %0A  #add every 'cell' to the row list, identifying the item just like an index in a list%0A  row.append(datetime.now())%0A  row.append(bitstamp.get_current_price())%0A  row.append(bitstamp.get_current_bid())%0A  row.append(bitstamp.get_current_ask())%0A  row.append(bitfinex.get_current_price())%0A  row.append(bitfinex.get_current_bid())%0A  row.append(bitfinex.get_current_ask())%0A  row.append(okcoin.get_current_price())%09%0A  row.append(okcoin.get_current_bid())%0A  row.append(okcoin.get_current_ask())%0A  row.append(cex.get_current_price())%09%0A  row.append(cex.get_current_bid())%0A  row.append(cex.get_current_ask())%0A  row.append(btce.get_current_price())%09%0A  row.append(btce.get_current_ask())%0A  row.append(btce.get_current_bid())%0A  %0A  %0A  %0A  %0A  %0A  #once you have all the cells in there, write the row to your csv%0A  writer.writerow(row)%0A  %0A  #increment our loop counter, now we're on the next time through the loop%0A  i = i + 1%0A  #tell Python to rest for 5 secs, so we don't exceed our rate limit%0A  sleep(5)

Move original to this folder