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

Modify Trade Republic PDF-Importer to support cryptocurrency transaction #3524

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,29 @@
PDFBox Version: 1.8.16
-----------------------------------------
TRADE REPUBLIC BANK GMBH KASTANIENALLEE 32 10435 BERLIN
xxxxxxxxxxxxxxxxxxxxxxxx SEITE 1 von 1
xxxxxxxxxxxxxx DATUM 03.01.2022
xxxxxxxxxxxxxxxxxxxxx ORDER 2dc3-a410
AUSFÜHRUNG ce15-0e37
CRYPTO-WALLET BitGo
DEPOT 0000000000
ABRECHNUNG CRYPTOGESCHÄFT
ÜBERSICHT
Market-Order Kauf am 03.01.2022, um 12:32 Uhr (Europe/Berlin) im außerbörslichen Handel (Bankhaus
Scheich).
Der Kontrahent der Transaktion ist Bankhaus Scheich Wertpapierspezialist AG.
POSITION ANZAHL KURS BETRAG
Ethereum (ETH) 0,0878 Stk. 3.415,35 EUR 299,87 EUR
GESAMT 299,87 EUR
ABRECHNUNG
POSITION BETRAG
Fremdkostenzuschlag -1,00 EUR
GESAMT -300,87 EUR
BUCHUNG
VERRECHNUNGSKONTO VALUTA BETRAG
DE40110101008224044621 03.01.2022 -300,87 EUR
Diese Abrechnung wird maschinell erstellt und daher nicht unterschrieben.
Die Cryptowerte werden in einer zentralen Wallet bei dem Cryptoverwahrer BitGo Deutschland GmbH verwahrt.
Trade Republic Bank GmbH www.traderepublic.com Sitz der Gesellschaft: Düsseldorf Geschäftsführer
Kastanienallee 32 service@traderepublic.com AG Düsseldorf HRB 85864 Andreas Willius
10435 Berlin USt-ID DE307510626 Karsten Müller
@@ -0,0 +1,29 @@
```
PDFBox Version: 1.8.17
Portfolio Performance Version: 0.62.1
-----------------------------------------
TRADE REPUBLIC BANK GMBH KÖPENICKER STRASSE 40C 10179 BERLIN
VoeapbAgL Zgaze SEITE 1 von 1
UzFDuHrEU Str. 39 DATUM 16.05.2023
92540 Berlin AUSFÜHRUNG K7Y2-2e37
SPARPLAN y646-a753
CRYPTO- BitGo Deutschland
WALLET GmbH
DEPOT 7711975235
ABRECHNUNG CRYPTO SPARPLAN
ÜBERSICHT
Sparplanausführung am 16.05.2023 im außerbörslichen Handel Bankhaus Scheich.
Der Kontrahent der Transaktion ist Bankhaus Scheich Wertpapierspezialist AG.
POSITION ANZAHL DURCHSCHNITTSKURS BETRAG
Bitcoin (BTC) 0,000983 Stk. 25.424,22 EUR 24,99 EUR
GESAMT 24,99 EUR
BUCHUNG
VERRECHNUNGSKONTO WERTSTELLUNG BETRAG
DE00111122223333444455 16.05.2023 -24,99 EUR
Diese Abrechnung wird maschinell erstellt und daher nicht unterschrieben.
Die Cryptowerte werden in einer zentralen Wallet bei dem Cryptoverwahrer BitGo Deutschland GmbH verwahrt.
Trade Republic Bank GmbH www.traderepublic.com Sitz der Gesellschaft: Berlin Geschäftsführer
Köpenicker Straße 40c service@traderepublic.com AG Charlottenburg HRB 244347 B Andreas Torner
10179 Berlin USt-ID DE307510626 Gernot Mittendorfer

```
@@ -0,0 +1,30 @@
PDF Autor: ''
PDFBox Version: 1.8.16

TRADE REPUBLIC BANK GMBH KASTANIENALLEE 32 10435 BERLIN
XXXXXX XXXXXX SEITE 1 von 1
XXXXXX XXXXXX DATUM 06.10.2021
XXXXXX XXXXXX ORDER e010-35b5
AUSFÜHRUNG fc83-aeb4
CRYPTO-WALLET BitGo
DEPOT XXXXXXXXX
ABRECHNUNG CRYPTOGESCHÄFT
ÜBERSICHT
Market-Order Kauf am 06.10.2021, um 21:10 Uhr (Europe/Berlin) im außerbörslichen Handel (Bankhaus
Scheich).
Der Kontrahent der Transaktion ist Bankhaus Scheich Wertpapierspezialist AG.
POSITION ANZAHL KURS BETRAG
Bitcoin (BTC) 0,0026 Stk. 47.772,95 EUR 124,21 EUR
GESAMT 124,21 EUR
ABRECHNUNG
POSITION BETRAG
Fremdkostenzuschlag -1,00 EUR
GESAMT -125,21 EUR
BUCHUNG
VERRECHNUNGSKONTO VALUTA BETRAG
DEXXXXXXXXXXXX 06.10.2021 -125,21 EUR
Diese Abrechnung wird maschinell erstellt und daher nicht unterschrieben.
Die Cryptowerte werden in einer zentralen Wallet bei dem Cryptoverwahrer BitGo Deutschland GmbH verwahrt.
Trade Republic Bank GmbH www.traderepublic.com Sitz der Gesellschaft: Düsseldorf Geschäftsführer
Kastanienallee 32 service@traderepublic.com AG Düsseldorf HRB 85864 Andreas Willius
10435 Berlin USt-ID DE307510626 Karsten Müller
Expand Up @@ -12,6 +12,8 @@
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasAmount;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasCurrencyCode;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasDate;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasFeed;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasFeedProperty;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasFees;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasGrossValue;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.hasIsin;
Expand All @@ -25,6 +27,7 @@
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.purchase;
import static name.abuchen.portfolio.datatransfer.ExtractorMatchers.security;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Iterator;
Expand Down Expand Up @@ -54,10 +57,30 @@
import name.abuchen.portfolio.money.CurrencyUnit;
import name.abuchen.portfolio.money.Money;
import name.abuchen.portfolio.money.Values;
import name.abuchen.portfolio.online.impl.CoinGeckoQuoteFeed;

@SuppressWarnings("nls")
public class TradeRepublicPDFExtractorTest
{
TradeRepublicPDFExtractor extractor = new TradeRepublicPDFExtractor(new Client())
{
@Override
protected CoinGeckoQuoteFeed lookupFeed()
{
// mock the list of coins to avoid remote call
return new CoinGeckoQuoteFeed()
{
@Override
public synchronized List<Coin> getCoins() throws IOException
{
return List.of( //
new Coin("bitcoin", "BTC", "Bitcoin"), //
new Coin("ethereum", "ETH", "Ethereum"));
}
};
}
};

@Test
public void testKauf01()
{
Expand Down Expand Up @@ -410,6 +433,93 @@ public void testKauf08()
is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1.00))));
}

@Test
public void testCryptoKauf01()
{
List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "CryptoKauf01.txt"), errors);

assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(1L));
assertThat(countAccountTransactions(results), is(0L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin(null), hasWkn(null), hasTicker("ETH"), //
hasName("Ethereum"), //
hasCurrencyCode("EUR"), //
hasFeed(CoinGeckoQuoteFeed.ID), //
hasFeedProperty(CoinGeckoQuoteFeed.COINGECKO_COIN_ID, "ethereum"))));

// check buy sell transaction
assertThat(results, hasItem(purchase( //
hasDate("2022-01-03T12:32"), hasShares(0.0878), //
hasSource("CryptoKauf01.txt"), hasNote("Order: 2dc3-a410 | Ausführung: ce15-0e37"), //
hasAmount("EUR", 300.87), hasGrossValue("EUR", 299.87), //
hasTaxes("EUR", 0.00), hasFees("EUR", 1.00))));
}

@Test
public void testCryptoKauf02()
{
List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "CryptoKauf02.txt"), errors);

assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(1L));
assertThat(countAccountTransactions(results), is(0L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin(null), hasWkn(null), hasTicker("BTC"), //
hasName("Bitcoin"), //
hasCurrencyCode("EUR"), //
hasFeed(CoinGeckoQuoteFeed.ID), //
hasFeedProperty(CoinGeckoQuoteFeed.COINGECKO_COIN_ID, "bitcoin"))));

// check buy sell transaction
assertThat(results, hasItem(purchase( //
hasDate("2023-05-16T00:00"), hasShares(0.000983), //
hasSource("CryptoKauf02.txt"), hasNote("Sparplan: y646-a753 | Ausführung: K7Y2-2e37"), //
hasAmount("EUR", 24.99), hasGrossValue("EUR", 24.99), //
hasTaxes("EUR", 0.00), hasFees("EUR", 0.00))));
}

@Test
public void testCryptoKauf03()
{
List<Exception> errors = new ArrayList<>();

List<Item> results = extractor.extract(PDFInputFile.loadTestCase(getClass(), "CryptoKauf03.txt"), errors);

assertThat(countSecurities(results), is(1L));
assertThat(countBuySell(results), is(1L));
assertThat(countAccountTransactions(results), is(0L));
assertThat(results.size(), is(2));
new AssertImportActions().check(results, CurrencyUnit.EUR);

// check security
assertThat(results, hasItem(security( //
hasIsin(null), hasWkn(null), hasTicker("BTC"), //
hasName("Bitcoin"), //
hasCurrencyCode("EUR"), //
hasFeed(CoinGeckoQuoteFeed.ID), //
hasFeedProperty(CoinGeckoQuoteFeed.COINGECKO_COIN_ID, "bitcoin"))));

// check buy sell transaction
assertThat(results, hasItem(purchase( //
hasDate("2021-10-06T21:10"), hasShares(0.0026), //
hasSource("CryptoKauf03.txt"), hasNote("Order: e010-35b5 | Ausführung: fc83-aeb4"), //
hasAmount("EUR", 125.21), hasGrossValue("EUR", 124.21), //
hasTaxes("EUR", 0.00), hasFees("EUR", 1.00))));
}

@Test
public void testWertpapierKauf15()
{
Expand Down