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

Fix: add _approx_equal_price_rounding to allow price in accepable range #571

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hermanho
Copy link
Contributor

@hermanho hermanho commented Nov 17, 2024

Fix: add _approx_equal_price_rounding to allow price in accepable range

Amount difference can be caused by rounding errors in the unit price.
Schwab rounds down the price to 4 decimal places so that the error in amount can be more than $0.01.
Fox example:
500 shares of FOO sold at $100.00016 with $1.23 fees.
"01/01/2024,"Sell","FOO","FOO","500","$100.0001","$1.23","$49,998.85"
calculated_amount = 500 * 100.0001 - 1.23 = 49998.82
amount_on_record = 49998.85 vs calculated_amount = 49998.82

In this PR change, the acceptable range of unit price is within $0.0001 when compare price on record and from retro calculation.

@hermanho hermanho force-pushed the fix/approx_equal_rounding branch from a14bb40 to 175a726 Compare November 17, 2024 21:49
cgt_calc/main.py Outdated
Comment on lines 95 to 94
LOGGER.debug(
"Price error in calculated_price %.6f vs price_on_record %s",
calculated_price,
price_on_record,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logs the same information as the lines below, can you please remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@hermanho hermanho force-pushed the fix/approx_equal_rounding branch 2 times, most recently from e28dbd2 to f8d03f5 Compare December 24, 2024 17:17
@hermanho hermanho force-pushed the fix/approx_equal_rounding branch from f8d03f5 to 582d3c0 Compare December 24, 2024 17:23
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

Successfully merging this pull request may close these issues.

2 participants