Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / btce2ledger
1264 bytesRaw
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | |
5 | my $broker_account = 'Assets:Broker:BTC-E'; |
6 | my $fee_account = 'Expenses:Broker:BTC-E'; |
7 | |
8 | while (<>) { |
9 | my ($pair, $type, $amount, $price, $total, $date) = split ','; |
10 | next if $pair eq "Pair"; |
11 | |
12 | my ($day, $month, $year) = $date =~ /^([0-9]{2}).([0-9]{2}).([0-9]{2})/; |
13 | $date = "20$year/$month/$day"; |
14 | |
15 | my $description = ucfirst($type).' '.$pair; |
16 | my $sign = ($type eq 'sell') ? '-' : ''; |
17 | my $total_sign = ($type eq 'buy') ? '-' : ''; |
18 | |
19 | my ($cur1, $cur2) = split '/', $pair; |
20 | my ($amount_num, $amount_cur) = split ' ', $amount; |
21 | my ($total_num, $total_cur) = split ' ', $total; |
22 | |
23 | my ($fee_amount, $fee_cur); |
24 | |
25 | if ($type eq 'buy') { |
26 | $total_num *= -1; |
27 | $fee_cur = $amount_cur; |
28 | $fee_amount = $amount_num * 0.002; |
29 | $amount_num -= $fee_amount; |
30 | } else { |
31 | $amount_num *= -1; |
32 | $fee_cur = $total_cur; |
33 | $fee_amount = $total_num * 0.002; |
34 | $total_num -= $fee_amount; |
35 | } |
36 | printf "%s %s\n", $date, $description; |
37 | printf " %-20s %.8f %s\n", $broker_account, $amount_num, $amount_cur; |
38 | printf " %-20s %.8f %s\n", $fee_account, $fee_amount, $fee_cur; |
39 | printf " %-20s %.8f %s\n\n", $broker_account, $total_num, $total_cur; |
40 | } |
41 |
Built with git-ssb-web