Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Booking order with intraday bookings #820

Open
korrat opened this issue Apr 15, 2024 · 0 comments
Open

Booking order with intraday bookings #820

korrat opened this issue Apr 15, 2024 · 0 comments

Comments

@korrat
Copy link
Contributor

korrat commented Apr 15, 2024

I'm trying to import transactions from Coinbase. For some assets, there are two internal accounts, the main balance and one staked coins. Due to the account structure, I'm using an intermediate account to book transfers, which causes errors, depending on the ordering of transactions inside the ledger.

An example:

2023-01-01 open Assets:Coinbase:EUR EUR
2023-01-01 open Assets:Coinbase:ATOM:Staking ATOM "FIFO"
2023-01-01 open Assets:Coinbase:ATOM:Wallet ATOM "FIFO"
2023-01-01 open Assets:Coinbase:Internal-Transfers ATOM "FIFO"

** Main Account

2023-01-01 * "Buy"
  Assets:Coinbase:ATOM:Wallet 1 ATOM {10 EUR}
  Assets:Coinbase:EUR

2023-01-05 * "Stake"
  Assets:Coinbase:ATOM:Wallet -1 ATOM {}
  Assets:Coinbase:Internal-Transfers 1 ATOM {10 EUR, 2023-01-01}

2023-01-15 * "Unstake"
  Assets:Coinbase:ATOM:Wallet 1 ATOM {10 EUR, 2023-01-01}
  Assets:Coinbase:Internal-Transfers -1 ATOM {}

** Staking Account

2023-01-05 * "Stake"
  Assets:Coinbase:ATOM:Staking 1 ATOM {10 EUR, 2023-01-01}
  Assets:Coinbase:Internal-Transfers -1 ATOM {}

2023-01-15 * "Unstake"
  Assets:Coinbase:ATOM:Staking -1 ATOM {}
  Assets:Coinbase:Internal-Transfers 1 ATOM {10 EUR, 2023-01-01}

This causes an error, because the unstaking transaction on the main account is processed before the one on the staking account. When the latter transaction is processed, there is no matching lot.

Manually ordering the erroring transaction before the working unstaking transaction works, so does merging the transaction to get rid of the intermediate account. Fudging the the date on the reducing transaction also works.

As an added complication in my use cases versus the example, I generally do not know the lots, nor do I want to specify them by hand, as on staking accounts there are numerous lots. Furthermore, I split my ledgers by accounts, but as the example shows, the issue also presents with different sections in the same file.

Some solution ideas (without any regard for feasibility), in preference order:

  1. Automatically attempt to reorder transactions on the same day “until it works” during booking. In the example above, a simple heuristic might be applying transactions with fully specified cost basis first before resorting to the booking method. Alternatively, augmenting transactions could be prioritized. I'm not sure how this would interact with plugins though.
  2. Add some metadata or similar to specify part of an entries sort-key that gets considered after the date but before the filename/line number.
  3. Modify the importer to discard half of the transactions (e.g., the transfers on the staking account) and only import the other half, producing transactions without the intermediate account. I consider this more of a workaround, but if you are unwilling to implement one of the previous solutions, this is what I would do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant