Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ibkr_report/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class AssetCategory(StrEnum):

STOCKS = "Stocks"
OPTIONS = "Equity and Index Options"
WARRANTS = "Warrants"


@unique
Expand Down
6 changes: 3 additions & 3 deletions ibkr_report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def add_trades(self, file: Iterable[bytes]) -> None:
except UnicodeDecodeError as err:
raise ValueError("Input data not in UTF-8 text format.") from err

def is_stock_or_options_trade(self, items: Tuple[str, ...]) -> bool:
def is_trade(self, items: Tuple[str, ...]) -> bool:
"""Checks whether the current row is part of a trade or not."""
if (
len(self.options.fields) == len(items)
Expand All @@ -89,7 +89,7 @@ def is_stock_or_options_trade(self, items: Tuple[str, ...]) -> bool:
and items[self.options.fields[Field.DATA_DISCRIMINATOR]]
in (DataDiscriminator.TRADE, DataDiscriminator.CLOSED_LOT)
and items[self.options.fields[Field.ASSET_CATEGORY]]
in (AssetCategory.STOCKS, AssetCategory.OPTIONS)
in (AssetCategory.STOCKS, AssetCategory.OPTIONS, AssetCategory.WARRANTS)
):
return True
return False
Expand All @@ -101,7 +101,7 @@ def _handle_one_line(self, items: Tuple[str, ...]) -> None:
for index, item in enumerate(items):
self.options.fields[item] = index
return
if self.options.fields and self.is_stock_or_options_trade(items):
if self.options.fields and self.is_trade(items):
self._handle_trade(items)

def _handle_trade(self, items: Tuple[str, ...]) -> None:
Expand Down