Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / lbcsv2ledger
1445 bytesRaw
1 | #!/usr/bin/awk -f |
2 | |
3 | BEGIN { |
4 | FS=","; |
5 | } |
6 | { |
7 | created_at=$1 |
8 | if (created_at == "created_at") next; |
9 | buyer=$2 |
10 | seller=$3 |
11 | trade_type=$4 |
12 | btc_amount=$5 |
13 | fee_btc=$6 |
14 | btc_amount_less_fee=$7 |
15 | fiat_amount=$8 |
16 | fiat_fee=$9 |
17 | fiat_per_btc=$10 |
18 | currency=$11 |
19 | transaction_released_at=$12 |
20 | |
21 | i = index(transaction_released_at, " ")-1; |
22 | released_date = substr(transaction_released_at, 0, i); |
23 | gsub("-", "/", released_date); |
24 | |
25 | # As of 2013-12-18, localbitcoins csv does not include the fee. |
26 | # Calculate it here. |
27 | # For newer transactions, it seems to be included in the btc_amount |
28 | if (trade_type == "LOCAL_BUY") { |
29 | } else if (created_at > "2013-02-08" && created_at < "2013-07") { |
30 | fee_btc = btc_amount/100 |
31 | btc_amount += fee_btc |
32 | } else { |
33 | fee_btc = btc_amount/101 |
34 | } |
35 | |
36 | if (trade_type == "LOCAL_SELL") { |
37 | printf "%s (#) %s\n", released_date, buyer; |
38 | printf "\tAssets:Bitcoin:LocalBitcoins -%.8f BTC\n", btc_amount; |
39 | printf "\tExpenses:Broker:LocalBitcoins %.8f BTC\n", fee_btc; |
40 | printf "\tAssets:Cash $%.2f\n", fiat_amount; |
41 | } else if (trade_type == "LOCAL_BUY") { |
42 | printf "%s (#) %s\n", released_date, seller; |
43 | printf "\tAssets:Bitcoin:LocalBitcoins %.8f BTC\n", btc_amount; |
44 | printf "\tAssets:Cash -$%.2f\n", fiat_amount; |
45 | } |
46 | print ""; |
47 | } |
48 |
Built with git-ssb-web