use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class TransactionComparatorTest method testBuyIsPreferredOverSell.
@Test
public void testBuyIsPreferredOverSell() {
Portfolio portfolio = //
new PortfolioBuilder().sell(security, "2010-01-01", 100, //
100).buy(security, "2010-01-01", 100, //
100).addTo(client);
List<PortfolioTransaction> list = portfolio.getTransactions();
Collections.sort(list, new TransactionComparator());
assertThat(list.get(0).getType(), is(Type.BUY));
assertThat(list.get(1).getType(), is(Type.SELL));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class ClassificationTestCase method testCase7_Account30Account30.
@Test
public void testCase7_Account30Account30() {
Taxonomy case1 = client.getTaxonomies().stream().filter(t -> "case_7".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
// check performance of 'subcategory'
Classification ccategory = case1.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
assertThat(txp, hasSize(0));
List<AccountTransaction> txa = categoryClient.getAccounts().stream().filter(a -> "Konto 1".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.3)))))));
// check that transfer between two accounts is created
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.TRANSFER_IN)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
txa = categoryClient.getAccounts().stream().filter(a -> "Konto 2".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.TRANSFER_OUT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
// create index
List<Exception> warnings = new ArrayList<>();
PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
assertThat(warnings.isEmpty(), is(true));
assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(534.91)));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class ClassificationTestCase method testCase8_Security100Account30_SecurityTransfer.
@Test
public void testCase8_Security100Account30_SecurityTransfer() {
Taxonomy case8 = client.getTaxonomies().stream().filter(t -> "case_8".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
// check performance of 'subcategory'
Classification ccategory = case8.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
// check that inbound delivery is w/o taxes
assertThat(txp, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-01T00:00"))), //
hasProperty("type", is(PortfolioTransaction.Type.DELIVERY_INBOUND)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(3813.58 - 20)))))));
assertThat(txp, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), //
hasProperty("type", is(PortfolioTransaction.Type.DELIVERY_INBOUND)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(6640.30)))))));
List<AccountTransaction> txa = categoryClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
// check that dividends are included + removal to reflect the 30%
// assignment of the account
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DIVIDENDS)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(16.5)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(16.5 * 0.7)))))));
// tax refund w/ security
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-27T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10 * 0.3)))))));
// create index
List<Exception> warnings = new ArrayList<>();
PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
assertThat(warnings.isEmpty(), is(true));
assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(10563.68)));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class ClassificationTestCase method testCase5_Account70Account30.
@Test
public void testCase5_Account70Account30() {
Taxonomy case1 = client.getTaxonomies().stream().filter(t -> "case_5".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
// check performance of 'subcategory'
Classification ccategory = case1.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
assertThat(txp, hasSize(0));
List<AccountTransaction> txa = categoryClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.7)))))));
// check that transfer between two accounts is created
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.TRANSFER_IN)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.4)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.TRANSFER_OUT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
// check that taxes are not included:
// tax refund w/o security
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-26T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10 * 0.3)))))));
// tax refund w/ security
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-27T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10 * 0.3)))))));
// tax transaction
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-28T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10 * 0.3)))))));
// create index
List<Exception> warnings = new ArrayList<>();
PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
assertThat(warnings.isEmpty(), is(true));
assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(1034.17)));
}
use of name.abuchen.portfolio.model.PortfolioTransaction in project portfolio by buchen.
the class ClassificationTestCase method testCase6_Account30Account80.
@Test
public void testCase6_Account30Account80() {
Taxonomy case1 = client.getTaxonomies().stream().filter(t -> "case_6".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
// check performance of 'subcategory'
Classification ccategory = case1.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
assertThat(txp, hasSize(0));
List<AccountTransaction> txa = categoryClient.getAccounts().stream().filter(a -> "Konto 1".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.3)))))));
// check that transfer between two accounts is created
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.TRANSFER_IN)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
txa = categoryClient.getAccounts().stream().filter(a -> "Konto 2".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.TRANSFER_OUT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
assertThat(txa, hasItem(allOf(//
hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), //
hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.5)))))));
// create index
List<Exception> warnings = new ArrayList<>();
PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
assertThat(warnings.isEmpty(), is(true));
assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(802.34)));
}
Aggregations