-
Notifications
You must be signed in to change notification settings - Fork 31
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
Resolve Withdrawals/Deposits #116
Conversation
# Conflicts: # src/main.py
If you provide a rough outline of how the solution is going to look, I am more than happy to help to implement this feature. |
Hey @jhoogstraat, awesome that you want to help. Does this give you the idea? |
Hey @jhoogstraat, thanks for helping! I added a to-do list in the top-comment above, based on the discussion in #4. Let me know if this makes sense to you. |
You can find the work in progress on my fork Hopefully I got the distinction between "balancing" and "taxation" right. As I said, this is just a rudimentary implementation that is missing many things. The approach basically goes through each platform and memorizes the "sold coins" when a withdrawal emerges (aka the reduction of the balance). In a second loop, the sold coins from the withdrawals are appended to the associated deposit. So deposits are regarded as buys and withdrawals as sells on the respective balance queues. |
I think it should be possible to balance the platforms and evaluate the taxation at the same time. Implementing this in the evaluation requires this to be easily refactor able in case we want to evaluate the taxation for another country. Is it necessary to add the new DepositMatch class instead of adding a new variable to all coins, which states where the coin is currently (besides the old variable for where the coin was bought)? |
Wasn't the goal to separate the balancing from taxation? Or what do you mean by "at the same time"? Should the withdrawals/deposits better be evaluated beforehand (in The new class is not strictly necessary. It currently just serves as a container for the rows in the wd.csv file. |
Good points. Keep on the good work. |
Thanks! The goal is for every operation to specify which coins exactly are exchanged via FIFO or LIFO queue. That would be equal to a That is basically how it works now, not respecting staking and potentially other operations. |
I think balancing means the part when the buys/sells are evaluated. E.g. buy 2 coins. Sell 1 coin. Sell 1 coin. Has operations buy(2), buy(1), sell(1), withdraw(2). The missing information is the link between the withdraw and deposit operation. So our first goal is to match deposit and withdraw operations and the second goal is to identify the coins with buy times and buy prices. The information about the moved coins could be saved in the deposit operation. On tax evaluation. The withdraw operation will remove coins from the queue (on withdraw. We do not care where the coins get moved to). The deposit operation will add/"buy" the coins which where identified earlier with the buy times and buy prices. This might be your tuple of sold coins. A tuple of operation and sold coins shouldn't be necessary as the sold coins know their operation (not sure about this). |
Thanks for clarifying. Withdrawals are handled as "selling" the coin on the specific platform queue, while deposits are just "buys" on the queue. As history cannot be changed, we could even cache the balancing to disk. |
Saving the withdrawal/deposit links might be a good idea. But keep in mind, that I could add a missing account statement after the first run. So the saved link should also save the latest transaction. If an even older account statement file is added later on, the links might have to be recalculated. |
some more ideas from me to the current implementation and my current favorite approach I think that it's quite rare, that you have withdrawal/deposits in your history, which can not be matched automatically/easily e.g. in my case: i rarly withdraw/deposit coins. for me it might be enough to just search for a deposit/withdrawal match by coin in an appropiate time frame. using a file to match deposit/withdrawals is in my eyes over the top. i'd recommend to stick to a basic matching algo.
If deposit/withdrawals come in the pattern: withdrawal, deposit, withdrawal, deposit; matching should be trivial. (check the |
I agree. I'll implement the matching algo in a new branch first. After that we can implement the balancing part. Especially because you are refactoring the BalanceQueue right now. That means I'll implement |
Balancing won't be an issue as soon as the matching is done. I'll add the balancing and evaluation afterwards.
I'd recommend to save the Withdrawal operation to each Deposit. We'll require much more information than just the source platform. Also the handling will be much easier. |
...and raise a warning when a Withdrawal matches to no Deposit. Make sure that each Withdrawal matches only to one Deposit, raise a warning when a Deposit has no Withdrawal. |
Ok, I implemented the most basic matching algorithm I could think of (matching attributes 'coin' and 'change'). We can build on this now. Does anyone have statements with some transfers in them? Doesn't matter if they are made up, as long as all transactions are valid. Transfers between coinbase and coinbase_pro are not reported in the respective transfers, but also feeless and thus tax-irrelevant. 3rd, warning are almost invisible using the debug log level. At least for me. |
Difficult question. Let's keep the tax evaluation separate from this PR. Might be enough to create your own transaction history. Make sure to account for withdrawal fees. E.g. withdrawal 100. Deposit 97 So we will need a matching Algo which looks for same coin and the same change or a bit lower change |
Maybe coinbase and coinbase_pro can be considered the same "platform" from a legal perspective? What makes a platform a platform? Anyhow, yes, the change might be lower for the deposit, and we have to account for that. I don't know common fee rates, so maybe go with withdrawal change - 5% as a minimum? |
Yeah why not. Just keep something like that or lower. If it's not enough. Issues will be raised. |
Done. How would you like to merge this? |
Might be easiest when merged into my working branch instead of master. |
The match-fees branch? I can rebase and squash my changes onto the branch, so you can just cherry pick the commit. I can also create a new pr if you prefer. |
Yes. Whatever you like most. You can reuse this branch if you like rebasing or resetting this. |
I am not the owner of this branch, so I don't think I can do that. |
In that case, just create a new branch. |
Closes #4
Dependencies that should be finished first
To-do list
acquire_platform
or similar to operationsacquire_platform
orplatform
)