Skip to content

Commit

Permalink
Fix nexo (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
VibeNL authored Oct 11, 2023
1 parent f4e9242 commit 1ffb3d1
Show file tree
Hide file tree
Showing 19 changed files with 457 additions and 510 deletions.
13 changes: 7 additions & 6 deletions ConsoleHelper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GhostfolioSidekick.FileImporter.Bunq;
using GhostfolioSidekick.FileImporter.DeGiro;
using GhostfolioSidekick.FileImporter.Generic;
using GhostfolioSidekick.FileImporter.Nexo;
using GhostfolioSidekick.FileImporter.ScalableCaptial;
using GhostfolioSidekick.FileImporter.Trading212;
using GhostfolioSidekick.Ghostfolio.API;
Expand All @@ -29,15 +30,15 @@ static void Main(string[] args)
MemoryCache memoryCache = new MemoryCache(new MemoryCacheOptions { });
GhostfolioAPI api = new GhostfolioAPI(cs, memoryCache, logger);
IScheduledWork t = new FileImporterTask(logger, api, cs, new IFileImporter[] {
new ScalableCapitalParser(api),
new DeGiroParser(api),
new Trading212Parser(api),
new GenericParser(api),
new BunqParser(api),
//new CoinbaseParser(api),
//new NexoParser(api),
new DeGiroParser(api),
new GenericParser(api),
new NexoParser(api),
new ScalableCapitalParser(api),
new Trading212Parser(api),
});
// t.DoWork().Wait();
t.DoWork().Wait();
t = new MarketDataMaintainerTask(logger, api);
t.DoWork().Wait();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task ConvertActivitiesForAccount_TestFileLifecycle_Converted()
var parser = new BunqParser(api.Object);
var fixture = new Fixture();

var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);

Expand All @@ -45,13 +45,13 @@ public async Task ConvertActivitiesForAccount_TestFileLifecycle_Converted()

// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.EUR, 903.5M, new DateTime(2023, 08, 18, 0, 0, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[] { new Model.Activity {
account.Activities.Should().BeEquivalentTo(new[] { new Activity {
Asset = null,
Comment = "Transaction Reference: [Interest_2023-07-27]",
Date = new DateTime(2023,07,27, 0,0,0, DateTimeKind.Utc),
Fee = null,
Quantity = 1m,
ActivityType = Model.ActivityType.Interest,
ActivityType = ActivityType.Interest,
UnitPrice = new Money(DefaultCurrency.EUR, 3.5M, new DateTime(2023,7,27, 0,0,0, DateTimeKind.Utc)),
ReferenceCode = "Interest_2023-07-27"
} });
Expand All @@ -64,7 +64,7 @@ public async Task ConvertActivitiesForAccount_TestMultipleDepositsOn1Day_Convert
var parser = new BunqParser(api.Object);
var fixture = new Fixture();

var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public async Task ConvertActivitiesForAccount_TestFileSingleOrder_Converted()
var parser = new DeGiroParser(api.Object);
var fixture = new Fixture();

var asset = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();
var asset = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);
api.Setup(x => x.FindSymbolByISIN("IE00B3XXRP09", null)).ReturnsAsync(asset);
Expand All @@ -60,13 +60,13 @@ public async Task ConvertActivitiesForAccount_TestFileSingleOrder_Converted()

// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.EUR, 21.70M, new DateTime(2023, 07, 10, 17, 34, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[] { new Model.Activity {
account.Activities.Should().BeEquivalentTo(new[] { new Activity {
Asset = asset,
Comment = "Transaction Reference: [b7ab0494-1b46-4e2f-9bd2-f79e6c87cb5b]",
Date = new DateTime(2023,07,6, 9, 39,0, DateTimeKind.Utc),
Fee = new Money(DefaultCurrency.EUR, 1, new DateTime(2023,07,6, 9, 39,0, DateTimeKind.Utc)),
Quantity = 1,
ActivityType = Model.ActivityType.Buy,
ActivityType = ActivityType.Buy,
UnitPrice = new Money(DefaultCurrency.EUR, 77.30M, new DateTime(2023,07,6, 9, 39,0, DateTimeKind.Utc)),
ReferenceCode = "b7ab0494-1b46-4e2f-9bd2-f79e6c87cb5b"
} });
Expand All @@ -79,10 +79,10 @@ public async Task ConvertActivitiesForAccount_TestFileMultipleOrders_Converted()
var parser = new DeGiroParser(api.Object);
var fixture = new Fixture();

var asset1 = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var asset2 = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var asset1 = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var asset2 = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();

var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);
api.Setup(x => x.FindSymbolByISIN("IE00B3XXRP09", null)).ReturnsAsync(asset1);
Expand All @@ -94,22 +94,22 @@ public async Task ConvertActivitiesForAccount_TestFileMultipleOrders_Converted()
// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.EUR, 23.83M, new DateTime(2023, 07, 13, 11, 49, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[]
{ new Model.Activity {
{ new Activity {
Asset = asset1,
Comment = "Transaction Reference: [b7ab0494-1b46-4e2f-9bd2-f79e6c87cb5b]",
Date = new DateTime(2023,07,6,9,39,0, DateTimeKind.Utc),
Fee = new Money(DefaultCurrency.EUR, 1, new DateTime(2023,07,6,9,39,0, DateTimeKind.Utc)),
Quantity = 1,
ActivityType = Model.ActivityType.Buy,
ActivityType = ActivityType.Buy,
UnitPrice = new Money(DefaultCurrency.EUR, 77.30M, new DateTime(2023,07,6,9,39,0, DateTimeKind.Utc)),
ReferenceCode = "b7ab0494-1b46-4e2f-9bd2-f79e6c87cb5b"
}, new Model.Activity {
}, new Activity {
Asset = asset2,
Comment = "Transaction Reference: [67e39ca1-2f10-4f82-8365-1baad98c398f]",
Date = new DateTime(2023,07,11, 9,33,0, DateTimeKind.Utc),
Fee = new Money(DefaultCurrency.EUR, 1, new DateTime(2023,07,11, 9,33,0, DateTimeKind.Utc)),
Quantity = 29,
ActivityType = Model.ActivityType.Buy,
ActivityType = ActivityType.Buy,
UnitPrice = new Money(DefaultCurrency.EUR, 34.375M, new DateTime(2023,07,11, 9,33,0, DateTimeKind.Utc)),
ReferenceCode = "67e39ca1-2f10-4f82-8365-1baad98c398f"
} });
Expand All @@ -122,8 +122,8 @@ public async Task ConvertActivitiesForAccount_TestFileDividend_WithTax_Converted
var parser = new DeGiroParser(api.Object);
var fixture = new Fixture();

var asset = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();
var asset = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);
api.Setup(x => x.FindSymbolByISIN("NL0009690239", null)).ReturnsAsync(asset);
Expand All @@ -133,13 +133,13 @@ public async Task ConvertActivitiesForAccount_TestFileDividend_WithTax_Converted

// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.EUR, 24.39M, new DateTime(2023, 09, 14, 6, 32, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[] { new Model.Activity {
account.Activities.Should().BeEquivalentTo(new[] { new Activity {
Asset = asset,
Comment = "Transaction Reference: [Dividend_14-09-2023_06:32_NL0009690239]",
Date = new DateTime(2023,09,14,6, 32,0, DateTimeKind.Utc),
Fee = null,
Quantity = 1,
ActivityType = Model.ActivityType.Dividend,
ActivityType = ActivityType.Dividend,
UnitPrice = new Money(DefaultCurrency.EUR, 8.13M, new DateTime(2023,09,14,6, 32,0, DateTimeKind.Utc)),
ReferenceCode = "Dividend_14-09-2023_06:32_NL0009690239"
} });
Expand All @@ -152,8 +152,8 @@ public async Task ConvertActivitiesForAccount_TestFileDividend_NoTax_Converted()
var parser = new DeGiroParser(api.Object);
var fixture = new Fixture();

var asset = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();
var asset = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.EUR).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.EUR)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);
api.Setup(x => x.FindSymbolByISIN("NL0009690239", null)).ReturnsAsync(asset);
Expand All @@ -163,13 +163,13 @@ public async Task ConvertActivitiesForAccount_TestFileDividend_NoTax_Converted()

// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.EUR, 33.96M, new DateTime(2023, 09, 14, 6, 32, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[] { new Model.Activity {
account.Activities.Should().BeEquivalentTo(new[] { new Activity {
Asset = asset,
Comment = "Transaction Reference: [Dividend_14-09-2023_06:32_NL0009690239]",
Date = new DateTime(2023,09,14,6, 32,0, DateTimeKind.Utc),
Fee = null,
Quantity = 1,
ActivityType = Model.ActivityType.Dividend,
ActivityType = ActivityType.Dividend,
UnitPrice = new Money(DefaultCurrency.EUR, 9.57M, new DateTime(2023,09,14,6, 32,0, DateTimeKind.Utc)),
ReferenceCode = "Dividend_14-09-2023_06:32_NL0009690239"
} });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public async Task ConvertActivitiesForAccount_TestFileSingleOrder_Converted()
var parser = new GenericParser(api.Object);
var fixture = new Fixture();

var asset = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.USD).Create();
var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.USD)).Create();
var asset = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.USD).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.USD)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);
api.Setup(x => x.FindSymbolByISIN("US67066G1040", null)).ReturnsAsync(asset);
Expand All @@ -47,13 +47,13 @@ public async Task ConvertActivitiesForAccount_TestFileSingleOrder_Converted()

// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.USD, -12.123956333000M, new DateTime(2023, 08, 7, 0, 0, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[] { new Model.Activity {
account.Activities.Should().BeEquivalentTo(new[] { new Activity {
Asset = asset,
Comment = "Transaction Reference: [Buy_US67066G1040_2023-08-07]",
Date = new DateTime(2023,08,7, 0,0,0, DateTimeKind.Utc),
Fee = new Money(DefaultCurrency.USD, 0.02M, new DateTime(2023,08,7, 0,0,0, DateTimeKind.Utc)),
Quantity = 0.0267001M,
ActivityType = Model.ActivityType.Buy,
ActivityType = ActivityType.Buy,
UnitPrice = new Money(DefaultCurrency.USD, 453.33M, new DateTime(2023,08,7, 0,0,0, DateTimeKind.Utc)),
ReferenceCode = "Buy_US67066G1040_2023-08-07"
} });
Expand All @@ -66,8 +66,8 @@ public async Task ConvertActivitiesForAccount_TestFileLifecycle_Converted()
var parser = new GenericParser(api.Object);
var fixture = new Fixture();

var asset = fixture.Build<Model.Asset>().With(x => x.Currency, DefaultCurrency.USD).Create();
var account = fixture.Build<Model.Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.USD)).Create();
var asset = fixture.Build<Asset>().With(x => x.Currency, DefaultCurrency.USD).Create();
var account = fixture.Build<Account>().With(x => x.Balance, Balance.Empty(DefaultCurrency.USD)).Create();

api.Setup(x => x.GetAccountByName(account.Name)).ReturnsAsync(account);
api.Setup(x => x.FindSymbolByISIN("US67066G1040", null)).ReturnsAsync(asset);
Expand All @@ -77,13 +77,13 @@ public async Task ConvertActivitiesForAccount_TestFileLifecycle_Converted()

// Assert
account.Balance.Current(DummyPriceConverter.Instance).Should().BeEquivalentTo(new Money(DefaultCurrency.USD, 589.98M, new DateTime(2023, 08, 8, 0, 0, 0, DateTimeKind.Utc)));
account.Activities.Should().BeEquivalentTo(new[] { new Model.Activity {
account.Activities.Should().BeEquivalentTo(new[] { new Activity {
Asset = asset,
Comment = "Transaction Reference: [Buy_US67066G1040_2023-08-07]",
Date = new DateTime(2023,08,7, 0,0,0, DateTimeKind.Utc),
Fee = new Money(DefaultCurrency.USD, 0.02M, new DateTime(2023,08,7, 0,0,0, DateTimeKind.Utc)),
Quantity = 4m,
ActivityType = Model.ActivityType.Buy,
ActivityType = ActivityType.Buy,
UnitPrice = new Money(DefaultCurrency.USD, 100M, new DateTime(2023,08,7, 0,0,0, DateTimeKind.Utc)),
ReferenceCode = "Buy_US67066G1040_2023-08-07"
} });
Expand Down
Loading

0 comments on commit 1ffb3d1

Please sign in to comment.