Skip to content

Commit a9de7de

Browse files
shuky19itshukychen
authored andcommitted
Fixing option security symbols
1 parent ebddcdb commit a9de7de

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

name.abuchen.portfolio.tests/src/name/abuchen/portfolio/datatransfer/ibflex/IBFlexStatementExtractorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,10 +2806,10 @@ public void testIBFlexStatementFile24() throws IOException
28062806
.collect(Collectors.toList());
28072807

28082808
assertThat(errors, empty());
2809-
assertThat(securityItems.size(), is(3));
2809+
assertThat(securityItems.size(), is(2));
28102810
assertThat(buySellTransactions.size(), is(0));
28112811
assertThat(accountTransactions.size(), is(4));
2812-
assertThat(results.size(), is(7));
2812+
assertThat(results.size(), is(6));
28132813
new AssertImportActions().check(results, CurrencyUnit.USD, CurrencyUnit.EUR);
28142814

28152815
assertThat(results, hasItem(sellOption( //

name.abuchen.portfolio/src/name/abuchen/portfolio/datatransfer/ibflex/IBFlexStatementExtractor.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,18 @@ private Security getOrCreateSecurity(Element element, boolean doCreate)
10301030

10311031
if (Arrays.asList(ASSETKEY_OPTION, ASSETKEY_FUTURE_OPTION).contains(element.getAttribute("assetCategory")))
10321032
{
1033-
// Converting symbol into Option name only to keep a single security per option trading asset
1034-
computedTickerSymbol = tickerSymbol.map(t -> t.replaceAll("\\s+.*", ""));
1035-
description = computedTickerSymbol.get();
1033+
if (element.hasAttribute("underlyingSymbol")) {
1034+
// Using the underlying symbol if possible
1035+
computedTickerSymbol = Optional.ofNullable(element.getAttribute("underlyingSymbol"));
1036+
description = computedTickerSymbol.get();
1037+
quoteFeed = YahooFinanceQuoteFeed.ID;
1038+
}
1039+
else
1040+
{
1041+
// Converting symbol into the trading asset (SPXW 20251207...) -> SPXW
1042+
computedTickerSymbol = tickerSymbol.map(t -> t.replaceAll("\\s+.*", ""));
1043+
description = computedTickerSymbol.get();
1044+
}
10361045
}
10371046

10381047
if (Arrays.asList(ASSETKEY_STOCK, ASSETKEY_FUND, ASSETKEY_CERTIFICATE)

0 commit comments

Comments
 (0)