It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency,
since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site;
Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in -
your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency
so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
two people pretty much nailed it. i'd say that some modifications pending both are eligible for the reward.
i'd like to host both in a html file on my server so i can make them publicly available. if both of you could provide upload and export functionality so i everyone can use this?
aside: i dunno if my webspace (bitcoinsinberlin.com) runs perl, actually.
the files that i can export from my mtgox account that are supposed to give me a clear image of what I have traded, deposited, withdrawn and paid as fees are close to unusable to me. not only do i use a different format for my 1000 and decimals (1.200,75 instead of 1,200.75), but also there's no way I am manually adding all those millibitcoins that i traded to make total for the day
i am looking for the following:
a script that takes the .csv as-is and automatically
- detects the currency - makes a total for EACH DAY displaying -- bought @ average price -- sold @ average price -- fees paid -- deposited -- withdrawn -- 24avg bitcoin price
I was looking for a script that would make it easy for my and my accountant to figure out what I had bought/sold/deposited/withdrawn/paidfees for a given time.
20BTC was bountied.
12.5 BTC went to the PHP script 7.5 BTC went to the Pearl scripts.
Please feel free to use them under the given license and consider tipping to contribute to my expenses.
Cheers 2weiX
The php code
Code:
/* This code is available to you under CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/).
If you use this tool to analyze your mtgox trades or use this code to build your own project, consider donating to 12weixK5ttMdjeoQgdGca9mKMKxkCxZkBG and consider adding your work to this thread: https://bitcointalk.org/index.php?topic=94769
function parsecsv($csv) { global $currency; $regex=array(); $regex['$']='/\] ([\d\.]+).+BTC at \$([\d\.]+)/'; $regex['€']='/\] ([\d\.]+).+BTC at ([\d\.]+)/'; $out=array(); foreach ($csv as $tmp) { $line=explode(',', $tmp); if (!is_numeric($line[0])) { continue; } $line[1]=preg_replace('/"(.+) .*/', '$1', $line[1]); if (!isset($out[$line[1]])) { $out[$line[1]]=array(); $out[$line[1]]['day']=$line[1]; $out[$line[1]]['deposit']=0; $out[$line[1]]['withdraw']=0; $out[$line[1]]['earned']=0; $out[$line[1]]['earnedbtc']=0; $out[$line[1]]['earnedcur']=0; $out[$line[1]]['earnedrate']=0; $out[$line[1]]['fee']=0; $out[$line[1]]['spent']=0; $out[$line[1]]['spentbtc']=0; $out[$line[1]]['spentcur']=0; $out[$line[1]]['spentrate']=0; } if ($line[2]=='deposit') { $out[$line[1]]['deposit']+=$line[4]; } elseif ($line[2]=='withdraw') { $out[$line[1]]['withdraw']+=$line[4]; } elseif ($line[2]=='fee') { $out[$line[1]]['fee']+=$line[4]; } elseif ($line[2]=='earned') { $out[$line[1]]['earned']+=$line[4]; if (preg_match($regex[$currency], $line[3], $tmp)) { $out[$line[1]]['earnedbtc']+=$tmp[1]; $out[$line[1]]['earnedcur']+=$line[4]; } } elseif ($line[2]=='spent') { $out[$line[1]]['spent']+=$line[4]; if (preg_match($regex[$currency], $line[3], $tmp)) { $out[$line[1]]['spentbtc']+=$tmp[1]; $out[$line[1]]['spentcur']+=$line[4]; } } } return($out); }
function makecsv($out, $currency) { $tmp=''; global $currency; foreach ($out as $i) { if ($i['spentcur']>0) { $i['spentrate']=$i['spentcur']/$i['spentbtc']; } if ($i['earnedbtc']>0) { $i['earnedrate']=$i['earnedcur']/$i['earnedbtc']; } $i['day']=preg_replace('/(\d\d\d\d)\-(\d\d)\-(\d\d)/', '$3.$2.$1', $i['day']); $tmp.=$i['day'].";DEPOSIT;".number_format($i['deposit'], 2, ',', '').$currency."\n"; $tmp.=$i['day'].";BUY;".number_format($i['spentbtc'], 8, ',', '')."BTC;".number_format($i['spentrate'], 8, ',', '').$currency."/BTC\n"; $tmp.=$i['day'].";SELL;".number_format($i['earnedbtc'], 8, ',', '')."BTC;".number_format($i['earnedrate'], 8, ',', '').$currency."/BTC\n"; $tmp.=$i['day'].";FEES;".number_format($i['fee'], 2, ',', '').$currency."\n"; $tmp.=$i['day'].";WITHDRAW;-".number_format($i['withdraw'], 2, ',', '').$currency."\n"; $tmp.="\n\n"; } $tmp.="This code is available to you under CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/).\n\n"; $tmp.="If you use this tool to analyze your mtgox trades or use this code to build your own project, consider\n"; $tmp.="donating to 12weixK5ttMdjeoQgdGca9mKMKxkCxZkBG and consider adding your work to this thread:\n"; $tmp.="https://bitcointalk.org/index.php?topic=94769\n\n"; $tmp.="Thank you!\n"; $tmp.="2weiX, Bitsky and jl2012\n"; return($tmp); }
?>
Pearl code for EUR
Code:
#!/usr/bin/perl use strict; open USD, "history_EUR.csv"; open OUTCSV, ">goxeur.csv"; open OUTCSVE, ">goxeur_e.csv"; my %array; #my @type = ("deposit", "withdraw", "earned", "spent", "fee"); while () { my ($date, $type, $info, $value, $balance) = ($_ =~ /^\d+,\"(\d{4}-\d{2}-\d{2}) .+?\",(.+?),(.+?),(.+?),(.+)/); $date || next; if (my ($x, $y) = $value =~ /(.*)E(.*)/) { $value = $x * (10 ** $y); } $array{$date}{$type} += $value; $array{$date}{balance} = $balance; if ($type eq "spent") { my ($btc, $price) = ($info =~ /(\d+\.\d+).*?BTC at \$?(\d+\.\d+)/); $array{$date}{totalspent} += $value; $array{$date}{totalboughtbtc} += $btc; } elsif ($type eq "earned") { my ($btc, $price) = ($info =~ /(\d+\.\d+).*?BTC at \$?(\d+\.\d+)/); $array{$date}{totalreceive} += $value; $array{$date}{totalsoldbtc} += $btc; } } foreach (sort keys %array) { if ($array{$_}{deposit}> 0) { print OUTCSV "\"$_\",\"DEPOSIT\",\"". sprintf("%.8f", $array{$_}{deposit}) . " EUR\"\n"; } if ($array{$_}{withdraw} > 0) { print OUTCSV "\"$_\",\"WITHDRAW\",\"". sprintf("%.8f", $array{$_}{withdraw}) . " EUR\"\n"; } if ($array{$_}{fee} > 0) { print OUTCSV "\"$_\",\"FEES\",\"". sprintf("%.8f", $array{$_}{fee}) . " EUR\"\n"; } if ($array{$_}{totalboughtbtc} > 0) { print OUTCSV "\"$_\",\"BUY\",\"". sprintf("%.8f", $array{$_}{totalboughtbtc}) . " BTC\",\"". $array{$_}{totalspent}/$array{$_}{totalboughtbtc} ." EUR\"\n"; } if ($array{$_}{totalsoldbtc} > 0) { print OUTCSV "\"$_\",\"SELL\",\"". sprintf("%.8f", $array{$_}{totalsoldbtc}) . " BTC\",\"". $array{$_}{totalreceive}/$array{$_}{totalsoldbtc} ." EUR\"\n"; } } close OUTCSV; open OUTCSV, "goxeur.csv"; while () { s/\./,/g; print OUTCSVE; }
Parl code for USD
Code:
#!/usr/bin/perl use strict; open USD, "history_USD.csv"; open OUTCSV, ">goxusd.csv"; open OUTCSVE, ">goxusd_e.csv"; my %array; #my @type = ("deposit", "withdraw", "earned", "spent", "fee"); while () { my ($date, $type, $info, $value, $balance) = ($_ =~ /^\d+,\"(\d{4}-\d{2}-\d{2}) .+?\",(.+?),(.+?),(.+?),(.+)/); $date || next; if (my ($x, $y) = $value =~ /(.*)E(.*)/) { $value = $x * (10 ** $y); } $array{$date}{$type} += $value; $array{$date}{balance} = $balance; if ($type eq "spent") { my ($btc, $price) = ($info =~ /(\d+\.\d+).*?BTC at \$?(\d+\.\d+)/); $array{$date}{totalspent} += $value; $array{$date}{totalboughtbtc} += $btc; } elsif ($type eq "earned") { my ($btc, $price) = ($info =~ /(\d+\.\d+).*?BTC at \$?(\d+\.\d+)/); $array{$date}{totalreceive} += $value; $array{$date}{totalsoldbtc} += $btc; } } foreach (sort keys %array) { if ($array{$_}{deposit}> 0) { print OUTCSV "\"$_\",\"DEPOSIT\",\"". sprintf("%.8f", $array{$_}{deposit}) . " USD\"\n"; } if ($array{$_}{withdraw} > 0) { print OUTCSV "\"$_\",\"WITHDRAW\",\"". sprintf("%.8f", $array{$_}{withdraw}) . " USD\"\n"; } if ($array{$_}{fee} > 0) { print OUTCSV "\"$_\",\"FEES\",\"". sprintf("%.8f", $array{$_}{fee}) . " USD\"\n"; } if ($array{$_}{totalboughtbtc} > 0) { print OUTCSV "\"$_\",\"BUY\",\"". sprintf("%.8f", $array{$_}{totalboughtbtc}) . " BTC\",\"". $array{$_}{totalspent}/$array{$_}{totalboughtbtc} ." USD\"\n"; } if ($array{$_}{totalsoldbtc} > 0) { print OUTCSV "\"$_\",\"SELL\",\"". sprintf("%.8f", $array{$_}{totalsoldbtc}) . " BTC\",\"". $array{$_}{totalreceive}/$array{$_}{totalsoldbtc} ." USD\"\n"; } } close OUTCSV; open OUTCSV, "goxusd.csv"; while () { s/\./,/g; print OUTCSVE; }