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

Switch to Keyword Argument Calling Style #18

Open eprbell opened 2 years ago

eprbell commented 2 years ago

Currently RP2 uses keyword argument calling style inconsistently (mostly of the inconsitencies are in unit tests but there are a few in src as well). This issue has the purpose of switching all call sites with non-trivial number of arguments to keyword argument calling style.

The work on this issue will be incremental: you can open a PR for a single fix (or a few) and point it to this issue.

Some examples of fixes follow.

This RP2 src snippet:

           balance = Balance(
                configuration,
                self.__asset,
                account.exchange,
                account.holder,
                final_balance,
                acquired_balances.get(account, ZERO),
                sent_balances.get(account, ZERO),
                received_balances.get(account, ZERO),
            )

should become:

            balance = Balance(
                configuration=configuration,
                asset=self.__asset,
                exchange=account.exchange,
                account=account.holder,
                final_balance=final_balance,
                acquired_balance=acquired_balances.get(account, ZERO),
                sent_balance=sent_balances.get(account, ZERO),
                received_balance=received_balances.get(account, ZERO),
            )

And this unit test snippet:

        self._in_buy = InTransaction(
            self._configuration,
            "2020-01-02T08:42:43.882Z",
            "BTC",
            "Coinbase Pro",
            "Bob",
            "Buy",
            RP2Decimal("10000"),
            RP2Decimal("2.0002"),
            fiat_fee=RP2Decimal("20"),
            fiat_in_no_fee=RP2Decimal("20002"),
            fiat_in_with_fee=RP2Decimal("20022"),
            internal_id=10,
        )

should become:

        self._in_buy = InTransaction(
            configuration=self._configuration,
            timestamp="2020-01-02T08:42:43.882Z",
            asset="BTC",
            exchange="Coinbase Pro",
            holder="Bob",
            transaction_type="Buy",
            spot_price=RP2Decimal("10000"),
            crypto_in=RP2Decimal("2.0002"),
            fiat_fee=RP2Decimal("20"),
            fiat_in_no_fee=RP2Decimal("20002"),
            fiat_in_with_fee=RP2Decimal("20022"),
            internal_id=10,
        )