From 1e3dd21baace029268493adb6bb60a684d3480da Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 10 Oct 2023 09:49:11 +0100 Subject: [PATCH] ;doc:examples: fidelity csv rules --- examples/csv/fidelity.csv.rules | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/csv/fidelity.csv.rules diff --git a/examples/csv/fidelity.csv.rules b/examples/csv/fidelity.csv.rules new file mode 100644 index 000000000..5744175a1 --- /dev/null +++ b/examples/csv/fidelity.csv.rules @@ -0,0 +1,42 @@ +# Fidelity account csv rules + +# This CSV needs the leading spaces removed before parsing, +# eg with sed 's/^ //'. Here's an example script automating that: +# echo "cleaning fidelity csv" +# for f in $(latestcsv ~/Downloads/History_for_Account_); do +# g=~/Downloads/$(basename $f csv)clean.csv +# sed -e 's/^ //' $f >$g +# done + +source History_for_Account_Z12345678*.clean.csv +newest-first +intra-day-reversed + +if ^([a-z]|Brokerage|Run) + skip +#" + +# Run Date,Action,Symbol,Security Description,Security Type,Quantity,Price ($),Commission ($),Fees ($),Accrued Interest ($),Amount ($),Settlement Date +# If you have multiple accounts there will also be an Account field after Run Date +# (and it might need preprocessing, see https://github.com/simonmichael/hledger/issues/2082). +fields Run_Date, Action, Symbol, Security_Description, Security_Type, Quantity, Price_Usd, Commission_Usd, Fees_Usd, Accrued_Interest_Usd, Amount_Usd, Settlement_Date + +date %Run_Date +date-format %m/%d/%Y + +description fidelity | %Action +currency $ + +# Transactions come in various types, including: + +# 08/09/2000," Electronic Funds Transfer Received (Cash)", ," No Description",Cash,0.000,,,,,1234, +if %Action Transfer Received \(Cash\) + account1 assets:bank:wf:bchecking + account2 assets:brokerage:fi:money:qpctq + amount -%Amount_Usd + +# 08/31/2000," INTEREST EARNED FDIC INSURED DEPOSIT AT CITIBANK NOT... (QPCTQ) (Cash)", QPCTQ," FDIC INSURED DEPOSIT AT CITIBANK NOT CO",Cash,0.000,,,,,12.34, +if %Action INTEREST EARNED + account1 revenues:dividends:qpctq + account2 assets:brokerage:fi:money:qpctq + amount -%Amount_Usd