-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for cash merger transactions (Schwab only) (#532)
* Add simpler cash merger transactions (schwab support only) * Fix warning --------- Co-authored-by: Ruslan Sayfutdinov <[email protected]>
- Loading branch information
Showing
6 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
WARNING: No schwab award file provided | ||
WARNING: Cash Merger support is not complete and doesn't cover the cases when shares are received aside from cash, please review this transaction carefully: SchwabTransaction(date=datetime.date(2021, 3, 2), action=<ActionType.CASH_MERGER: 16>, symbol='FOO', description='FOO INC', quantity=Decimal('100'), price=Decimal('10'), fees=Decimal('0'), amount=Decimal('1000'), currency='USD', broker='Charles Schwab') | ||
INFO: No schwab Equity Award JSON file provided | ||
INFO: No trading212 folder provided | ||
INFO: No mssb folder provided | ||
INFO: No sharesight file provided | ||
INFO: No raw file provided | ||
First pass completed | ||
Final portfolio: | ||
Final balance: | ||
Charles Schwab: 1000.00 (USD) | ||
Dividends: £0.00 | ||
Dividend taxes: £0.00 | ||
Interest: £0.00 | ||
Disposal proceeds: £711.69 | ||
|
||
|
||
Second pass completed | ||
Portfolio at the end of 2020/2021 tax year: | ||
For tax year 2020/2021: | ||
Number of disposals: 1 | ||
Disposal proceeds: £711.69 | ||
Allowable costs: £1783.50 | ||
Capital gain: £0.00 | ||
Capital loss: £1071.81 | ||
Total capital gain: £-1071.81 | ||
Taxable capital gain: £0 | ||
|
||
Generate calculations report | ||
All done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Date,Action,Symbol,Description,Price,Quantity,Fees & Comm,Amount | ||
03/02/2021,Cash Merger,FOO,FOO INC,,,,$1000 | ||
03/02/2021,Cash Merger Adj,FOO,FOO INC,,-100,, | ||
03/02/2021,Buy,FOO,FOO INC,$25,100,$6,-$2506 | ||
03/01/2016,MoneyLink Transfer,,Tfr BANK,,,,$2506.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Test Schwab Cash Merger support.""" | ||
|
||
from pathlib import Path | ||
import subprocess | ||
import sys | ||
|
||
|
||
def test_run_with_schwab_cash_merger_files() -> None: | ||
"""Runs the script and verifies it doesn't fail.""" | ||
cmd = [ | ||
sys.executable, | ||
"-m", | ||
"cgt_calc.main", | ||
"--year", | ||
"2020", | ||
"--schwab", | ||
"tests/test_data/schwab_cash_merger/transactions.csv", | ||
"--no-pdflatex", | ||
] | ||
result = subprocess.run(cmd, check=True, capture_output=True) | ||
assert result.stderr == b"", "Run with example files generated errors" | ||
expected_file = ( | ||
Path("tests") / "test_data" / "schwab_cash_merger" / "expected_output.txt" | ||
) | ||
expected = expected_file.read_text() | ||
cmd_str = " ".join([param if param else "''" for param in cmd]) | ||
assert result.stdout.decode("utf-8") == expected, ( | ||
"Run with example files generated unexpected outputs, " | ||
"if you added new features update the test with:\n" | ||
f"{cmd_str} > {expected_file}" | ||
) |