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

Add Parqet converter #106

Merged
merged 5 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
next-version: 0.17.1
next-version: 0.18.0
assembly-informational-format: "{NuGetVersion}"
mode: ContinuousDeployment
branches:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This tool allows you to convert a multiple transaction exports (CSV) to an impor
- [Freetrade](https://freetrade.io)
- [Interactive Brokers (IBKR)](https://www.interactivebrokers.com)
- [Investimental](https://www.investimental.ro/)
- [Parqet](https://www.parqet.com/)
- [Rabobank](https://rabobank.nl)
- [Schwab](https://www.schwab.com)
- [Swissquote](https://en.swissquote.com/)
Expand Down Expand Up @@ -79,6 +80,10 @@ Login to your Investimental account and click on the "Orders Daily Log". Select

![Export instructions for Investimental](./assets/export-investimental.png)

### Parqet

todo
dickwolff marked this conversation as resolved.
Show resolved Hide resolved

### Rabobank

Login to Rabobank and navigate to your investments. Navigate to "Transactions & Contract Notes" (Mutaties & Nota's). Select the range you wish to export at the top. Then scroll to the bottom of the page and click "Export as .csv"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "export-to-ghostfolio",
"version": "0.17.1",
"version": "0.18.0",
"type": "module",
"description": "Convert multiple broker exports to Ghostfolio import",
"scripts": {
Expand Down
28 changes: 28 additions & 0 deletions samples/parqet-export.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"datetime";"date";"time";"price";"shares";"amount";"tax";"fee";"realizedgains";"type";"broker";"assettype";"identifier";"wkn";"originalcurrency";"currency";"fxrate";"holding";"holdingname";"holdingnickname";"exchange";"avgholdingperiod";
"2024-08-02T07:00:00.001Z";"02.08.2024";"09:00:00";28,03;17,83803;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-08-02T07:00:00.000Z";"02.08.2024";"09:00:00";75,35;0,078433;5,91;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-08-02T07:00:00.000Z";"02.08.2024";"09:00:00";28,03;0,250089;7,01;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-07-23T07:00:00.000Z";"23.07.2024";"09:00:00";83,33;0,00036;0,03;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-07-16T07:00:00.001Z";"16.07.2024";"09:00:00";85,99;1,162925;100;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-07-16T07:00:00.000Z";"16.07.2024";"09:00:00";29,86;16,747613;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-07-16T07:00:00.000Z";"16.07.2024";"09:00:00";85,99;0,094894;8,16;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-07-15T07:00:00.000Z";"15.07.2024";"09:00:00";0,24;40;9,66;2,48;0;;"Dividend";"trade_republic";"Security";"US7561091049";"899744";;"EUR";;;"Realty Income";;;
"2024-07-09T07:00:00.000Z";"09.07.2024";"09:00:00";86,92;0,10941;9,51;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-07-02T07:00:00.001Z";"02.07.2024";"09:00:00";29,33;17,050298;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-07-02T07:00:00.000Z";"02.07.2024";"09:00:00";84,5;0,079526;6,72;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-07-02T07:00:00.000Z";"02.07.2024";"09:00:00";29,33;0,511508;15;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-06-24T07:00:00.000Z";"24.06.2024";"09:00:00";82,66;0,103435;8,55;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-06-17T07:00:00.001Z";"17.06.2024";"09:00:00";84,39;1,184974;100;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-06-17T07:00:00.000Z";"17.06.2024";"09:00:00";0,18;6;1,11;0,27;0;;"Dividend";"trade_republic";"Security";"US02079K3059";"A14Y6F";;"EUR";;;"Alphabet 'A'";;;
"2024-06-17T07:00:00.000Z";"17.06.2024";"09:00:00";29,09;17,190991;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-06-17T07:00:00.000Z";"17.06.2024";"09:00:00";84,39;0,298613;25,2;0;0;;"Buy";"trade_republic";"Security";"IE00BM67HT60";"A113FM";;"EUR";;;"Xtrackers MSCI World Information Technology UCITS ETF - 1C USD ACC";"";"";
"2024-06-14T07:00:00.000Z";"14.06.2024";"09:00:00";0,24;40;9,76;2,5;0;;"Dividend";"trade_republic";"Security";"US7561091049";"899744";;"EUR";;;"Realty Income";;;
"2024-06-04T12:04:00.000Z";"04.06.2024";"14:04:00";263;6;1578;14,83;1;600,12;"Sell";;"Security";"DE0008404005";"840400";;"EUR";;;"Allianz";;;51941820000
"2024-06-03T12:03:00.000Z";"03.06.2024";"14:03:00";28,32;17,655367;500;0;0;;"Buy";;"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-06-03T12:01:00.000Z";"03.06.2024";"14:01:00";28,32;0,47846;13,55;0;0;;"Buy";;"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-05-21T04:38:00.000Z";"21.05.2024";"06:38:00";2,2;12;26,4;0;0;;"Dividend";;"Security";"DE0007164600";"716460";;"EUR";;;"SAP";;;
"2024-05-15T22:41:00.000Z";"16.05.2024";"00:41:00";28,56;17,510068;500;0;0;;"Buy";;"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";
"2024-05-15T22:39:00.000Z";"16.05.2024";"00:39:00";22,88;14;320,32;-12,64;1;-636,72;"Sell";;"Security";"IL0011582033";"A2PLX6";;"EUR";;;"Fiverr International";;;72534780000
"2024-05-15T22:37:00.000Z";"16.05.2024";"00:37:00";0,23;7;1,61;0,42;0;;"Dividend";;"Security";"US0378331005";"865985";;"EUR";;;"Apple";;"gettex";
"2024-05-14T22:35:00.000Z";"15.05.2024";"00:35:00";0,24;40;9,6;2,51;0;;"Dividend";;"Security";"US7561091049";"899744";;"EUR";;;"Realty Income";;;
"2024-05-10T22:34:00.000Z";"11.05.2024";"00:34:00";13,8;6;82,8;11,46;0;;"Dividend";;"Security";"DE0008404005";"840400";;"EUR";;;"Allianz";;;
7 changes: 6 additions & 1 deletion src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { FreetradeConverter } from "./converters/freetradeConverter";
import { GhostfolioExport } from "./models/ghostfolioExport";
import { IbkrConverter } from "./converters/ibkrConverter";
import { InvestimentalConverter } from "./converters/investimentalConverter";
import { ParqetConverter } from "./converters/parqetConverter";
import { RabobankConverter } from "./converters/rabobankConverter";
import { SchwabConverter } from "./converters/schwabConverter";
import { SwissquoteConverter } from "./converters/swissquoteConverter";
Expand Down Expand Up @@ -89,7 +90,7 @@ async function createConverter(converterType: string): Promise<AbstractConverter
break;
case "degiro":
console.log("[i] Processing file using DeGiro converter");
console.log("[i] There is a new version of the DEGIRO converter available in public beta and we're looking for feedback!");
console.log("[i] There is a new version of the DEGIRO converter available in public beta and we're looking for feedback!");
console.log("[i] You can enable the new converter by setting the environment variable DEGIRO_FORCE_V3=true");
converter = new DeGiroConverterV2(securityService);
break;
Expand Down Expand Up @@ -121,6 +122,10 @@ async function createConverter(converterType: string): Promise<AbstractConverter
console.log("[i] Processing file using Investimental converter");
converter = new InvestimentalConverter(securityService);
break;
case "parqet":
console.log("[i] Processing file using Parqet converter");
converter = new ParqetConverter(securityService);
break;
case "rabobank":
console.log("[i] Processing file using Rabobank converter");
converter = new RabobankConverter(securityService);
Expand Down
2 changes: 1 addition & 1 deletion src/converters/bitvavoConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class BitvavoConverter extends AbstractConverter {
*/
protected processHeaders(_: string): string[] {

// Generic header mapping from the DEGIRO CSV export.
// Generic header mapping from the Bitvavo CSV export.
const csvHeaders = [
"timezone",
"date",
Expand Down
147 changes: 147 additions & 0 deletions src/converters/parqetConverter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { ParqetConverter } from "./parqetConverter";
import { SecurityService } from "../securityService";
import { GhostfolioExport } from "../models/ghostfolioExport";
import YahooFinanceServiceMock from "../testing/yahooFinanceServiceMock";

describe("parqetConverter", () => {

beforeEach(() => {
jest.spyOn(console, "log").mockImplementation(jest.fn());
});

afterEach(() => {
jest.clearAllMocks();
});

it("should construct", () => {

// Act
const sut = new ParqetConverter(new SecurityService(new YahooFinanceServiceMock()));

// Assert
expect(sut).toBeTruthy();
});

it("should process sample CSV file", (done) => {

// Arange
const sut = new ParqetConverter(new SecurityService(new YahooFinanceServiceMock()));
const inputFile = "samples/parqet-export.csv";

// Act
sut.readAndProcessFile(inputFile, (actualExport: GhostfolioExport) => {

// Assert
expect(actualExport).toBeTruthy();
expect(actualExport.activities.length).toBeGreaterThan(0);
expect(actualExport.activities.length).toBe(26);

done();
}, () => { done.fail("Should not have an error!"); });
});

describe("should throw an error if", () => {
it("the input file does not exist", (done) => {

// Arrange
const sut = new ParqetConverter(new SecurityService(new YahooFinanceServiceMock()));

let tempFileName = "tmp/testinput/parqet-filedoesnotexist.csv";

// Act
sut.readAndProcessFile(tempFileName, () => { done.fail("Should not succeed!"); }, (err: Error) => {

// Assert
expect(err).toBeTruthy();

done();
});
});

it("the input file is empty", (done) => {

// Arrange
const sut = new ParqetConverter(new SecurityService(new YahooFinanceServiceMock()));

let tempFileContent = "";
tempFileContent += `"datetime";"date";"time";"price";"shares";"amount";"tax";"fee";"realizedgains";"type";"broker";"assettype";"identifier";"wkn";"originalcurrency";"currency";"fxrate";"holding";"holdingname";"holdingnickname";"exchange";"avgholdingperiod";\n`;

// Act
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => {

// Assert
expect(err).toBeTruthy();
expect(err.message).toContain("An error ocurred while parsing");

done();
});
});

it("the header and row column count doesn't match", (done) => {

// Arrange
const sut = new ParqetConverter(new SecurityService(new YahooFinanceServiceMock()));

let tempFileContent = "";
tempFileContent += `"datetime";"date";"time";"price";"shares";"amount";"tax";"fee";"realizedgains";"type";"broker";"assettype";"identifier";"wkn";"originalcurrency";"currency";"fxrate";"holding";"holdingname";"holdingnickname";"exchange";"avgholdingperiod";\n`;
tempFileContent += `"2024-08-02T07:00:00.001Z";"02.08.2024";"09:00:00";28,03;17,83803;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";;;`;

// Act
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => {

// Assert
expect(err).toBeTruthy();
expect(err.message).toBe("An error ocurred while parsing! Details: Invalid Record Length: columns length is 22, got 24 on line 2");

done();
});
});

it("Yahoo Finance throws an error", (done) => {

// Arrange
let tempFileContent = "";
tempFileContent += `"datetime";"date";"time";"price";"shares";"amount";"tax";"fee";"realizedgains";"type";"broker";"assettype";"identifier";"wkn";"originalcurrency";"currency";"fxrate";"holding";"holdingname";"holdingnickname";"exchange";"avgholdingperiod";\n`;
tempFileContent += `"2024-08-02T07:00:00.001Z";"02.08.2024";"09:00:00";28,03;17,83803;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";`;

// Mock Yahoo Finance service to throw error.
const yahooFinanceServiceMock = new YahooFinanceServiceMock();
jest.spyOn(yahooFinanceServiceMock, "search").mockImplementation(() => { throw new Error("Unit test error"); });
const sut = new ParqetConverter(new SecurityService(yahooFinanceServiceMock));

// Act
sut.processFileContents(tempFileContent, () => { done.fail("Should not succeed!"); }, (err: Error) => {

// Assert
expect(err).toBeTruthy();
expect(err.message).toContain("Unit test error");

done();
});
});
});

it("should log when Yahoo Finance returns no symbol", (done) => {

// Arrange
let tempFileContent = "";
tempFileContent += `"datetime";"date";"time";"price";"shares";"amount";"tax";"fee";"realizedgains";"type";"broker";"assettype";"identifier";"wkn";"originalcurrency";"currency";"fxrate";"holding";"holdingname";"holdingnickname";"exchange";"avgholdingperiod";\n`;
tempFileContent += `"2024-08-02T07:00:00.001Z";"02.08.2024";"09:00:00";28,03;17,83803;500;0;0;;"Buy";"trade_republic";"Security";"LU2089238203";"A2PWMK";;"EUR";;;"Amundi Index Solutions Prime Global UCITS ETF - DR USD ACC";;"";`;

// Mock Yahoo Finance service to return no quotes.
const yahooFinanceServiceMock = new YahooFinanceServiceMock();
jest.spyOn(yahooFinanceServiceMock, "search").mockImplementation(() => { return Promise.resolve({ quotes: [] }) });
const sut = new ParqetConverter(new SecurityService(yahooFinanceServiceMock));

// Bit hacky, but it works.
const consoleSpy = jest.spyOn((sut as any).progress, "log");

// Act
sut.processFileContents(tempFileContent, () => {

expect(consoleSpy).toHaveBeenCalledWith("[i] No result found for buy action for LU2089238203! Please add this manually..\n");

done();
}, () => done.fail("Should not have an error!"));
});
});
Loading
Loading