forked from EvergreenCrypto/docker-finance
docker-finance | modern accounting for the power-user
Dedicated to Michael Morgan: a beautiful, beautiful soul.
---
Internal signing keys:
Aaron Fiore (sole author)
- 518A22F85BEFD32BCC99C48603F90C4F35E0213E
- 31ECA5C347A0CC0815EDE730A3EACCFCDA7E685E
- C8187C585CB07A4DA81CC0F37318B50EBE9C0DA8
Internal repositories (rebased from):
Staging:
$ git log -n1 --pretty=format:"%H"
c8e0cd66f6c89fa7b3c62f72fb524a4cc454b7b6
$ git rev-list --max-parents=0 HEAD
ac3863b8c234755855f1aea3a07a853122decdf2
Private:
$ git log -n1 --pretty=format:"%H"
69bb3591eaa2990a9637832bb484690e00c4f926
$ git rev-list --max-parents=0 HEAD
a5c1cc9fb593c4cf09bc0adfef6cb6d2964511ae
This commit is contained in:
86
container/src/hledger-flow/accounts/etrade/etrade-shared.bash
Executable file
86
container/src/hledger-flow/accounts/etrade/etrade-shared.bash
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#
|
||||
# "Libraries"
|
||||
#
|
||||
|
||||
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/lib/lib_preprocess.bash" "$1" "$2"
|
||||
|
||||
#
|
||||
# Implementation
|
||||
#
|
||||
|
||||
[ -z "$global_year" ] && exit 1
|
||||
[ -z "$global_subaccount" ] && exit 1
|
||||
|
||||
[ -z "$global_in_path" ] && exit 1
|
||||
[ -z "$global_out_path" ] && exit 1
|
||||
|
||||
function parse()
|
||||
{
|
||||
# NOTE: skipping comments, header begins at line 3
|
||||
lib_preprocess::assert_header "TransactionDate,TransactionType,SecurityType,Symbol,Quantity,Amount,Price,Commission,Description" "$(sed -n '3p' $global_in_path)"
|
||||
|
||||
gawk -v global_year="$global_year" -v global_subaccount="$global_subaccount" \
|
||||
'{
|
||||
if (NR<4 || !NF)
|
||||
next
|
||||
|
||||
# Date format is MM/DD/YY
|
||||
yy=substr($1, 7, 2)
|
||||
global_yy=substr(global_year, 3, 2)
|
||||
|
||||
if (yy != global_yy)
|
||||
next
|
||||
|
||||
gsub(/^$/, "")
|
||||
gsub(/, ,/, ",USD,")
|
||||
|
||||
printf $1 OFS # TransactionDate
|
||||
printf $2 OFS # TransactionType
|
||||
printf $3 OFS # SecurityType
|
||||
printf $4 OFS # Symbol
|
||||
printf $5 OFS # Quantity
|
||||
|
||||
direction=($6 ~ /^-/ ? "OUT" : "IN")
|
||||
sub(/^-/, "", $6)
|
||||
printf $6 OFS # Amount
|
||||
|
||||
printf $7 OFS # Price
|
||||
printf $8 OFS # Comission
|
||||
printf $9 OFS # Description
|
||||
|
||||
printf direction OFS
|
||||
printf global_subaccount
|
||||
|
||||
printf "\n"
|
||||
|
||||
}' FS=, OFS=, "$global_in_path" >"$global_out_path"
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
parse
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
@@ -0,0 +1,85 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fields date,type,security_,currency_,amount_,fiat_amount,price,fees,description,direction,subaccount
|
||||
|
||||
date-format %m/%d/%y
|
||||
|
||||
# TODO: how to handle 'ProShares Ultra Semiconductors', ticker 'USD' ...
|
||||
|
||||
account1 assets:etrade:%subaccount:%currency_
|
||||
amount %amount_ %currency_
|
||||
|
||||
comment type:%type, security:%security_
|
||||
if %direction [A-Z]
|
||||
comment type:%type, security:%security_, direction:%direction
|
||||
|
||||
# TODO: currently needs to be added manually
|
||||
if %type ^Reorganization$
|
||||
skip
|
||||
|
||||
################################################################################
|
||||
# #
|
||||
# TRANSFER #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
if %direction ^IN$
|
||||
account2 equity:etrade:%subaccount:withdrawal:%currency_
|
||||
|
||||
if %direction ^IN$
|
||||
& %security_ UNKNOWN
|
||||
amount %fiat_amount %currency_
|
||||
|
||||
if %direction ^OUT$
|
||||
amount -%amount_ %currency_
|
||||
account2 equity:etrade:%subaccount:deposit:%currency_
|
||||
|
||||
if %direction ^OUT$
|
||||
& %security_ UNKNOWN
|
||||
amount -%fiat_amount %currency_
|
||||
|
||||
################################################################################
|
||||
# #
|
||||
# INCOME #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
if %type ^Interest$
|
||||
account1 assets:etrade:%subaccount:USD
|
||||
amount %fiat_amount USD
|
||||
account2 income:etrade:%subaccount:USD
|
||||
|
||||
################################################################################
|
||||
# #
|
||||
# TRADE #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
if %type (^Bought$|^Sold$)
|
||||
amount %amount_ %currency_ @ %price USD
|
||||
account2 assets:etrade:%subaccount:USD
|
||||
comment type:%type, security:%security_
|
||||
|
||||
if %type (^Bought$|^Sold$)
|
||||
& %fees [1-9]
|
||||
account3 assets:etrade:%subaccount:USD
|
||||
amount3 -%fees USD
|
||||
account4 expenses:etrade:%subaccount:fees:trades:USD
|
||||
amount4 %fees USD
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
23
container/src/hledger-flow/accounts/etrade/template/etrade-shared.bash
Executable file
23
container/src/hledger-flow/accounts/etrade/template/etrade-shared.bash
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
[ -z "$DOCKER_FINANCE_CONTAINER_REPO" ] && exit 1
|
||||
source "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow/accounts/etrade/etrade-shared.bash"
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
@@ -0,0 +1,20 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
include ../../../../../src/accounts/etrade/etrade-shared.rules
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
@@ -0,0 +1,14 @@
|
||||
For Account:,####1234
|
||||
|
||||
TransactionDate,TransactionType,SecurityType,Symbol,Quantity,Amount,Price,Commission,Description
|
||||
|
||||
12/31/23,Transfer,UNKNOWN, ,0,-5000,0,0,ACH WITHDRAWL REFID:00000000002;
|
||||
12/12/23,Sold,EQ,COIN,-50,7523.00,150.46,0,COINBASE GLOBAL INC CLASS A COMMON STOCK
|
||||
12/31/22,Interest,EQ,#1234567,0,0.10,0,0,EXTENDED INSURANCE SWEEP DEPOSIT ACCOUNT INTEREST
|
||||
12/20/22,Bought,EQ,COIN,100,-3515.00,35.15,0,COINBASE GLOBAL INC CLASS A COMMON STOCK
|
||||
12/15/22,Transfer,UNKNOWN, ,0,5000,0,0,ACH DEPOSIT REFID:00000000001;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,14 @@
|
||||
For Account:,####1234
|
||||
|
||||
TransactionDate,TransactionType,SecurityType,Symbol,Quantity,Amount,Price,Commission,Description
|
||||
|
||||
12/31/23,Transfer,UNKNOWN, ,0,-5000,0,0,ACH WITHDRAWL REFID:00000000002;
|
||||
12/12/23,Sold,EQ,COIN,-50,7523.00,150.46,0,COINBASE GLOBAL INC CLASS A COMMON STOCK
|
||||
12/31/22,Interest,EQ,#1234567,0,0.10,0,0,EXTENDED INSURANCE SWEEP DEPOSIT ACCOUNT INTEREST
|
||||
12/20/22,Bought,EQ,COIN,100,-3515.00,35.15,0,COINBASE GLOBAL INC CLASS A COMMON STOCK
|
||||
12/15/22,Transfer,UNKNOWN, ,0,5000,0,0,ACH DEPOSIT REFID:00000000001;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,14 @@
|
||||
For Account:,####1234
|
||||
|
||||
TransactionDate,TransactionType,SecurityType,Symbol,Quantity,Amount,Price,Commission,Description
|
||||
|
||||
12/31/23,Transfer,UNKNOWN, ,0,-5000,0,0,ACH WITHDRAWL REFID:00000000002;
|
||||
12/12/23,Sold,EQ,COIN,-50,7523.00,150.46,0,COINBASE GLOBAL INC CLASS A COMMON STOCK
|
||||
12/31/22,Interest,EQ,#1234567,0,0.10,0,0,EXTENDED INSURANCE SWEEP DEPOSIT ACCOUNT INTEREST
|
||||
12/20/22,Bought,EQ,COIN,100,-3515.00,35.15,0,COINBASE GLOBAL INC CLASS A COMMON STOCK
|
||||
12/15/22,Transfer,UNKNOWN, ,0,5000,0,0,ACH DEPOSIT REFID:00000000001;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,20 @@
|
||||
# docker-finance | modern accounting for the power-user
|
||||
#
|
||||
# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
include ../../etrade-shared.rules
|
||||
|
||||
# vim: sw=2 sts=2 si ai et
|
||||
@@ -0,0 +1 @@
|
||||
../../etrade-shared.bash
|
||||
Reference in New Issue
Block a user