-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatically adapt symbol changes
- Loading branch information
Rafael Augusto de Oliveira
committed
Dec 20, 2024
1 parent
88bf20a
commit 5f32ab4
Showing
3 changed files
with
223 additions
and
25 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,60 @@ | ||
# from tastytrade_ghostfolio.main import filter_dividends | ||
from tastytrade_ghostfolio.main import ( | ||
adapt_symbol_changes, | ||
extract_symbol_changes, | ||
filter_trades, | ||
) | ||
|
||
|
||
# def test_filter_dividends_happy_path(transactions, dividends): | ||
# result = filter_dividends(transactions) | ||
class TestFilterTrades: | ||
def test_should_filter_dividend_reinvestments( | ||
self, transactions, dividend_reinvestment_transaction_buy | ||
): | ||
result = filter_trades(transactions) | ||
|
||
# assert len(result) == 2 | ||
# assert result == dividends | ||
from tastytrade_ghostfolio.main import filter_trades | ||
assert dividend_reinvestment_transaction_buy in result | ||
|
||
def test_should_filter_buy_trades(self, transactions, trade_buy): | ||
result = filter_trades(transactions) | ||
|
||
def test_filter_trades_should_filter_dividend_reinvestments( | ||
transactions, dividend_reinvestment_transaction_buy | ||
): | ||
result = filter_trades(transactions) | ||
assert trade_buy in result | ||
|
||
assert len(result) == 2 | ||
assert dividend_reinvestment_transaction_buy in result | ||
def test_should_filter_symbol_changes( | ||
self, transactions, symbol_change_sell_old, symbol_change_buy_new | ||
): | ||
result = filter_trades(transactions) | ||
|
||
assert symbol_change_sell_old in result | ||
assert symbol_change_buy_new in result | ||
|
||
def test_filter_trades_should_filter_buy_trades(transactions, trade_buy): | ||
result = filter_trades(transactions) | ||
|
||
assert len(result) == 2 | ||
assert trade_buy in result | ||
class TestExtractSymbolChanges: | ||
def test_when_theres_symbol_change_should_return_transactions_and_changes_separately( | ||
self, transactions, symbol_changeless_transactions, symbol_change | ||
): | ||
clean_transactions, symbol_changes = extract_symbol_changes(transactions) | ||
|
||
assert clean_transactions == symbol_changeless_transactions | ||
assert symbol_changes == symbol_change | ||
|
||
def test_when_theres_no_symbol_change_should_return_all_transactions_and_empty_list( | ||
self, symbol_changeless_transactions | ||
): | ||
clean_transactions, symbol_changes = extract_symbol_changes( | ||
symbol_changeless_transactions | ||
) | ||
|
||
assert clean_transactions == symbol_changeless_transactions | ||
assert symbol_changes == [] | ||
|
||
|
||
class TestAdaptSymbolChanges: | ||
def test_should_map_old_symbol_to_new_one( | ||
self, symbol_changeless_transactions, symbol_change | ||
): | ||
result = adapt_symbol_changes(symbol_changeless_transactions, symbol_change) | ||
|
||
assert all( | ||
transaction.symbol == "COLA" | ||
for transaction in result | ||
if transaction.transaction_sub_type == "Dividend" | ||
) |