From 9c20d7955b7695aaa66f88a391c1866d0c640baa Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 19 Jan 2023 07:47:00 -1000 Subject: [PATCH] ;doc: csv: add new coinbase example --- hledger/hledger.m4.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index ac706d73e..97242ffca 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -3757,6 +3757,31 @@ The balance assertions don't raise an error above, because we're reading directly from CSV, but they will be checked if these entries are imported into a journal file. +### Coinbase + +A simple example with some CSV from Coinbase. The spot price is recorded using cost notation. +The legacy `amount` field name conveniently sets amount2 to the total cost. +```csv +# Timestamp,Transaction Type,Asset,Quantity Transacted,Spot Price Currency,Spot Price at Transaction,Subtotal,Total (inclusive of fees and/or spread),Fees and/or Spread,Notes +# 2021-12-30T06:57:59Z,Receive,USDC,100,GBP,0.740000,"","","","Received 100.00 USDC from an external account" +``` +```rules +# coinbase.csv.rules +skip 1 +fields Timestamp,Transaction_Type,Asset,Quantity_Transacted,Spot_Price_Currency,Spot_Price_at_Transaction,Subtotal,Total,Fees_Spread,Notes +date %Timestamp +date-format %Y-%m-%dT%T%Z +description %Notes +account1 assets:coinbase:cc +amount %Quantity_Transacted %Asset @ %Spot_Price_at_Transaction %Spot_Price_Currency +``` +```shell +$ hledger print -f coinbase.csv +2021-12-29 Received 100.00 USDC from an external account + assets:coinbase:cc 100 USDC @ 0.740000 GBP + income:unknown -74.000000 GBP +``` + ### Amazon Here we convert amazon.com order history, and use an if block to