Bitcoin Forum
December 07, 2016, 02:49:31 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: bash script to download all mtgox trade history json data  (Read 2694 times)
mizerydearia
Hero Member
*****
Offline Offline

Activity: 574



View Profile
August 25, 2011, 08:42:44 PM
 #1

Here's a simple bash script to download all trade history json data from MtGox.

Update:
Code:
#!/bin/bash
outputfile=data
lasttrade=0
while test -n "$lasttrade";do
wget --quiet https://mtgox.com/code/data/getTrades.php?since=$lasttrade
if test "`cat getTrades.php\?since\=$lasttrade`" != "[]";then
cat getTrades.php\?since\=* >> $outputfile;
echo >> $outputfile;
lasttrade=`cat getTrades.php\?since\=$lasttrade|sed "s/,/\n/g"|grep tid|tail -n 1|cut -d ":" -f 2|cut -d "\"" -f 2`;
lasttradets=`cat getTrades.php\?since\=*|sed "s/,/\n/g"|grep date|tail -n 1|cut -d ":" -f 2`;
echo "$(date -d @$lasttradets)  tid $lasttrade"
else
echo Finished
fi
rm getTrades.php\?since\=*;
done

#!/bin/bash
outputfile=data
lasttrade=0
while test -n "$lasttrade";do
   wget --quiet https://mtgox.com/code/data/getTrades.php?since=$lasttrade
   cat getTrades.php\?since\=* >> $outputfile;
   echo >> $outputfile;
   lasttrade=`cat getTrades.php\?since\=*|sed "s/,/\n/g"|grep tid|tail -n 1|cut -d ":" -f 2|cut -d "\"" -f 2`;
   lasttradets=`cat getTrades.php\?since\=*|sed "s/,/\n/g"|grep date|tail -n 1|cut -d ":" -f 2`;
   if test -n "$lasttrade"; then echo "$(date -d @$lasttradets)  tid $lasttrade"; fi
   rm getTrades.php\?since\=*;
done


#!/bin/bash
outputfile=output
next=0
while test -n "$next";do
   wget https://mtgox.com/code/data/getTrades.php?since=$next
   cat getTrades.php\?since\=* >> $outputfile;
   echo >> $outputfile;
   next=`echo "$(cat getTrades.php\?since\=*|sed "s/,/\n/g"|grep tid|tail -n 1|cut -d ":" -f 2|cut -d "\"" -f 2)+1"|bc`;
   rm getTrades.php\?since\=*;
done


Here is a list of urls to download trade history from mtgox from very beginning tid 1 until tid 1314315710505672 with timestamp 1314315710 (Fri Aug 26 01:41:50 CEST 2011), each returning 100 results: http://pastebin.com/pmhMXZJu

download json data from torrent: http://www.wupload.com/file/124870046/mtgox_trades_json.ts-1314316120.js.torrent

Also see https://en.bitcoin.it/wiki/MtGox/API#0.2Fdata.2FgetTrades.php
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!