Skip to content

Instantly share code, notes, and snippets.

@petershaw
Created July 8, 2016 21:29
Show Gist options
  • Save petershaw/4e5d6aa8af687a1bb591e4beafd4da6a to your computer and use it in GitHub Desktop.
Save petershaw/4e5d6aa8af687a1bb591e4beafd4da6a to your computer and use it in GitHub Desktop.
use strict;
use warnings;
## Login your account,
## export the transactions as csv
## run the script
my $file = './Transactions.csv';
open my $info, $file or die "Could not open $file: $!";
my %account;
while( my $line = <$info>) {
my @line = split(/\,/, $line);
if($line[0] eq 'Market'){
$line[6] =~ s/^([0-9\.]+).*$/$1/;
$line[9] =~ s/^([a-zA-Z]+).*$/$1/;
chomp ($line[9]);
$account{$line[9]} += $line[6];
chomp $line[9];
}
}
close $info;
print "-"x30;
print "\n";
printf "Buy: %0.2f\n", $account{'Buy'};
printf "SELL: %.2f\n", $account{'Sell'};
printf "\nREV: %.2f\n", ($account{'Sell'} - $account{'Buy'});
print "-"x30;
print "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment