-
Notifications
You must be signed in to change notification settings - Fork 604
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
CSVAccountTransactionExtractor: Do not blindly ignore amount sign #3617
base: master
Are you sure you want to change the base?
CSVAccountTransactionExtractor: Do not blindly ignore amount sign #3617
Conversation
CSV importer's existing mental model is that each transaction would be explicitly categorized (via a "type" column) as Buy or Sell. It then just ignores the sign of transaction amount (by calling Math.abs()). This assumption is not realistic to cover all the cases. Another way is to have a generic "security transaction" type, and the sign of the amount signifies the actual operation, e.g. negative for Buy, positive for Sell. This change allows to handle such CSV statements, by "inverting" the configured transaction type. For example, if given type column value is mapped to "BUY", but amount is negative, it is turned into "SELL".
This addresses p.2 from #3616 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pfalcon,
thanks for the pull request. I like the change. It will give some more flexibility.
The build failure is due to code formatting of the new change (curly braces). Can you be so kind and format it with the default formatter in Eclipse (Ctrl-F)?
I think we should add a test case to CSVAccountTransactionExtractorTest that tests the new behavior. Otherwise it is too easy to accidentally break this new feature with a future commit. Can you be so kind and add one?
Finally, I believe we should have the same logic when importing "only" portfolio transactions: CSVPortfolioTransactionExtractor.java#L243-L249
Thanks for taking the time for a contribution to Portfolio Performance.
Andreas.
I have my doubts here that this is a good idea.... Several problems will arise here.
|
@Nirus2000 writes:
Let's recap what this change enables. Let's say we have a CSV of this format:
In this case, the type cannot be used to determine the transaction - the sign of the value is needed as well. If I understand your concerns, they are about negative values in the internal transactions model of Portfolio Performance. At the moment, I do not see this change allowing the negative values to leak in. |
Yes, this exemplifies a case we see here. I understand that it may change behavior for some users of CSV import, so it would depend on benefits it brings vs possible corner cases, and IMHO benefits outweigh. All in all, I posted it for feedback. I'll try to address review comments as time permits. (I otherwise have a whole bunch of changes in my fork, some adhoc, all without tests, but some certainly may be useful to other people, and to make PP a more generic tool (== cover more usecases), which should be a good aim for an open-source project.) |
CSV importer's existing mental model is that each transaction would be explicitly categorized (via a "type" column) as Buy or Sell. It then just ignores the sign of transaction amount (by calling Math.abs()).
This assumption is not realistic to cover all the cases. Another way is to have a generic "security transaction" type, and the sign of the amount signifies the actual operation, e.g. negative for Buy, positive for Sell.
This change allows to handle such CSV statements, by "inverting" the configured transaction type. For example, if given type column value is mapped to "BUY", but amount is negative, it is turned into "SELL".