eprbell / rp2

Privacy-focused, free, open-source cryptocurrency tax calculator for multiple countries: it handles multiple coins/exchanges and computes long/short-term capital gains, cost bases, in/out lot relationships/fractioning, and account balances. It supports FIFO, LIFO, HIFO and it outputs in form 8949 format. It has a programmable plugin architecture
https://pypi.org/project/rp2/
Apache License 2.0
270 stars 43 forks source link

Possibility of using Declarative programming language or Advanced T-SQL to perform HIFO, LIFO, FIFO & other accounting methods #117

Closed quocodilian closed 3 months ago

quocodilian commented 4 months ago

Hi guys, I've only discovered your cool project here and have only had a quick glance at the code. Python code looks cryptic to me at the moment :) I'm a C# developer; not a Python developer.

I'm just raising an idea here: Might it be possible at some point to use one of these options to perform the HIFO, LIFO, FIFO &/or any other accounting methods rp2 will support?

  1. Declarative programming language like Prolog. If a open-source or free version of Prolog could be used to link to a database of all the crypto transactions, then you could theoretically declare the problem you're trying to resolve, and Prolog would go to work finding that result, rather than us having to find the solution through procedural programming (sounds like a LOT of hard work!).
  2. Load the transactions into SQL Server database (hopefully a free version), and use Advanced T-SQL constructs/commands to come up with a solution for HIFO, LIFO, FIFO, etc for specific financial years.

I might try to write a quick & dirty version of idea 2 to sort out my own tax affairs, but it would be in .NET/C# and use a free or cheap version of SQL Server RDBMS. Not sure I have time for that though; we'll see :(

Just my two cents.. which doesn't count for much.

Thanks for reading, Huey.

quocodilian commented 4 months ago

Please feel free to ditch this issue :)

eprbell commented 4 months ago

Thanks for the message. To be honest, this sounds a bit clunky, especially considering that we already have:

So I see no need to reimplement the above and also introduce new dependencies: new plugins would simply follow the pattern of the existing ones. Having said that, this is an open-source project, so feel free to experiment with it in any way you find interesting.

eprbell commented 3 months ago

Closing this for now.

quocodilian commented 3 months ago

Thanks for the message. To be honest, this sounds a bit clunky, especially considering that we already have:

  • a clean and robust plugin architecture for native Python plugins;
  • three native accounting method plugins (FIFO, LIFO, HIFO) already implemented.

So I see no need to reimplement the above and also introduce new dependencies: new plugins would simply follow the pattern of the existing ones. Having said that, this is an open-source project, so feel free to experiment with it in any way you find interesting.

Yeah, it does sound clunky :) I might only try with my idea by writing a quick & dirty C# app talking to data in SQL Server and use SQL Server's advanced T-SQL commands. I'm not sure if it's possible; haven't thought too hard about it yet.

If I feel extra keen, I could look at writing these extensions/plugins to rp2 (after learning Python), thanks. And if I do, it'll definitely be using the already-established patterns :)