Skip to content

Commit

Permalink
DEGIRO: Add interest
Browse files Browse the repository at this point in the history
  • Loading branch information
dickwolff committed Jan 3, 2025
1 parent 68b58bd commit f4d3535
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
4 changes: 3 additions & 1 deletion samples/degiro-export.csv
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ Datum,Tijd,Valutadatum,Product,ISIN,Omschrijving,FX,Mutatie,,Saldo,,Order Id
19-09-2024,20:20,19-09-2024,APPLE INC,US0378331005,Crédito de divisa,,EUR,408.83,EUR,638.81,711b1ad7-a370-4c88-bc86-074aada4a278
01-08-2024,07:40,31-07-2024,OXFORD SQUARE CAPITAL CORP,US69181V1070,Impôts sur dividende,,USD,-0.53,USD,2.97,
01-08-2024,07:39,31-07-2024,OXFORD SQUARE CAPITAL CORP,US69181V1070,Dividende,,USD,3.50,USD,3.50,
05-02-2024,07:18,31-01-2024,,,Giro Exchange Connection Fee 2024,,EUR,-2.50,EUR,655.40,
05-02-2024,07:18,31-01-2024,,,Giro Exchange Connection Fee 2024,,EUR,-2.50,EUR,655.40,
23-08-2024,12:21,23-08-2024,,,DEGIRO courtesy,,EUR,0.24,EUR,61.30,
23-08-2024,12:21,23-08-2024,,,DEGIRO courtesy,,EUR,0.61,EUR,61.06,
2 changes: 1 addition & 1 deletion src/converters/degiroConverterV2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("degiroConverterV2", () => {
// Assert
expect(actualExport).toBeTruthy();
expect(actualExport.activities.length).toBeGreaterThan(0);
expect(actualExport.activities.length).toBe(21);
expect(actualExport.activities.length).toBe(23);

done();
}, () => { done.fail("Should not have an error!"); });
Expand Down
30 changes: 30 additions & 0 deletions src/converters/degiroConverterV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ export class DeGiroConverterV2 extends AbstractConverter {
continue;
}

// Interest does not have a security, add it immediately.
if (this.isInterest(record)) {

const interestAmount = Math.abs(parseFloat(record.amount.replace(",", ".")));
const date = dayjs(`${record.date} ${record.time}:00`, "DD-MM-YYYY HH:mm");

result.activities.push({
accountId: process.env.GHOSTFOLIO_ACCOUNT_ID,
comment: "",
fee: 0,
quantity: 1,
type: GhostfolioOrderType.interest,
unitPrice: interestAmount,
currency: record.currency,
dataSource: "MANUAL",
date: date.format("YYYY-MM-DDTHH:mm:ssZ"),
symbol: record.description
});

bar1.increment(1);
continue;
}

// Look for the security for the current record.
let security: YahooFinanceRecord;
try {
Expand Down Expand Up @@ -414,4 +437,11 @@ export class DeGiroConverterV2 extends AbstractConverter {

return platformFeeRecordType.some((t) => record.description.toLocaleLowerCase().indexOf(t) > -1);
}

private isInterest(record: DeGiroRecord): boolean {

const interestRecordType = ["degiro courtesy"];

return interestRecordType.some((t) => record.description.toLocaleLowerCase().indexOf(t) > -1);
}
}
2 changes: 1 addition & 1 deletion src/converters/degiroConverterV3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("degiroConverterV3", () => {
// Assert
expect(actualExport).toBeTruthy();
expect(actualExport.activities.length).toBeGreaterThan(0);
expect(actualExport.activities.length).toBe(21);
expect(actualExport.activities.length).toBe(23);

done();
}, () => { done.fail("Should not have an error!"); });
Expand Down
30 changes: 30 additions & 0 deletions src/converters/degiroConverterV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,29 @@ export class DeGiroConverterV3 extends AbstractConverter {
continue;
}

// Interest does not have a security, add it immediately.
if (this.isInterest(record)) {

const interestAmount = Math.abs(parseFloat(record.amount.replace(",", ".")));
const date = dayjs(`${record.date} ${record.time}:00`, "DD-MM-YYYY HH:mm");

result.activities.push({
accountId: process.env.GHOSTFOLIO_ACCOUNT_ID,
comment: "",
fee: 0,
quantity: 1,
type: GhostfolioOrderType.interest,
unitPrice: interestAmount,
currency: record.currency,
dataSource: "MANUAL",
date: date.format("YYYY-MM-DDTHH:mm:ssZ"),
symbol: record.description
});

bar1.increment(1);
continue;
}

// Look for the security for the current record.
let security: YahooFinanceRecord;
try {
Expand Down Expand Up @@ -393,4 +416,11 @@ export class DeGiroConverterV3 extends AbstractConverter {

return platformFeeRecordType.some((t) => record.description.toLocaleLowerCase().indexOf(t) > -1);
}

private isInterest(record: DeGiroRecord): boolean {

const platformFeeRecordType = ["degiro courtesy"];

return platformFeeRecordType.some((t) => record.description.toLocaleLowerCase().indexOf(t) > -1);
}
}

0 comments on commit f4d3535

Please sign in to comment.