Bitcoin Forum
March 19, 2024, 03:22:58 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bash script to download all mtgox trade history json data  (Read 2914 times)
mizerydearia (OP)
Hero Member
*****
Offline Offline

Activity: 574
Merit: 507



View Profile
August 25, 2011, 08:42:44 PM
Last edit: August 26, 2011, 03:22:26 PM by mizerydearia
 #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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!